diff --git a/.eslintrc.json b/.eslintrc.json index 0c7211db0fb0..8cd7cbdb3a18 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -129,7 +129,7 @@ "ecmaVersion": 2020, "sourceType": "script" }, - "ignorePatterns": ["dist/**/*", "types/**/*"], + "ignorePatterns": ["lib/**/*", "types/**/*", "test/types/**/*", "src/**/*.d.ts"], "plugins": ["mocha", "jsdoc", "@typescript-eslint"], "env": { "node": true, diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 75d39f137eb9..9a1d127fd6eb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,5 +1,9 @@ name: CI -on: [push, pull_request] +on: + push: + branches: + - v6 + pull_request: env: SEQ_DB: sequelize_test @@ -11,45 +15,82 @@ jobs: name: Lint code and docs runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 with: - node-version: 16.x - - run: yarn install --frozen-lockfile + node-version: 18.x + - run: yarn global add node-gyp --ignore-engines + - run: yarn install --frozen-lockfile --ignore-engines - run: yarn lint - run: yarn lint-docs docs: name: Generate docs runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 with: - node-version: 16.x - - run: yarn install --frozen-lockfile + node-version: 18.x + - run: yarn global add node-gyp --ignore-engines + - run: yarn install --frozen-lockfile --ignore-engines - run: yarn docs test-typings: strategy: fail-fast: false matrix: - ts-version: ["4.1", "4.2", "4.3", "4.4", "4.5"] + ts-version: ["4.1", "4.2", "4.3", "4.4", "4.5", "4.6", "4.7", "4.8", "4.9", "5.0", "5.1", "5.2"] name: TS Typings (${{ matrix.ts-version }}) runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 with: - node-version: 16.x - - run: yarn install --frozen-lockfile - - run: yarn add --dev typescript@~${{ matrix.ts-version }} + node-version: 18.x + - run: yarn global add node-gyp --ignore-engines + - run: yarn install --frozen-lockfile --ignore-engines + - run: yarn add --dev typescript@~${{ matrix.ts-version }} --ignore-engines - run: yarn test-typings + test-oracle: + strategy: + fail-fast: false + matrix: + oracle-version: [18, 23] + node-version: [10, 18] + name: Oracle DB ${{ matrix.oracle-version }} (Node ${{ matrix.node-version }}) + runs-on: ubuntu-22.04 + env: + DIALECT: oracle + SEQ_ORACLE_USER: sequelizetest + SEQ_ORACLE_PW: sequelizepassword + SEQ_ORACLE_DB: XEPDB1 + SEQ_ORACLE_HOST: localhost + SEQ_ORACLE_PORT: 1521 + LD_LIBRARY_PATH: ${{ github.workspace }}/.oracle/instantclient + UV_THREADPOOL_SIZE: 128 + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + - run: yarn global add node-gyp --ignore-engines + - run: yarn install --frozen-lockfile --ignore-engines + - if: matrix.oracle-version == '18' + name: Install Local Oracle DB 18 + run: yarn start-oracle-oldest + - if: matrix.oracle-version == '23' + name: Install Local Oracle DB 23 + run: yarn start-oracle-latest + - name: Unit Tests + run: yarn test-unit + - name: Integration Tests + run: yarn test-integration test-db2: strategy: fail-fast: false matrix: - node-version: [10, 16] + node-version: [10, 18] name: DB2 (Node ${{ matrix.node-version }}) - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 env: DIALECT: db2 SEQ_DB: testdb @@ -58,10 +99,11 @@ jobs: SEQ_TEST_CLEANUP_TIMEOUT: 1200000 SEQ_PORT: 50000 steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} + - run: yarn global add node-gyp --ignore-engines - run: yarn install --frozen-lockfile --ignore-engines - name: Install Local DB2 Copy run: yarn start-db2 @@ -75,16 +117,17 @@ jobs: strategy: fail-fast: false matrix: - node-version: [10, 16] + node-version: [10, 18] name: SQLite (Node ${{ matrix.node-version }}) - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 env: DIALECT: sqlite steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} + - run: yarn global add node-gyp --ignore-engines - run: yarn install --frozen-lockfile --ignore-engines - name: Unit Tests run: yarn test-unit @@ -94,12 +137,12 @@ jobs: strategy: fail-fast: false matrix: - node-version: [10, 16] + node-version: [10, 18] postgres-version: [9.5, 10] # Does not work with 12 minify-aliases: [true, false] native: [true, false] name: Postgres ${{ matrix.postgres-version }}${{ matrix.native && ' (native)' || '' }} (Node ${{ matrix.node-version }})${{ matrix.minify-aliases && ' (minified aliases)' || '' }} - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 services: postgres: image: sushantdhiman/postgres:${{ matrix.postgres-version }} @@ -116,10 +159,11 @@ jobs: SEQ_PG_MINIFY_ALIASES: ${{ matrix.minify-aliases && '1' || '' }} steps: - run: PGPASSWORD=sequelize_test psql -h localhost -p 5432 -U sequelize_test sequelize_test -c '\l' - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} + - run: yarn global add node-gyp --ignore-engines - run: yarn install --frozen-lockfile --ignore-engines - run: yarn add pg-native --ignore-engines if: matrix.native @@ -140,7 +184,7 @@ jobs: - name: MySQL 5.7 image: mysql:5.7 dialect: mysql - node-version: 16 + node-version: 18 - name: MySQL 8.0 image: mysql:8.0 dialect: mysql @@ -148,7 +192,7 @@ jobs: - name: MySQL 8.0 image: mysql:8.0 dialect: mysql - node-version: 16 + node-version: 18 - name: MariaDB 10.3 image: mariadb:10.3 dialect: mariadb @@ -156,7 +200,7 @@ jobs: - name: MariaDB 10.3 image: mariadb:10.3 dialect: mariadb - node-version: 16 + node-version: 18 - name: MariaDB 10.5 image: mariadb:10.5 dialect: mariadb @@ -164,9 +208,9 @@ jobs: - name: MariaDB 10.5 image: mariadb:10.5 dialect: mariadb - node-version: 16 + node-version: 18 name: ${{ matrix.name }} (Node ${{ matrix.node-version }}) - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 services: mysql: image: ${{ matrix.image }} @@ -183,10 +227,11 @@ jobs: DIALECT: ${{ matrix.dialect }} steps: - run: mysql --host 127.0.0.1 --port 3306 -uroot -psequelize_test -e "GRANT ALL ON *.* TO 'sequelize_test'@'%' with grant option; FLUSH PRIVILEGES;" - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} + - run: yarn global add node-gyp --ignore-engines - run: yarn install --frozen-lockfile --ignore-engines - name: Unit Tests run: yarn test-unit @@ -196,20 +241,21 @@ jobs: strategy: fail-fast: false matrix: - node-version: [10, 16] + node-version: [10, 18] mssql-version: [2017, 2019] name: MSSQL ${{ matrix.mssql-version }} (Node ${{ matrix.node-version }}) - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 services: mssql: image: mcr.microsoft.com/mssql/server:${{ matrix.mssql-version }}-latest env: ACCEPT_EULA: Y SA_PASSWORD: Password12! + MSSQL_SA_PASSWORD: Password12! ports: - 1433:1433 options: >- - --health-cmd="/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P \"Password12!\" -l 30 -Q \"SELECT 1\"" + --health-cmd="/opt/mssql-tools${{ matrix.mssql-version == '2019' && '18' || '' }}/bin/sqlcmd -S localhost -U SA -P \"Password12!\" -C -l 30 -Q \"SELECT 1\"" --health-start-period 10s --health-interval 10s --health-timeout 5s @@ -220,11 +266,12 @@ jobs: SEQ_PW: Password12! SEQ_PORT: 1433 steps: - - run: /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "Password12!" -Q "CREATE DATABASE sequelize_test; ALTER DATABASE sequelize_test SET READ_COMMITTED_SNAPSHOT ON;" - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 + - run: /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "Password12!" -C -Q "CREATE DATABASE sequelize_test; ALTER DATABASE sequelize_test SET READ_COMMITTED_SNAPSHOT ON;" + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} + - run: yarn global add node-gyp --ignore-engines - run: yarn install --frozen-lockfile --ignore-engines - name: Unit Tests run: yarn test-unit @@ -234,16 +281,17 @@ jobs: strategy: fail-fast: false matrix: - node-version: [10, 16] + node-version: [10, 18] name: SNOWFLAKE (Node ${{ matrix.node-version }}) - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 env: DIALECT: snowflake steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} + - run: yarn global add node-gyp --ignore-engines - run: yarn install --frozen-lockfile --ignore-engines - name: Unit Tests run: yarn test-unit @@ -260,7 +308,6 @@ jobs: test-sqlite, test-postgres, test-mysql-mariadb, - test-mssql, ] if: github.event_name == 'push' && (github.ref == 'refs/heads/v6' || github.ref == 'refs/heads/v6-beta') env: @@ -268,14 +315,19 @@ jobs: NPM_TOKEN: ${{ secrets.NPM_TOKEN }} steps: - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 + - uses: actions/setup-node@v3 with: - node-version: 16.x - - run: yarn install --frozen-lockfile + node-version: 18.x + - run: yarn global add node-gyp --ignore-engines + - run: yarn install --frozen-lockfile --ignore-engines - run: npx semantic-release - id: sequelize uses: sdepold/github-action-get-latest-release@master with: repository: sequelize/sequelize - - run: | + - name: Notify channels + run: | curl -XPOST -u "sdepold:${{ secrets.GH_TOKEN }}" -H "Accept: application/vnd.github.v3+json" -H "Content-Type: application/json" https://api.github.com/repos/sequelize/sequelize/dispatches --data '{"event_type":"Release notifier","client_payload":{"release-id": ${{ steps.sequelize.outputs.id }}}}' + - name: Notify docs repo + run: | + curl -XPOST -u "sdepold:${{ secrets.GH_TOKEN }}" -H "Accept: application/vnd.github.v3+json" -H "Content-Type: application/json" https://api.github.com/repos/sequelize/website/dispatches --data '{"event_type":"Build website"}' diff --git a/.gitignore b/.gitignore index 212837714c4f..54389f25c6e5 100644 --- a/.gitignore +++ b/.gitignore @@ -14,4 +14,6 @@ test/binary/tmp/* .vscode/ esdoc node_modules -dist +/lib +/types +.oracle/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index cb2cd52d453d..479465728745 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -9,7 +9,7 @@ We are happy to see that you might be interested in contributing to Sequelize! T - Reviewing (i.e. commenting on) open Pull Requests, to help their creators improve it if needed and allow maintainers to take less time looking into them - Helping to clarify issues opened by others, commenting and asking for clarification - Answering [questions tagged with `sequelize.js` on StackOverflow](https://stackoverflow.com/questions/tagged/sequelize.js) -- Helping people in our [public Slack channel](https://sequelize.slack.com/) (note: if you don't have access, get yourself an invite automatically via [this link](http://sequelize-slack.herokuapp.com/)) +- Helping people in our [public Slack channel](https://sequelize.slack.com/) (note: if you don't have access, get yourself an invite automatically via [this link](https://sequelize.org/slack)) Sequelize is strongly moved by contributions from people like you. All maintainers also work on their free time here. diff --git a/README.md b/README.md index cd9db8121f61..3bc983b542ae 100644 --- a/README.md +++ b/README.md @@ -1,75 +1,83 @@

- -

Sequelize

+ Sequelize logo +

Sequelize

[![npm version](https://badgen.net/npm/v/sequelize)](https://www.npmjs.com/package/sequelize) [![Build Status](https://github.com/sequelize/sequelize/workflows/CI/badge.svg)](https://github.com/sequelize/sequelize/actions?query=workflow%3ACI) [![npm downloads](https://badgen.net/npm/dm/sequelize)](https://www.npmjs.com/package/sequelize) +[![contributors](https://img.shields.io/github/contributors/sequelize/sequelize)](https://github.com/sequelize/sequelize/graphs/contributors) +[![Open Collective](https://img.shields.io/opencollective/backers/sequelize)](https://opencollective.com/sequelize#section-contributors) [![sponsor](https://img.shields.io/opencollective/all/sequelize?label=sponsors)](https://opencollective.com/sequelize) [![Merged PRs](https://badgen.net/github/merged-prs/sequelize/sequelize)](https://github.com/sequelize/sequelize) [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) +[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) -Sequelize is a promise-based [Node.js](https://nodejs.org/en/about/) [ORM tool](https://en.wikipedia.org/wiki/Object-relational_mapping) for [Postgres](https://en.wikipedia.org/wiki/PostgreSQL), [MySQL](https://en.wikipedia.org/wiki/MySQL), [MariaDB](https://en.wikipedia.org/wiki/MariaDB), [SQLite](https://en.wikipedia.org/wiki/SQLite), [DB2](https://en.wikipedia.org/wiki/IBM_Db2_Family) and [Microsoft SQL Server](https://en.wikipedia.org/wiki/Microsoft_SQL_Server). It features solid transaction support, relations, eager and lazy loading, read replication and more. +Sequelize is an easy-to-use and promise-based [Node.js](https://nodejs.org/en/about/) [ORM tool](https://en.wikipedia.org/wiki/Object-relational_mapping) for [Postgres](https://en.wikipedia.org/wiki/PostgreSQL), [MySQL](https://en.wikipedia.org/wiki/MySQL), [MariaDB](https://en.wikipedia.org/wiki/MariaDB), [SQLite](https://en.wikipedia.org/wiki/SQLite), [DB2](https://en.wikipedia.org/wiki/IBM_Db2_Family), [Microsoft SQL Server](https://en.wikipedia.org/wiki/Microsoft_SQL_Server), and [Snowflake](https://www.snowflake.com/). It features solid transaction support, relations, eager and lazy loading, read replication and more. -Sequelize follows [Semantic Versioning](http://semver.org) and supports Node v10 and above. +Would you like to contribute? Read [our contribution guidelines](https://github.com/sequelize/sequelize/blob/main/CONTRIBUTING.md) to know more. There are many ways to help! 😃 -New to Sequelize? Take a look at the [Tutorials and Guides](https://sequelize.org/master). You might also be interested in the [API Reference](https://sequelize.org/master/identifiers). +## 🚀 Seeking New Maintainers for Sequelize! 🚀 -Would you like to contribute? Read [our contribution guidelines](https://github.com/sequelize/sequelize/blob/main/CONTRIBUTING.md) to know more. There are many ways to help. +We're looking for new maintainers to help finalize and release the next major version of Sequelize! If you're passionate about open-source and database ORMs, we'd love to have you onboard. -### v6 Release +### 💰 Funding Available +We distribute **$2,500 per quarter** among maintainers and have additional funds for full-time contributions. -You can find the detailed changelog [here](https://github.com/sequelize/sequelize/blob/main/docs/manual/other-topics/upgrade-to-v6.md). +### 🛠️ What You’ll Work On +- Finalizing and releasing Sequelize’s next major version +- Improving TypeScript support and database integrations +- Fixing critical issues and shaping the ORM’s future -## Supporting the project +### 🤝 How to Get Involved +Interested? Join our Slack and reach out to **@WikiRik** or **@sdepold**: +➡️ **[sequelize.org/slack](https://sequelize.org/slack)** -Do you like Sequelize and would like to give back to the engineering team behind it? +We’d love to have you on board! 🚀 -We have recently created an [OpenCollective based money pool](https://opencollective.com/sequelize) which is shared amongst all core maintainers based on their contributions. Every support is wholeheartedly welcome. ❤️ +## :computer: Getting Started + +Ready to start using Sequelize? Head to [sequelize.org](https://sequelize.org) to begin! -## Installation +- [Our Getting Started guide for Sequelize 6 (stable)](https://sequelize.org/docs/v6/getting-started) -```sh -$ npm i sequelize # This will install v6 +## :money_with_wings: Supporting the project -# And one of the following: -$ npm i pg pg-hstore # Postgres -$ npm i mysql2 -$ npm i mariadb -$ npm i sqlite3 -$ npm i tedious # Microsoft SQL Server -$ npm i ibm_db #DB2 -``` +Do you like Sequelize and would like to give back to the engineering team behind it? -## Documentation +We have recently created an [OpenCollective based money pool](https://opencollective.com/sequelize) which is shared amongst all core maintainers based on their contributions. Every support is wholeheartedly welcome. ❤️ -- [v6 Documentation](https://sequelize.org/master) -- [v5/v4/v3 Documentation](https://sequelize.org) -- [Contributing](https://github.com/sequelize/sequelize/blob/main/CONTRIBUTING.md) +## :pencil: Major version changelog -## Responsible disclosure +Please find upgrade information to major versions here: -If you have security issues to report, please refer to our [Responsible Disclosure Policy](https://github.com/sequelize/sequelize/blob/main/SECURITY.md) for more details. +- [Upgrade from v5 to v6](https://sequelize.org/docs/v6/other-topics/upgrade-to-v6) -## Resources +## :book: Resources +- [Documentation](https://sequelize.org) +- [Databases Compatibility Table](https://sequelize.org/releases/) - [Changelog](https://github.com/sequelize/sequelize/releases) -- [Slack Inviter](http://sequelize-slack.herokuapp.com/) +- [Discussions](https://github.com/sequelize/sequelize/discussions) +- [Slack](https://sequelize.org/slack) - [Stack Overflow](https://stackoverflow.com/questions/tagged/sequelize.js) -### Tools +### :wrench: Tools - [CLI](https://github.com/sequelize/cli) -- [With TypeScript](https://sequelize.org/master/manual/typescript.html) +- [With TypeScript](https://sequelize.org/docs/v6/other-topics/typescript) - [Enhanced TypeScript with decorators](https://github.com/RobinBuschmann/sequelize-typescript) - [For GraphQL](https://github.com/mickhansen/graphql-sequelize) - [For CockroachDB](https://github.com/cockroachdb/sequelize-cockroachdb) -- [Plugins](https://sequelize.org/master/manual/resources.html) +- [Awesome Sequelize](https://sequelize.org/docs/v6/other-topics/resources/) - [For YugabyteDB](https://github.com/yugabyte/sequelize-yugabytedb) -### Translations +### :speech_balloon: Translations + +- [English](https://sequelize.org) (Official) +- [中文文档](https://github.com/demopark/sequelize-docs-Zh-CN) (Unofficial) -- [English](https://sequelize.org/master) (OFFICIAL) -- [中文文档](https://github.com/demopark/sequelize-docs-Zh-CN) (UNOFFICIAL) +## :warning: Responsible disclosure +If you have security issues to report, please refer to our +[Responsible Disclosure Policy](https://github.com/sequelize/sequelize/blob/main/SECURITY.md) for more details. diff --git a/build.js b/build.js index 2302c47949b2..a8b1f4604749 100644 --- a/build.js +++ b/build.js @@ -13,22 +13,23 @@ const copyFile = promisify(fs.copyFile); // if this script is moved, this will need to be adjusted const rootDir = __dirname; -const outdir = path.join(rootDir, 'dist'); +const outdir = path.join(rootDir, 'lib'); +const typesDir = path.join(rootDir, 'types'); const nodeMajorVersion = Number(process.version.match(/(?<=^v)\d+/)); -async function rmDistDir() { +async function rmDir(dirName) { try { - await stat(outdir); + await stat(dirName); if (nodeMajorVersion >= 14) { const rm = promisify(fs.rm); - await rm(outdir, { recursive: true }); + await rm(dirName, { recursive: true }); } else { const rmdir = promisify(fs.rmdir); if (nodeMajorVersion >= 12) { - await rmdir(outdir, { recursive: true }); + await rmdir(dirName, { recursive: true }); } else { - await rmdir(outdir); + await rmdir(dirName); }} } catch { /* no-op */ @@ -37,23 +38,46 @@ async function rmDistDir() { async function main() { console.log('Compiling sequelize...'); - const [declarationFiles, filesToCompile] = await Promise.all([ - // Find all .d.ts files from types/ - glob('./types/**/*.d.ts', { onlyFiles: true, absolute: false }), - // Find all .js and .ts files from lib/ - glob('./lib/**/*.[tj]s', { onlyFiles: true, absolute: false }), - // Delete dist/ for a full rebuild. - rmDistDir() + const [sourceFiles] = await Promise.all([ + // Find all .js and .ts files from /src + glob('./src/**/*.{mjs,cjs,js,mts,cts,ts}', { onlyFiles: true, absolute: false }), + // Delete /lib for a full rebuild. + rmDir(outdir), + // Delete /types for a full rebuild. + rmDir(typesDir) ]); + const filesToCompile = []; + const filesToCopyToLib = []; + const declarationFiles = []; + + for (const file of sourceFiles) { + // mjs files cannot be built as they would be compiled to commonjs + if (file.endsWith('.mjs')) { + filesToCopyToLib.push(file); + } else if (file.endsWith('.d.ts')) { + declarationFiles.push(file); + } else { + filesToCompile.push(file); + } + } + // copy .d.ts files prior to generating them from the .ts files // so the .ts files in lib/ will take priority.. await copyFiles( // The last path in the list is the output directory - declarationFiles.concat(outdir), + declarationFiles.concat(typesDir), { up: 1 } ); + if (filesToCopyToLib.length > 0) { + await copyFiles( + // The last path in the list is the output directory + filesToCopyToLib.concat(outdir), + { up: 1 } + ); + } + await Promise.all([ build({ // Adds source mapping @@ -65,13 +89,9 @@ async function main() { outdir, entryPoints: filesToCompile - .concat('./index.js') .map(file => path.resolve(file)) }), - // not passed to "build" because we need this file to stay as ESM instead of CJS - copyFile('./index.mjs', path.resolve(outdir, './index.mjs')), - exec('tsc', { env: { // binaries installed from modules have symlinks in diff --git a/dev/mariadb/10.3/start.sh b/dev/mariadb/10.3/start.sh index 30af181cb667..492b19bca12e 100755 --- a/dev/mariadb/10.3/start.sh +++ b/dev/mariadb/10.3/start.sh @@ -3,8 +3,8 @@ set -Eeuxo pipefail # https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" # https://stackoverflow.com/a/17744637 -docker-compose -p sequelize-mariadb-103 down --remove-orphans -docker-compose -p sequelize-mariadb-103 up -d +docker compose -p sequelize-mariadb-103 down --remove-orphans +docker compose -p sequelize-mariadb-103 up -d ./../../wait-until-healthy.sh sequelize-mariadb-103 diff --git a/dev/mariadb/10.3/stop.sh b/dev/mariadb/10.3/stop.sh index e2629c115979..bee20b8ff7bd 100755 --- a/dev/mariadb/10.3/stop.sh +++ b/dev/mariadb/10.3/stop.sh @@ -3,6 +3,6 @@ set -Eeuxo pipefail # https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" # https://stackoverflow.com/a/17744637 -docker-compose -p sequelize-mariadb-103 down --remove-orphans +docker compose -p sequelize-mariadb-103 down --remove-orphans echo "Local MariaDB-10.3 instance stopped (if it was running)." diff --git a/dev/mssql/2019/start.sh b/dev/mssql/2019/start.sh index 9fe3c2b48997..61ec91ac623a 100755 --- a/dev/mssql/2019/start.sh +++ b/dev/mssql/2019/start.sh @@ -3,14 +3,14 @@ set -Eeuxo pipefail # https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" # https://stackoverflow.com/a/17744637 -docker-compose -p sequelize-mssql-2019 down --remove-orphans -docker-compose -p sequelize-mssql-2019 up -d +docker compose -p sequelize-mssql-2019 down --remove-orphans +docker compose -p sequelize-mssql-2019 up -d ./../../wait-until-healthy.sh sequelize-mssql-2019 docker exec sequelize-mssql-2019 \ /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "Password12!" -Q "CREATE DATABASE sequelize_test; ALTER DATABASE sequelize_test SET READ_COMMITTED_SNAPSHOT ON;" -node check.js +DIALECT=mssql node check.js echo "Local MSSQL-2019 instance is ready for Sequelize tests." diff --git a/dev/mssql/2019/stop.sh b/dev/mssql/2019/stop.sh index 0c8d73b3fee1..10249f0e619d 100755 --- a/dev/mssql/2019/stop.sh +++ b/dev/mssql/2019/stop.sh @@ -3,6 +3,6 @@ set -Eeuxo pipefail # https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" # https://stackoverflow.com/a/17744637 -docker-compose -p sequelize-mssql-2019 down --remove-orphans +docker compose -p sequelize-mssql-2019 down --remove-orphans echo "Local MSSQL-2019 instance stopped (if it was running)." diff --git a/dev/mysql/5.7/start.sh b/dev/mysql/5.7/start.sh index fb8b02a8b43d..8ef78e301c16 100755 --- a/dev/mysql/5.7/start.sh +++ b/dev/mysql/5.7/start.sh @@ -3,8 +3,8 @@ set -Eeuxo pipefail # https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" # https://stackoverflow.com/a/17744637 -docker-compose -p sequelize-mysql-57 down --remove-orphans -docker-compose -p sequelize-mysql-57 up -d +docker compose -p sequelize-mysql-57 down --remove-orphans +docker compose -p sequelize-mysql-57 up -d ./../../wait-until-healthy.sh sequelize-mysql-57 diff --git a/dev/mysql/5.7/stop.sh b/dev/mysql/5.7/stop.sh index 36e3e076065e..60c6a7b3d868 100755 --- a/dev/mysql/5.7/stop.sh +++ b/dev/mysql/5.7/stop.sh @@ -3,6 +3,6 @@ set -Eeuxo pipefail # https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" # https://stackoverflow.com/a/17744637 -docker-compose -p sequelize-mysql-57 down --remove-orphans +docker compose -p sequelize-mysql-57 down --remove-orphans echo "Local MySQL-5.7 instance stopped (if it was running)." diff --git a/dev/mysql/8.0/start.sh b/dev/mysql/8.0/start.sh index d3b0aaab912c..046ba95d145b 100755 --- a/dev/mysql/8.0/start.sh +++ b/dev/mysql/8.0/start.sh @@ -3,8 +3,8 @@ set -Eeuxo pipefail # https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" # https://stackoverflow.com/a/17744637 -docker-compose -p sequelize-mysql-80 down --remove-orphans -docker-compose -p sequelize-mysql-80 up -d +docker compose -p sequelize-mysql-80 down --remove-orphans +docker compose -p sequelize-mysql-80 up -d ./../../wait-until-healthy.sh sequelize-mysql-80 diff --git a/dev/mysql/8.0/stop.sh b/dev/mysql/8.0/stop.sh index a5a6492ca0f7..8bcf3da8323e 100755 --- a/dev/mysql/8.0/stop.sh +++ b/dev/mysql/8.0/stop.sh @@ -3,6 +3,6 @@ set -Eeuxo pipefail # https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" # https://stackoverflow.com/a/17744637 -docker-compose -p sequelize-mysql-80 down --remove-orphans +docker compose -p sequelize-mysql-80 down --remove-orphans echo "Local MySQL-8.0 instance stopped (if it was running)." diff --git a/dev/oracle/18-slim/docker-compose.yml b/dev/oracle/18-slim/docker-compose.yml new file mode 100644 index 000000000000..1ba87e65e686 --- /dev/null +++ b/dev/oracle/18-slim/docker-compose.yml @@ -0,0 +1,17 @@ +# Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved + +services: + oraclexedb: + container_name: oraclexedb + image: gvenzl/oracle-xe:18-slim + environment: + ORACLE_PASSWORD: password + ports: + - 1521:1521 + healthcheck: + test: ["CMD-SHELL", "sqlplus", "system/password@XEPDB1"] + retries: 10 + +networks: + default: + name: sequelize-oraclexedb-network diff --git a/dev/oracle/18-slim/start.sh b/dev/oracle/18-slim/start.sh new file mode 100755 index 000000000000..aa0c719e1797 --- /dev/null +++ b/dev/oracle/18-slim/start.sh @@ -0,0 +1,61 @@ +# Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved + +#!/usr/bin/env bash +set -Eeuxo pipefail # https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/ +cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" # https://stackoverflow.com/a/17744637 + +# Remove an existing Oracle DB docker image +docker compose -p oraclexedb down --remove-orphans + +# Bring up new Oracle DB docker image +docker compose -p oraclexedb up -d + +# Wait until Oracle DB is set up and docker state is healthy +./../wait-until-healthy.sh oraclexedb + +# Moving privileges.sql to docker container +docker cp ../privileges.sql oraclexedb:/opt/oracle/. + +# Granting all the needed privileges to sequelizetest user +docker exec -t oraclexedb sqlplus system/password@XEPDB1 @privileges.sql + +SEQ_WORKSPACE="$PWD"/../../../ + +if [[ ! -d "$SEQ_WORKSPACE"/.oracle/ ]] +then + mkdir "$SEQ_WORKSPACE"/.oracle/ + if [[ $(uname) == 'Linux' ]] + then + wget https://download.oracle.com/otn_software/linux/instantclient/217000/instantclient-basic-linux.x64-21.7.0.0.0dbru.zip --no-check-certificate && + unzip instantclient-basic-linux.x64-21.7.0.0.0dbru.zip -d "$SEQ_WORKSPACE"/.oracle/ && + rm instantclient-basic-linux.x64-21.7.0.0.0dbru.zip && + mv "$SEQ_WORKSPACE"/.oracle/instantclient_21_7 "$SEQ_WORKSPACE"/.oracle/instantclient + + echo "Local Oracle instant client on Linux has been setup!" + elif [[ $(uname) == 'Darwin' ]] + then + if [[ ! -d ~/Downloads/instantclient_19_8 ]] + then + curl -O https://download.oracle.com/otn_software/mac/instantclient/198000/instantclient-basic-macos.x64-19.8.0.0.0dbru.dmg && + hdiutil mount instantclient-basic-macos.x64-19.8.0.0.0dbru.dmg && + /Volumes/instantclient-basic-macos.x64-19.8.0.0.0dbru/install_ic.sh && + hdiutil unmount /Volumes/instantclient-basic-macos.x64-19.8.0.0.0dbru && + rm instantclient-basic-macos.x64-19.8.0.0.0dbru.dmg && + mv ~/Downloads/instantclient_19_8/ "$SEQ_WORKSPACE"/.oracle/instantclient + else + cp -rf ~/Downloads/instantclient_19_8/ "$SEQ_WORKSPACE"/.oracle/instantclient + fi + ln -s "$SEQ_WORKSPACE"/.oracle/instantclient/libclntsh.dylib "$SEQ_WORKSPACE"/node_modules/oracledb/build/Release/ + + echo "Local Oracle instant client on macOS has been setup!" + else + # Windows + curl -O https://download.oracle.com/otn_software/nt/instantclient/216000/instantclient-basic-windows.x64-21.6.0.0.0dbru.zip && + unzip instantclient-basic-windows.x64-21.6.0.0.0dbru.zip -d "$SEQ_WORKSPACE"/.oracle/ && + rm instantclient-basic-windows.x64-21.6.0.0.0dbru.zip && + mv "$SEQ_WORKSPACE"/.oracle/instantclient_21_6/* "$SEQ_WORKSPACE"/node_modules/oracledb/build/Release + + echo "Local Oracle instant client on $(uname) has been setup!" + fi +fi +echo "Local Oracle DB is ready for use!" diff --git a/dev/oracle/18-slim/stop.sh b/dev/oracle/18-slim/stop.sh new file mode 100755 index 000000000000..d3ac45b9a0c4 --- /dev/null +++ b/dev/oracle/18-slim/stop.sh @@ -0,0 +1,10 @@ +# Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved + +#!/usr/bin/env bash +set -Eeuxo pipefail # https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/ +cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" # https://stackoverflow.com/a/17744637 + + +docker compose -p oraclexedb down --remove-orphans + +echo "Local Oracle DB instance stopped (if it was running)." diff --git a/dev/oracle/23-slim/docker-compose.yml b/dev/oracle/23-slim/docker-compose.yml new file mode 100644 index 000000000000..95d8c749ed2e --- /dev/null +++ b/dev/oracle/23-slim/docker-compose.yml @@ -0,0 +1,19 @@ +# Copyright (c) 2022, 2024 Oracle and/or its affiliates. All rights reserved + +services: + oraclexedb: + container_name: oraclexedb + image: gvenzl/oracle-free:23.4-slim + environment: + ORACLE_PASSWORD: password + ORACLE_DATABASE: XEPDB1 + + ports: + - 1521:1521 + healthcheck: + test: ["CMD-SHELL", "sqlplus", "system/password@localhost:1521/XEPDB1"] + retries: 10 + +networks: + default: + name: sequelize-oraclexedb-network diff --git a/dev/oracle/23-slim/start.sh b/dev/oracle/23-slim/start.sh new file mode 100755 index 000000000000..dd14eb1d476b --- /dev/null +++ b/dev/oracle/23-slim/start.sh @@ -0,0 +1,61 @@ +# Copyright (c) 2022, 2024 Oracle and/or its affiliates. All rights reserved + +#!/usr/bin/env bash +set -Eeuxo pipefail # https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/ +cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" # https://stackoverflow.com/a/17744637 + +# Remove an existing Oracle DB docker image +docker compose -p oraclexedb down --remove-orphans + +# Bring up new Oracle DB docker image +docker compose -p oraclexedb up -d + +# Wait until Oracle DB is set up and docker state is healthy +./../wait-until-healthy.sh oraclexedb + +# Moving privileges.sql to docker container +docker cp ../privileges.sql oraclexedb:/opt/oracle/. + +# Granting all the needed privileges to sequelizetest user +docker exec -t oraclexedb sqlplus system/password@localhost:1521/XEPDB1 @privileges.sql + +SEQ_WORKSPACE="$PWD"/../../../ + +if [[ ! -d "$SEQ_WORKSPACE"/.oracle/ ]] +then + mkdir "$SEQ_WORKSPACE"/.oracle/ + if [[ $(uname) == 'Linux' ]] + then + wget https://download.oracle.com/otn_software/linux/instantclient/217000/instantclient-basic-linux.x64-21.7.0.0.0dbru.zip --no-check-certificate && + unzip instantclient-basic-linux.x64-21.7.0.0.0dbru.zip -d "$SEQ_WORKSPACE"/.oracle/ && + rm instantclient-basic-linux.x64-21.7.0.0.0dbru.zip && + mv "$SEQ_WORKSPACE"/.oracle/instantclient_21_7 "$SEQ_WORKSPACE"/.oracle/instantclient + + echo "Local Oracle instant client on Linux has been setup!" + elif [[ $(uname) == 'Darwin' ]] + then + if [[ ! -d ~/Downloads/instantclient_19_8 ]] + then + curl -O https://download.oracle.com/otn_software/mac/instantclient/198000/instantclient-basic-macos.x64-19.8.0.0.0dbru.dmg && + hdiutil mount instantclient-basic-macos.x64-19.8.0.0.0dbru.dmg && + /Volumes/instantclient-basic-macos.x64-19.8.0.0.0dbru/install_ic.sh && + hdiutil unmount /Volumes/instantclient-basic-macos.x64-19.8.0.0.0dbru && + rm instantclient-basic-macos.x64-19.8.0.0.0dbru.dmg && + mv ~/Downloads/instantclient_19_8/ "$SEQ_WORKSPACE"/.oracle/instantclient + else + cp -rf ~/Downloads/instantclient_19_8/ "$SEQ_WORKSPACE"/.oracle/instantclient + fi + ln -s "$SEQ_WORKSPACE"/.oracle/instantclient/libclntsh.dylib "$SEQ_WORKSPACE"/node_modules/oracledb/build/Release/ + + echo "Local Oracle instant client on macOS has been setup!" + else + # Windows + curl -O https://download.oracle.com/otn_software/nt/instantclient/216000/instantclient-basic-windows.x64-21.6.0.0.0dbru.zip && + unzip instantclient-basic-windows.x64-21.6.0.0.0dbru.zip -d "$SEQ_WORKSPACE"/.oracle/ && + rm instantclient-basic-windows.x64-21.6.0.0.0dbru.zip && + mv "$SEQ_WORKSPACE"/.oracle/instantclient_21_6/* "$SEQ_WORKSPACE"/node_modules/oracledb/build/Release + + echo "Local Oracle instant client on $(uname) has been setup!" + fi +fi +echo "Local Oracle DB is ready for use!" diff --git a/dev/oracle/23-slim/stop.sh b/dev/oracle/23-slim/stop.sh new file mode 100755 index 000000000000..d3ac45b9a0c4 --- /dev/null +++ b/dev/oracle/23-slim/stop.sh @@ -0,0 +1,10 @@ +# Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved + +#!/usr/bin/env bash +set -Eeuxo pipefail # https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/ +cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" # https://stackoverflow.com/a/17744637 + + +docker compose -p oraclexedb down --remove-orphans + +echo "Local Oracle DB instance stopped (if it was running)." diff --git a/dev/oracle/privileges.sql b/dev/oracle/privileges.sql new file mode 100644 index 000000000000..afea910fdc49 --- /dev/null +++ b/dev/oracle/privileges.sql @@ -0,0 +1,27 @@ +-- Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved + +create user sequelizetest identified by sequelizepassword; +grant connect to sequelizetest with admin option; +grant create session to sequelizetest with admin option; +grant grant any privilege to sequelizetest with admin option; +grant grant any role to sequelizetest with admin option; +grant create any table to sequelizetest with admin option; +grant insert any table to sequelizetest with admin option; +grant select any table to sequelizetest with admin option; +grant update any table to sequelizetest with admin option; +grant delete any table to sequelizetest with admin option; +grant drop any table to sequelizetest with admin option; +grant create view to sequelizetest with admin option; +grant create user to sequelizetest with admin option; +grant drop user to sequelizetest with admin option; +grant create any trigger to sequelizetest with admin option; +grant create any procedure to sequelizetest with admin option; +grant create any sequence to sequelizetest with admin option; +grant select any sequence to sequelizetest with admin option; +grant drop any sequence to sequelizetest with admin option; +grant create any synonym to sequelizetest with admin option; +grant create any index to sequelizetest with admin option; +grant alter user to sequelizetest with admin option; +grant alter any table to sequelizetest with admin option; +alter user sequelizetest quota unlimited on users; +exit; diff --git a/dev/oracle/wait-until-healthy.sh b/dev/oracle/wait-until-healthy.sh new file mode 100755 index 000000000000..096242f82a05 --- /dev/null +++ b/dev/oracle/wait-until-healthy.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +if [ "$#" -ne 1 ]; then + >&2 echo "Please provide the container name or hash" + exit 1 +fi + +for _ in {1..50} +do + state=$(docker inspect -f '{{ .State.Health.Status }}' $1 2>&1) + return_code=$? + if [ ${return_code} -eq 0 ] && [ "$state" == "healthy" ]; then + echo "$1 is healthy!" + sleep 60 + exit 0 + fi + sleep 6 +done + +>&2 echo "Timeout of 5m exceeded when waiting for container to be healthy: $1" +exit 1 diff --git a/dev/postgres/10/start.sh b/dev/postgres/10/start.sh index 6a2ea51738e9..fe0dc41117f1 100755 --- a/dev/postgres/10/start.sh +++ b/dev/postgres/10/start.sh @@ -3,8 +3,8 @@ set -Eeuxo pipefail # https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" # https://stackoverflow.com/a/17744637 -docker-compose -p sequelize-postgres-10 down --remove-orphans -docker-compose -p sequelize-postgres-10 up -d +docker compose -p sequelize-postgres-10 down --remove-orphans +docker compose -p sequelize-postgres-10 up -d ./../../wait-until-healthy.sh sequelize-postgres-10 diff --git a/dev/postgres/10/stop.sh b/dev/postgres/10/stop.sh index 907d2074513b..53dd5c47fbf7 100755 --- a/dev/postgres/10/stop.sh +++ b/dev/postgres/10/stop.sh @@ -3,6 +3,6 @@ set -Eeuxo pipefail # https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" # https://stackoverflow.com/a/17744637 -docker-compose -p sequelize-postgres-10 down --remove-orphans +docker compose -p sequelize-postgres-10 down --remove-orphans echo "Local Postgres-10 instance stopped (if it was running)." diff --git a/docs.sh b/docs.sh new file mode 100644 index 000000000000..d34b3dc61a7f --- /dev/null +++ b/docs.sh @@ -0,0 +1,23 @@ +set -e + +rimraf esdoc + +exec 5>&1 +OUT=$(esdoc -c docs/esdoc-config.js|tee /dev/fd/5) + +cp docs/favicon.ico esdoc/favicon.ico +cp docs/ROUTER.txt esdoc/ROUTER + +node docs/run-docs-transforms.js +node docs/redirects/create-redirects.js + +rimraf esdoc/file esdoc/source.html + +set +e +GREP_RESULT=$(echo "$OUT" | grep -c 'could not parse the following code\|SyntaxError') +set -e + +if [ "$GREP_RESULT" -ge 1 ]; then + echo "esdoc generation encountered an error. See above logging for details." + exit 1 +fi diff --git a/docs/ROUTER.txt b/docs/ROUTER.txt index da1d58631241..b68706f2111e 100644 --- a/docs/ROUTER.txt +++ b/docs/ROUTER.txt @@ -10,18 +10,18 @@ 301 /en/latest/docs/getting-started/ https://sequelize.org/master/manual/getting-started.html 301 /en/latest/docs/:section/ https://sequelize.org/master/manual/:section.html -301 /en/latest/api/sequelize/ https://sequelize.org/master/class/lib/sequelize.js~Sequelize.html -301 /en/latest/api/model/ https://sequelize.org/master/class/lib/model.js~Model.html -301 /en/latest/api/instance/ https://sequelize.org/master/class/lib/model.js~Model.html -301 /en/latest/api/associations/ https://sequelize.org/master/class/lib/associations/base.js~Association.html -301 /en/latest/api/associations/belongs-to/ https://sequelize.org/master/class/lib/associations/belongs-to.js~BelongsTo.html -301 /en/latest/api/associations/belongs-to-many/ https://sequelize.org/master/class/lib/associations/belongs-to-.many.js~BelongsToMany.html -301 /en/latest/api/associations/has-one/ https://sequelize.org/master/class/lib/associations/has-one.js~HasOne.html -301 /en/latest/api/associations/has-many/ https://sequelize.org/master/class/lib/associations/has-many.js~HasMany.html -301 /en/latest/api/transaction/ https://sequelize.org/master/class/lib/transaction.js~Transaction.html +301 /en/latest/api/sequelize/ https://sequelize.org/master/class/src/sequelize.js~Sequelize.html +301 /en/latest/api/model/ https://sequelize.org/master/class/src/model.js~Model.html +301 /en/latest/api/instance/ https://sequelize.org/master/class/src/model.js~Model.html +301 /en/latest/api/associations/ https://sequelize.org/master/class/src/associations/base.js~Association.html +301 /en/latest/api/associations/belongs-to/ https://sequelize.org/master/class/src/associations/belongs-to.js~BelongsTo.html +301 /en/latest/api/associations/belongs-to-many/ https://sequelize.org/master/class/src/associations/belongs-to-.many.js~BelongsToMany.html +301 /en/latest/api/associations/has-one/ https://sequelize.org/master/class/src/associations/has-one.js~HasOne.html +301 /en/latest/api/associations/has-many/ https://sequelize.org/master/class/src/associations/has-many.js~HasMany.html +301 /en/latest/api/transaction/ https://sequelize.org/master/class/src/transaction.js~Transaction.html 301 /en/latest/api/datatypes/ https://sequelize.org/master/variable/index.html#static-variable-DataTypes 301 /en/latest/api/deferrable/ https://sequelize.org/master/variable/index.html#static-variable-Deferrable -301 /en/latest/api/errors/ https://sequelize.org/master/class/lib/errors/base-error.js~BaseError.html +301 /en/latest/api/errors/ https://sequelize.org/master/class/src/errors/base-error.js~BaseError.html 301 /manual/tutorial/:section.html https://sequelize.org/master/manual/:section.html 301 /manual/installation/:section.html https://sequelize.org/master/manual/:section.html @@ -33,4 +33,4 @@ 301 /:foo/:bar/:baz https://sequelize.org/master/:foo/:bar/:baz 301 /:foo/:bar/:baz/:quz https://sequelize.org/master/:foo/:bar/:baz/:quz -301 / https://sequelize.org/ \ No newline at end of file +301 / https://sequelize.org/ diff --git a/docs/css/style.css b/docs/css/style.css index 5e3c8b469438..4c931cc131f2 100644 --- a/docs/css/style.css +++ b/docs/css/style.css @@ -181,6 +181,6 @@ header a { } a[href="source.html"], -a[href^="file/lib/"] { +a[href^="file/src/"] { display: none; } diff --git a/docs/esdoc-config.js b/docs/esdoc-config.js index 36b3a867ccc0..e43d76c09eab 100644 --- a/docs/esdoc-config.js +++ b/docs/esdoc-config.js @@ -1,13 +1,11 @@ 'use strict'; -const { getDeclaredManuals, checkManuals } = require('./manual-utils'); - -checkManuals(); - module.exports = { - source: './lib', + index: `${__dirname}/index.md`, + source: './src', destination: './esdoc', includes: ['\\.[tj]s$'], + excludes: ['\\.d.ts$'], plugins: [ { name: 'esdoc-ecmascript-proposal-plugin', @@ -45,10 +43,8 @@ module.exports = { site: 'https://sequelize.org/master/' }, manual: { - index: './docs/index.md', - globalIndex: true, asset: './docs/images', - files: getDeclaredManuals() + files: [] } } }, diff --git a/docs/images/bitovi-logo.png b/docs/images/bitovi-logo.png deleted file mode 100644 index a0bfca78f930..000000000000 Binary files a/docs/images/bitovi-logo.png and /dev/null differ diff --git a/docs/images/clevertech.png b/docs/images/clevertech.png deleted file mode 100644 index 70bb50fc6ca2..000000000000 Binary files a/docs/images/clevertech.png and /dev/null differ diff --git a/docs/images/connected-cars.png b/docs/images/connected-cars.png deleted file mode 100644 index 807e7fa91b3d..000000000000 Binary files a/docs/images/connected-cars.png and /dev/null differ diff --git a/docs/images/ermeshotels-logo.png b/docs/images/ermeshotels-logo.png deleted file mode 100644 index a1153b476d93..000000000000 Binary files a/docs/images/ermeshotels-logo.png and /dev/null differ diff --git a/docs/images/filsh.png b/docs/images/filsh.png deleted file mode 100644 index 9fa27f81a9a9..000000000000 Binary files a/docs/images/filsh.png and /dev/null differ diff --git a/docs/images/logo-snaplytics-green.png b/docs/images/logo-snaplytics-green.png deleted file mode 100644 index c87113dc4887..000000000000 Binary files a/docs/images/logo-snaplytics-green.png and /dev/null differ diff --git a/docs/images/logo.png b/docs/images/logo.png deleted file mode 100644 index 3317765b1a4f..000000000000 Binary files a/docs/images/logo.png and /dev/null differ diff --git a/docs/images/metamarkets.png b/docs/images/metamarkets.png deleted file mode 100644 index 62180838027a..000000000000 Binary files a/docs/images/metamarkets.png and /dev/null differ diff --git a/docs/images/shutterstock.png b/docs/images/shutterstock.png deleted file mode 100644 index a89b014f2c8e..000000000000 Binary files a/docs/images/shutterstock.png and /dev/null differ diff --git a/docs/images/slack.svg b/docs/images/slack.svg deleted file mode 100644 index c37dc5eb49e3..000000000000 --- a/docs/images/slack.svg +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/docs/images/walmart-labs-logo.png b/docs/images/walmart-labs-logo.png deleted file mode 100644 index f463966c4efa..000000000000 Binary files a/docs/images/walmart-labs-logo.png and /dev/null differ diff --git a/docs/index.md b/docs/index.md index 7d8ebf948bfa..1ff71d06b0ae 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,52 +1,3 @@ - +# Sequelize 6 API Reference -[![npm version](https://badgen.net/npm/v/sequelize)](https://www.npmjs.com/package/sequelize) -[![Build Status](https://github.com/sequelize/sequelize/workflows/CI/badge.svg)](https://github.com/sequelize/sequelize/actions?query=workflow%3ACI) -[![npm downloads](https://badgen.net/npm/dm/sequelize)](https://www.npmjs.com/package/sequelize) -[![sponsor](https://img.shields.io/opencollective/all/sequelize?label=sponsors)](https://opencollective.com/sequelize) -[![Last commit](https://badgen.net/github/last-commit/sequelize/sequelize)](https://github.com/sequelize/sequelize) -[![Merged PRs](https://badgen.net/github/merged-prs/sequelize/sequelize)](https://github.com/sequelize/sequelize) -[![GitHub stars](https://badgen.net/github/stars/sequelize/sequelize)](https://github.com/sequelize/sequelize) -[![Slack Status](http://sequelize-slack.herokuapp.com/badge.svg)](http://sequelize-slack.herokuapp.com/) -[![node](https://badgen.net/npm/node/sequelize)](https://www.npmjs.com/package/sequelize) -[![License](https://badgen.net/github/license/sequelize/sequelize)](https://github.com/sequelize/sequelize/blob/main/LICENSE) -[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) - -Sequelize is a promise-based [Node.js](https://nodejs.org/en/about/) [ORM tool](https://en.wikipedia.org/wiki/Object-relational_mapping) for [Postgres](https://en.wikipedia.org/wiki/PostgreSQL), [MySQL](https://en.wikipedia.org/wiki/MySQL), [MariaDB](https://en.wikipedia.org/wiki/MariaDB), [SQLite](https://en.wikipedia.org/wiki/SQLite), [Microsoft SQL Server](https://en.wikipedia.org/wiki/Microsoft_SQL_Server), [Amazon Redshift](https://docs.aws.amazon.com/redshift/index.html) and [Snowflake’s Data Cloud](https://docs.snowflake.com/en/user-guide/intro-key-concepts.html). It features solid transaction support, relations, eager and lazy loading, read replication and more. - -Sequelize follows [Semantic Versioning](http://semver.org) and supports Node v10 and above. - -You are currently looking at the **Tutorials and Guides** for Sequelize. You might also be interested in the [API Reference](identifiers.html). - -## Quick example - -```js -const { Sequelize, Model, DataTypes } = require('sequelize'); -const sequelize = new Sequelize('sqlite::memory:'); - -class User extends Model {} -User.init({ - username: DataTypes.STRING, - birthday: DataTypes.DATE -}, { sequelize, modelName: 'user' }); - -(async () => { - await sequelize.sync(); - const jane = await User.create({ - username: 'janedoe', - birthday: new Date(1980, 6, 20) - }); - console.log(jane.toJSON()); -})(); -``` - -To learn more about how to use Sequelize, read the tutorials available in the left menu. Begin with [Getting Started](manual/getting-started.html). - -## Supporting the project - -Do you like Sequelize and would like to give back to the engineering team behind it? - -We have recently created an [OpenCollective based money pool](https://opencollective.com/sequelize) which is shared amongst all core maintainers based on their contributions. Every support is wholeheartedly welcome. ❤️ +Click on an entry in the sidebar to open its API Reference. diff --git a/docs/manual-utils.js b/docs/manual-utils.js deleted file mode 100644 index a09ce52d216a..000000000000 --- a/docs/manual-utils.js +++ /dev/null @@ -1,37 +0,0 @@ -'use strict'; - -const _ = require('lodash'); -const jetpack = require('fs-jetpack'); -const { normalize } = require('path'); -const assert = require('assert'); - -function getDeclaredManuals() { - const declaredManualGroups = require('./manual-groups.json'); - return _.flatten(Object.values(declaredManualGroups)).map(file => { - return normalize(`./docs/manual/${file}`); - }); -} - -function getAllManuals() { - return jetpack.find('./docs/manual/', { matching: '*.md' }).map(m => { - return normalize(`./${m}`); - }); -} - -function checkManuals() { - // First we check that declared manuals and all manuals are the same - const declared = getDeclaredManuals().sort(); - const all = getAllManuals().sort(); - assert.deepStrictEqual(declared, all); - - // Then we check that every manual begins with a single `#`. This is - // important for ESDoc to render the left menu correctly. - for (const manualRelativePath of all) { - assert( - /^#[^#]/.test(jetpack.read(manualRelativePath)), - `Manual '${manualRelativePath}' must begin with a single '#'` - ); - } -} - -module.exports = { getDeclaredManuals, getAllManuals, checkManuals }; diff --git a/docs/manual/advanced-association-concepts/advanced-many-to-many.md b/docs/manual/advanced-association-concepts/advanced-many-to-many.md deleted file mode 100644 index 371f66201f8c..000000000000 --- a/docs/manual/advanced-association-concepts/advanced-many-to-many.md +++ /dev/null @@ -1,667 +0,0 @@ -# Advanced M:N Associations - -Make sure you have read the [associations guide](assocs.html) before reading this guide. - -Let's start with an example of a Many-to-Many relationship between `User` and `Profile`. - -```js -const User = sequelize.define('user', { - username: DataTypes.STRING, - points: DataTypes.INTEGER -}, { timestamps: false }); -const Profile = sequelize.define('profile', { - name: DataTypes.STRING -}, { timestamps: false }); -``` - -The simplest way to define the Many-to-Many relationship is: - -```js -User.belongsToMany(Profile, { through: 'User_Profiles' }); -Profile.belongsToMany(User, { through: 'User_Profiles' }); -``` - -By passing a string to `through` above, we are asking Sequelize to automatically generate a model named `User_Profiles` as the *through table* (also known as junction table), with only two columns: `userId` and `profileId`. A composite unique key will be established on these two columns. - -We can also define ourselves a model to be used as the through table. - -```js -const User_Profile = sequelize.define('User_Profile', {}, { timestamps: false }); -User.belongsToMany(Profile, { through: User_Profile }); -Profile.belongsToMany(User, { through: User_Profile }); -``` - -The above has the exact same effect. Note that we didn't define any attributes on the `User_Profile` model. The fact that we passed it into a `belongsToMany` call tells sequelize to create the two attributes `userId` and `profileId` automatically, just like other associations also cause Sequelize to automatically add a column to one of the involved models. - -However, defining the model by ourselves has several advantages. We can, for example, define more columns on our through table: - -```js -const User_Profile = sequelize.define('User_Profile', { - selfGranted: DataTypes.BOOLEAN -}, { timestamps: false }); -User.belongsToMany(Profile, { through: User_Profile }); -Profile.belongsToMany(User, { through: User_Profile }); -``` - -With this, we can now track an extra information at the through table, namely the `selfGranted` boolean. For example, when calling the `user.addProfile()` we can pass values for the extra columns using the `through` option. - -Example: - -```js -const amidala = await User.create({ username: 'p4dm3', points: 1000 }); -const queen = await Profile.create({ name: 'Queen' }); -await amidala.addProfile(queen, { through: { selfGranted: false } }); -const result = await User.findOne({ - where: { username: 'p4dm3' }, - include: Profile -}); -console.log(result); -``` - -Output: - -```json -{ - "id": 4, - "username": "p4dm3", - "points": 1000, - "profiles": [ - { - "id": 6, - "name": "queen", - "User_Profile": { - "userId": 4, - "profileId": 6, - "selfGranted": false - } - } - ] -} -``` - -You can create all relationship in single `create` call too. - -Example: - -```js -const amidala = await User.create({ - username: 'p4dm3', - points: 1000, - profiles: [{ - name: 'Queen', - User_Profile: { - selfGranted: true - } - }] -}, { - include: Profile -}); - -const result = await User.findOne({ - where: { username: 'p4dm3' }, - include: Profile -}); - -console.log(result); -``` - -Output: - -```json -{ - "id": 1, - "username": "p4dm3", - "points": 1000, - "profiles": [ - { - "id": 1, - "name": "Queen", - "User_Profile": { - "selfGranted": true, - "userId": 1, - "profileId": 1 - } - } - ] -} -``` - -You probably noticed that the `User_Profiles` table does not have an `id` field. As mentioned above, it has a composite unique key instead. The name of this composite unique key is chosen automatically by Sequelize but can be customized with the `uniqueKey` option: - -```js -User.belongsToMany(Profile, { through: User_Profiles, uniqueKey: 'my_custom_unique' }); -``` - -Another possibility, if desired, is to force the through table to have a primary key just like other standard tables. To do this, simply define the primary key in the model: - -```js -const User_Profile = sequelize.define('User_Profile', { - id: { - type: DataTypes.INTEGER, - primaryKey: true, - autoIncrement: true, - allowNull: false - }, - selfGranted: DataTypes.BOOLEAN -}, { timestamps: false }); -User.belongsToMany(Profile, { through: User_Profile }); -Profile.belongsToMany(User, { through: User_Profile }); -``` - -The above will still create two columns `userId` and `profileId`, of course, but instead of setting up a composite unique key on them, the model will use its `id` column as primary key. Everything else will still work just fine. - -## Through tables versus normal tables and the "Super Many-to-Many association" - -Now we will compare the usage of the last Many-to-Many setup shown above with the usual One-to-Many relationships, so that in the end we conclude with the concept of a *"Super Many-to-Many relationship"*. - -### Models recap (with minor rename) - -To make things easier to follow, let's rename our `User_Profile` model to `grant`. Note that everything works in the same way as before. Our models are: - -```js -const User = sequelize.define('user', { - username: DataTypes.STRING, - points: DataTypes.INTEGER -}, { timestamps: false }); - -const Profile = sequelize.define('profile', { - name: DataTypes.STRING -}, { timestamps: false }); - -const Grant = sequelize.define('grant', { - id: { - type: DataTypes.INTEGER, - primaryKey: true, - autoIncrement: true, - allowNull: false - }, - selfGranted: DataTypes.BOOLEAN -}, { timestamps: false }); -``` - -We established a Many-to-Many relationship between `User` and `Profile` using the `Grant` model as the through table: - -```js -User.belongsToMany(Profile, { through: Grant }); -Profile.belongsToMany(User, { through: Grant }); -``` - -This automatically added the columns `userId` and `profileId` to the `Grant` model. - -**Note:** As shown above, we have chosen to force the `grant` model to have a single primary key (called `id`, as usual). This is necessary for the *Super Many-to-Many relationship* that will be defined soon. - -### Using One-to-Many relationships instead - -Instead of setting up the Many-to-Many relationship defined above, what if we did the following instead? - -```js -// Setup a One-to-Many relationship between User and Grant -User.hasMany(Grant); -Grant.belongsTo(User); - -// Also setup a One-to-Many relationship between Profile and Grant -Profile.hasMany(Grant); -Grant.belongsTo(Profile); -``` - -The result is essentially the same! This is because `User.hasMany(Grant)` and `Profile.hasMany(Grant)` will automatically add the `userId` and `profileId` columns to `Grant`, respectively. - -This shows that one Many-to-Many relationship isn't very different from two One-to-Many relationships. The tables in the database look the same. - -The only difference is when you try to perform an eager load with Sequelize. - -```js -// With the Many-to-Many approach, you can do: -User.findAll({ include: Profile }); -Profile.findAll({ include: User }); -// However, you can't do: -User.findAll({ include: Grant }); -Profile.findAll({ include: Grant }); -Grant.findAll({ include: User }); -Grant.findAll({ include: Profile }); - -// On the other hand, with the double One-to-Many approach, you can do: -User.findAll({ include: Grant }); -Profile.findAll({ include: Grant }); -Grant.findAll({ include: User }); -Grant.findAll({ include: Profile }); -// However, you can't do: -User.findAll({ include: Profile }); -Profile.findAll({ include: User }); -// Although you can emulate those with nested includes, as follows: -User.findAll({ - include: { - model: Grant, - include: Profile - } -}); // This emulates the `User.findAll({ include: Profile })`, however - // the resulting object structure is a bit different. The original - // structure has the form `user.profiles[].grant`, while the emulated - // structure has the form `user.grants[].profiles[]`. -``` - -### The best of both worlds: the Super Many-to-Many relationship - -We can simply combine both approaches shown above! - -```js -// The Super Many-to-Many relationship -User.belongsToMany(Profile, { through: Grant }); -Profile.belongsToMany(User, { through: Grant }); -User.hasMany(Grant); -Grant.belongsTo(User); -Profile.hasMany(Grant); -Grant.belongsTo(Profile); -``` - -This way, we can do all kinds of eager loading: - -```js -// All these work: -User.findAll({ include: Profile }); -Profile.findAll({ include: User }); -User.findAll({ include: Grant }); -Profile.findAll({ include: Grant }); -Grant.findAll({ include: User }); -Grant.findAll({ include: Profile }); -``` - -We can even perform all kinds of deeply nested includes: - -```js -User.findAll({ - include: [ - { - model: Grant, - include: [User, Profile] - }, - { - model: Profile, - include: { - model: User, - include: { - model: Grant, - include: [User, Profile] - } - } - } - ] -}); -``` - -## Aliases and custom key names - -Similarly to the other relationships, aliases can be defined for Many-to-Many relationships. - -Before proceeding, please recall [the aliasing example for `belongsTo`](assocs.html#defining-an-alias) on the [associations guide](assocs.html). Note that, in that case, defining an association impacts both the way includes are done (i.e. passing the association name) and the name Sequelize chooses for the foreign key (in that example, `leaderId` was created on the `Ship` model). - -Defining an alias for a `belongsToMany` association also impacts the way includes are performed: - -```js -Product.belongsToMany(Category, { as: 'groups', through: 'product_categories' }); -Category.belongsToMany(Product, { as: 'items', through: 'product_categories' }); - -// [...] - -await Product.findAll({ include: Category }); // This doesn't work - -await Product.findAll({ // This works, passing the alias - include: { - model: Category, - as: 'groups' - } -}); - -await Product.findAll({ include: 'groups' }); // This also works -``` - -However, defining an alias here has nothing to do with the foreign key names. The names of both foreign keys created in the through table are still constructed by Sequelize based on the name of the models being associated. This can readily be seen by inspecting the generated SQL for the through table in the example above: - -```sql -CREATE TABLE IF NOT EXISTS `product_categories` ( - `createdAt` DATETIME NOT NULL, - `updatedAt` DATETIME NOT NULL, - `productId` INTEGER NOT NULL REFERENCES `products` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - `categoryId` INTEGER NOT NULL REFERENCES `categories` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - PRIMARY KEY (`productId`, `categoryId`) -); -``` - -We can see that the foreign keys are `productId` and `categoryId`. To change these names, Sequelize accepts the options `foreignKey` and `otherKey` respectively (i.e., the `foreignKey` defines the key for the source model in the through relation, and `otherKey` defines it for the target model): - -```js -Product.belongsToMany(Category, { - through: 'product_categories', - foreignKey: 'objectId', // replaces `productId` - otherKey: 'typeId' // replaces `categoryId` -}); -Category.belongsToMany(Product, { - through: 'product_categories', - foreignKey: 'typeId', // replaces `categoryId` - otherKey: 'objectId' // replaces `productId` -}); -``` - -Generated SQL: - -```sql -CREATE TABLE IF NOT EXISTS `product_categories` ( - `createdAt` DATETIME NOT NULL, - `updatedAt` DATETIME NOT NULL, - `objectId` INTEGER NOT NULL REFERENCES `products` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - `typeId` INTEGER NOT NULL REFERENCES `categories` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, - PRIMARY KEY (`objectId`, `typeId`) -); -``` - -As shown above, when you define a Many-to-Many relationship with two `belongsToMany` calls (which is the standard way), you should provide the `foreignKey` and `otherKey` options appropriately in both calls. If you pass these options in only one of the calls, the Sequelize behavior will be unreliable. - -## Self-references - -Sequelize supports self-referential Many-to-Many relationships, intuitively: - -```js -Person.belongsToMany(Person, { as: 'Children', through: 'PersonChildren' }) -// This will create the table PersonChildren which stores the ids of the objects. -``` - -## Specifying attributes from the through table - -By default, when eager loading a many-to-many relationship, Sequelize will return data in the following structure (based on the first example in this guide): - -```json -// User.findOne({ include: Profile }) -{ - "id": 4, - "username": "p4dm3", - "points": 1000, - "profiles": [ - { - "id": 6, - "name": "queen", - "grant": { - "userId": 4, - "profileId": 6, - "selfGranted": false - } - } - ] -} -``` - -Notice that the outer object is an `User`, which has a field called `profiles`, which is a `Profile` array, such that each `Profile` comes with an extra field called `grant` which is a `Grant` instance. This is the default structure created by Sequelize when eager loading from a Many-to-Many relationship. - -However, if you want only some of the attributes of the through table, you can provide an array with the attributes you want in the `attributes` option. For example, if you only want the `selfGranted` attribute from the through table: - -```js -User.findOne({ - include: { - model: Profile, - through: { - attributes: ['selfGranted'] - } - } -}); -``` - -Output: - -```json -{ - "id": 4, - "username": "p4dm3", - "points": 1000, - "profiles": [ - { - "id": 6, - "name": "queen", - "grant": { - "selfGranted": false - } - } - ] -} -``` - -If you don't want the nested `grant` field at all, use `attributes: []`: - -```js -User.findOne({ - include: { - model: Profile, - through: { - attributes: [] - } - } -}); -``` - -Output: - -```json -{ - "id": 4, - "username": "p4dm3", - "points": 1000, - "profiles": [ - { - "id": 6, - "name": "queen" - } - ] -} -``` - -If you are using mixins (such as `user.getProfiles()`) instead of finder methods (such as `User.findAll()`), you have to use the `joinTableAttributes` option instead: - -```js -someUser.getProfiles({ joinTableAttributes: ['selfGranted'] }); -``` - -Output: - -```json -[ - { - "id": 6, - "name": "queen", - "grant": { - "selfGranted": false - } - } -] -``` - -## Many-to-many-to-many relationships and beyond - -Consider you are trying to model a game championship. There are players and teams. Teams play games. However, players can change teams in the middle of the championship (but not in the middle of a game). So, given one specific game, there are certain teams participating in that game, and each of these teams has a set of players (for that game). - -So we start by defining the three relevant models: - -```js -const Player = sequelize.define('Player', { username: DataTypes.STRING }); -const Team = sequelize.define('Team', { name: DataTypes.STRING }); -const Game = sequelize.define('Game', { name: DataTypes.INTEGER }); -``` - -Now, the question is: how to associate them? - -First, we note that: - -* One game has many teams associated to it (the ones that are playing that game); -* One team may have participated in many games. - -The above observations show that we need a Many-to-Many relationship between Game and Team. Let's use the Super Many-to-Many relationship as explained earlier in this guide: - -```js -// Super Many-to-Many relationship between Game and Team -const GameTeam = sequelize.define('GameTeam', { - id: { - type: DataTypes.INTEGER, - primaryKey: true, - autoIncrement: true, - allowNull: false - } -}); -Team.belongsToMany(Game, { through: GameTeam }); -Game.belongsToMany(Team, { through: GameTeam }); -GameTeam.belongsTo(Game); -GameTeam.belongsTo(Team); -Game.hasMany(GameTeam); -Team.hasMany(GameTeam); -``` - -The part about players is trickier. We note that the set of players that form a team depends not only on the team (obviously), but also on which game is being considered. Therefore, we don't want a Many-to-Many relationship between Player and Team. We also don't want a Many-to-Many relationship between Player and Game. Instead of associating a Player to any of those models, what we need is an association between a Player and something like a *"team-game pair constraint"*, since it is the pair (team plus game) that defines which players belong there. So what we are looking for turns out to be precisely the junction model, GameTeam, itself! And, we note that, since a given *game-team pair* specifies many players, and on the other hand that the same player can participate of many *game-team pairs*, we need a Many-to-Many relationship between Player and GameTeam! - -To provide the greatest flexibility, let's use the Super Many-to-Many relationship construction here again: - -```js -// Super Many-to-Many relationship between Player and GameTeam -const PlayerGameTeam = sequelize.define('PlayerGameTeam', { - id: { - type: DataTypes.INTEGER, - primaryKey: true, - autoIncrement: true, - allowNull: false - } -}); -Player.belongsToMany(GameTeam, { through: PlayerGameTeam }); -GameTeam.belongsToMany(Player, { through: PlayerGameTeam }); -PlayerGameTeam.belongsTo(Player); -PlayerGameTeam.belongsTo(GameTeam); -Player.hasMany(PlayerGameTeam); -GameTeam.hasMany(PlayerGameTeam); -``` - -The above associations achieve precisely what we want. Here is a full runnable example of this: - -```js -const { Sequelize, Op, Model, DataTypes } = require('sequelize'); -const sequelize = new Sequelize('sqlite::memory:', { - define: { timestamps: false } // Just for less clutter in this example -}); -const Player = sequelize.define('Player', { username: DataTypes.STRING }); -const Team = sequelize.define('Team', { name: DataTypes.STRING }); -const Game = sequelize.define('Game', { name: DataTypes.INTEGER }); - -// We apply a Super Many-to-Many relationship between Game and Team -const GameTeam = sequelize.define('GameTeam', { - id: { - type: DataTypes.INTEGER, - primaryKey: true, - autoIncrement: true, - allowNull: false - } -}); -Team.belongsToMany(Game, { through: GameTeam }); -Game.belongsToMany(Team, { through: GameTeam }); -GameTeam.belongsTo(Game); -GameTeam.belongsTo(Team); -Game.hasMany(GameTeam); -Team.hasMany(GameTeam); - -// We apply a Super Many-to-Many relationship between Player and GameTeam -const PlayerGameTeam = sequelize.define('PlayerGameTeam', { - id: { - type: DataTypes.INTEGER, - primaryKey: true, - autoIncrement: true, - allowNull: false - } -}); -Player.belongsToMany(GameTeam, { through: PlayerGameTeam }); -GameTeam.belongsToMany(Player, { through: PlayerGameTeam }); -PlayerGameTeam.belongsTo(Player); -PlayerGameTeam.belongsTo(GameTeam); -Player.hasMany(PlayerGameTeam); -GameTeam.hasMany(PlayerGameTeam); - -(async () => { - - await sequelize.sync(); - await Player.bulkCreate([ - { username: 's0me0ne' }, - { username: 'empty' }, - { username: 'greenhead' }, - { username: 'not_spock' }, - { username: 'bowl_of_petunias' } - ]); - await Game.bulkCreate([ - { name: 'The Big Clash' }, - { name: 'Winter Showdown' }, - { name: 'Summer Beatdown' } - ]); - await Team.bulkCreate([ - { name: 'The Martians' }, - { name: 'The Earthlings' }, - { name: 'The Plutonians' } - ]); - - // Let's start defining which teams were in which games. This can be done - // in several ways, such as calling `.setTeams` on each game. However, for - // brevity, we will use direct `create` calls instead, referring directly - // to the IDs we want. We know that IDs are given in order starting from 1. - await GameTeam.bulkCreate([ - { GameId: 1, TeamId: 1 }, // this GameTeam will get id 1 - { GameId: 1, TeamId: 2 }, // this GameTeam will get id 2 - { GameId: 2, TeamId: 1 }, // this GameTeam will get id 3 - { GameId: 2, TeamId: 3 }, // this GameTeam will get id 4 - { GameId: 3, TeamId: 2 }, // this GameTeam will get id 5 - { GameId: 3, TeamId: 3 } // this GameTeam will get id 6 - ]); - - // Now let's specify players. - // For brevity, let's do it only for the second game (Winter Showdown). - // Let's say that that s0me0ne and greenhead played for The Martians, while - // not_spock and bowl_of_petunias played for The Plutonians: - await PlayerGameTeam.bulkCreate([ - // In 'Winter Showdown' (i.e. GameTeamIds 3 and 4): - { PlayerId: 1, GameTeamId: 3 }, // s0me0ne played for The Martians - { PlayerId: 3, GameTeamId: 3 }, // greenhead played for The Martians - { PlayerId: 4, GameTeamId: 4 }, // not_spock played for The Plutonians - { PlayerId: 5, GameTeamId: 4 } // bowl_of_petunias played for The Plutonians - ]); - - // Now we can make queries! - const game = await Game.findOne({ - where: { - name: "Winter Showdown" - }, - include: { - model: GameTeam, - include: [ - { - model: Player, - through: { attributes: [] } // Hide unwanted `PlayerGameTeam` nested object from results - }, - Team - ] - } - }); - - console.log(`Found game: "${game.name}"`); - for (let i = 0; i < game.GameTeams.length; i++) { - const team = game.GameTeams[i].Team; - const players = game.GameTeams[i].Players; - console.log(`- Team "${team.name}" played game "${game.name}" with the following players:`); - console.log(players.map(p => `--- ${p.username}`).join('\n')); - } - -})(); -``` - -Output: - -```text -Found game: "Winter Showdown" -- Team "The Martians" played game "Winter Showdown" with the following players: ---- s0me0ne ---- greenhead -- Team "The Plutonians" played game "Winter Showdown" with the following players: ---- not_spock ---- bowl_of_petunias -``` - -So this is how we can achieve a *many-to-many-to-many* relationship between three models in Sequelize, by taking advantage of the Super Many-to-Many relationship technique! - -This idea can be applied recursively for even more complex, *many-to-many-to-...-to-many* relationships (although at some point queries might become slow). diff --git a/docs/manual/advanced-association-concepts/association-scopes.md b/docs/manual/advanced-association-concepts/association-scopes.md deleted file mode 100644 index 42224f5e0cf6..000000000000 --- a/docs/manual/advanced-association-concepts/association-scopes.md +++ /dev/null @@ -1,64 +0,0 @@ -# Association Scopes - -This section concerns association scopes, which are similar but not the same as [model scopes](scopes.html). - -Association scopes can be placed both on the associated model (the target of the association) and on the through table for Many-to-Many relationships. - -## Concept - -Similarly to how a [model scope](scopes.html) is automatically applied on the model static calls, such as `Model.scope('foo').findAll()`, an association scope is a rule (more precisely, a set of default attributes and options) that is automatically applied on instance calls from the model. Here, *instance calls* mean method calls that are called from an instance (rather than from the Model itself). Mixins are the main example of instance methods (`instance.getSomething`, `instance.setSomething`, `instance.addSomething` and `instance.createSomething`). - -Association scopes behave just like model scopes, in the sense that both cause an automatic application of things like `where` clauses to finder calls; the difference being that instead of applying to static finder calls (which is the case for model scopes), the association scopes automatically apply to instance finder calls (such as mixins). - -## Example - -A basic example of an association scope for the One-to-Many association between models `Foo` and `Bar` is shown below. - -* Setup: - - ```js - const Foo = sequelize.define('foo', { name: DataTypes.STRING }); - const Bar = sequelize.define('bar', { status: DataTypes.STRING }); - Foo.hasMany(Bar, { - scope: { - status: 'open' - }, - as: 'openBars' - }); - await sequelize.sync(); - const myFoo = await Foo.create({ name: "My Foo" }); - ``` - -* After this setup, calling `myFoo.getOpenBars()` generates the following SQL: - - ```sql - SELECT - `id`, `status`, `createdAt`, `updatedAt`, `fooId` - FROM `bars` AS `bar` - WHERE `bar`.`status` = 'open' AND `bar`.`fooId` = 1; - ``` - -With this we can see that upon calling the `.getOpenBars()` mixin, the association scope `{ status: 'open' }` was automatically applied into the `WHERE` clause of the generated SQL. - -## Achieving the same behavior with standard scopes - -We could have achieved the same behavior with standard scopes: - -```js -// Foo.hasMany(Bar, { -// scope: { -// status: 'open' -// }, -// as: 'openBars' -// }); - -Bar.addScope('open', { - where: { - status: 'open' - } -}); -Foo.hasMany(Bar); -Foo.hasMany(Bar.scope('open'), { as: 'openBars' }); -``` - -With the above code, `myFoo.getOpenBars()` yields the same SQL shown above. \ No newline at end of file diff --git a/docs/manual/advanced-association-concepts/creating-with-associations.md b/docs/manual/advanced-association-concepts/creating-with-associations.md deleted file mode 100644 index 60f5e80ea71d..000000000000 --- a/docs/manual/advanced-association-concepts/creating-with-associations.md +++ /dev/null @@ -1,130 +0,0 @@ -# Creating with Associations - -An instance can be created with nested association in one step, provided all elements are new. - -In contrast, performing updates and deletions involving nested objects is currently not possible. For that, you will have to perform each separate action explicitly. - -## BelongsTo / HasMany / HasOne association - -Consider the following models: - -```js -class Product extends Model {} -Product.init({ - title: Sequelize.STRING -}, { sequelize, modelName: 'product' }); -class User extends Model {} -User.init({ - firstName: Sequelize.STRING, - lastName: Sequelize.STRING -}, { sequelize, modelName: 'user' }); -class Address extends Model {} -Address.init({ - type: DataTypes.STRING, - line1: Sequelize.STRING, - line2: Sequelize.STRING, - city: Sequelize.STRING, - state: Sequelize.STRING, - zip: Sequelize.STRING, -}, { sequelize, modelName: 'address' }); - -// We save the return values of the association setup calls to use them later -Product.User = Product.belongsTo(User); -User.Addresses = User.hasMany(Address); -// Also works for `hasOne` -``` - -A new `Product`, `User`, and one or more `Address` can be created in one step in the following way: - -```js -return Product.create({ - title: 'Chair', - user: { - firstName: 'Mick', - lastName: 'Broadstone', - addresses: [{ - type: 'home', - line1: '100 Main St.', - city: 'Austin', - state: 'TX', - zip: '78704' - }] - } -}, { - include: [{ - association: Product.User, - include: [ User.Addresses ] - }] -}); -``` - -Observe the usage of the `include` option in the `Product.create` call. That is necessary for Sequelize to understand what you are trying to create along with the association. - -Note: here, our user model is called `user`, with a lowercase `u` - This means that the property in the object should also be `user`. If the name given to `sequelize.define` was `User`, the key in the object should also be `User`. Likewise for `addresses`, except it's pluralized being a `hasMany` association. - -## BelongsTo association with an alias - -The previous example can be extended to support an association alias. - -```js -const Creator = Product.belongsTo(User, { as: 'creator' }); - -return Product.create({ - title: 'Chair', - creator: { - firstName: 'Matt', - lastName: 'Hansen' - } -}, { - include: [ Creator ] -}); -``` - -## HasMany / BelongsToMany association - -Let's introduce the ability to associate a product with many tags. Setting up the models could look like: - -```js -class Tag extends Model {} -Tag.init({ - name: Sequelize.STRING -}, { sequelize, modelName: 'tag' }); - -Product.hasMany(Tag); -// Also works for `belongsToMany`. -``` - -Now we can create a product with multiple tags in the following way: - -```js -Product.create({ - id: 1, - title: 'Chair', - tags: [ - { name: 'Alpha'}, - { name: 'Beta'} - ] -}, { - include: [ Tag ] -}) -``` - -And, we can modify this example to support an alias as well: - -```js -const Categories = Product.hasMany(Tag, { as: 'categories' }); - -Product.create({ - id: 1, - title: 'Chair', - categories: [ - { id: 1, name: 'Alpha' }, - { id: 2, name: 'Beta' } - ] -}, { - include: [{ - association: Categories, - as: 'categories' - }] -}) -``` \ No newline at end of file diff --git a/docs/manual/advanced-association-concepts/eager-loading.md b/docs/manual/advanced-association-concepts/eager-loading.md deleted file mode 100644 index 70370ce1536d..000000000000 --- a/docs/manual/advanced-association-concepts/eager-loading.md +++ /dev/null @@ -1,666 +0,0 @@ -# Eager Loading - -As briefly mentioned in [the associations guide](assocs.html), eager Loading is the act of querying data of several models at once (one 'main' model and one or more associated models). At the SQL level, this is a query with one or more [joins](https://en.wikipedia.org/wiki/Join_\(SQL\)). - -When this is done, the associated models will be added by Sequelize in appropriately named, automatically created field(s) in the returned objects. - -In Sequelize, eager loading is mainly done by using the `include` option on a model finder query (such as `findOne`, `findAll`, etc). - -## Basic example - -Let's assume the following setup: - -```js -const User = sequelize.define('user', { name: DataTypes.STRING }, { timestamps: false }); -const Task = sequelize.define('task', { name: DataTypes.STRING }, { timestamps: false }); -const Tool = sequelize.define('tool', { - name: DataTypes.STRING, - size: DataTypes.STRING -}, { timestamps: false }); -User.hasMany(Task); -Task.belongsTo(User); -User.hasMany(Tool, { as: 'Instruments' }); -``` - -### Fetching a single associated element - -OK. So, first of all, let's load all tasks with their associated user: - -```js -const tasks = await Task.findAll({ include: User }); -console.log(JSON.stringify(tasks, null, 2)); -``` - -Output: - -```json -[{ - "name": "A Task", - "id": 1, - "userId": 1, - "user": { - "name": "John Doe", - "id": 1 - } -}] -``` - -Here, `tasks[0].user instanceof User` is `true`. This shows that when Sequelize fetches associated models, they are added to the output object as model instances. - -Above, the associated model was added to a new field called `user` in the fetched task. The name of this field was automatically chosen by Sequelize based on the name of the associated model, where its pluralized form is used when applicable (i.e., when the association is `hasMany` or `belongsToMany`). In other words, since `Task.belongsTo(User)`, a task is associated to one user, therefore the logical choice is the singular form (which Sequelize follows automatically). - -### Fetching all associated elements - -Now, instead of loading the user that is associated to a given task, we will do the opposite - we will find all tasks associated to a given user. - -The method call is essentially the same. The only difference is that now the extra field created in the query result uses the pluralized form (`tasks` in this case), and its value is an array of task instances (instead of a single instance, as above). - -```js -const users = await User.findAll({ include: Task }); -console.log(JSON.stringify(users, null, 2)); -``` - -Output: - -```json -[{ - "name": "John Doe", - "id": 1, - "tasks": [{ - "name": "A Task", - "id": 1, - "userId": 1 - }] -}] -``` - -Notice that the accessor (the `tasks` property in the resulting instance) is pluralized since the association is one-to-many. - -### Fetching an Aliased association - -If an association is aliased (using the `as` option), you must specify this alias when including the model. Instead of passing the model directly to the `include` option, you should instead provide an object with two options: `model` and `as`. - -Notice how the user's `Tool`s are aliased as `Instruments` above. In order to get that right you have to specify the model you want to load, as well as the alias: - -```js -const users = await User.findAll({ - include: { model: Tool, as: 'Instruments' } -}); -console.log(JSON.stringify(users, null, 2)); -``` - -Output: - -```json -[{ - "name": "John Doe", - "id": 1, - "Instruments": [{ - "name": "Scissor", - "id": 1, - "userId": 1 - }] -}] -``` - -You can also include by alias name by specifying a string that matches the association alias: - -```js -User.findAll({ include: 'Instruments' }); // Also works -User.findAll({ include: { association: 'Instruments' } }); // Also works -``` - -### Required eager loading - -When eager loading, we can force the query to return only records which have an associated model, effectively converting the query from the default `OUTER JOIN` to an `INNER JOIN`. This is done with the `required: true` option, as follows: - -```js -User.findAll({ - include: { - model: Task, - required: true - } -}); -``` - -This option also works on nested includes. - -### Eager loading filtered at the associated model level - -When eager loading, we can also filter the associated model using the `where` option, as in the following example: - -```js -User.findAll({ - include: { - model: Tool, - as: 'Instruments' - where: { - size: { - [Op.ne]: 'small' - } - } - } -}); -``` - -Generated SQL: - -```sql -SELECT - `user`.`id`, - `user`.`name`, - `Instruments`.`id` AS `Instruments.id`, - `Instruments`.`name` AS `Instruments.name`, - `Instruments`.`size` AS `Instruments.size`, - `Instruments`.`userId` AS `Instruments.userId` -FROM `users` AS `user` -INNER JOIN `tools` AS `Instruments` ON - `user`.`id` = `Instruments`.`userId` AND - `Instruments`.`size` != 'small'; -``` - -Note that the SQL query generated above will only fetch users that have at least one tool that matches the condition (of not being `small`, in this case). This is the case because, when the `where` option is used inside an `include`, Sequelize automatically sets the `required` option to `true`. This means that, instead of an `OUTER JOIN`, an `INNER JOIN` is done, returning only the parent models with at least one matching children. - -Note also that the `where` option used was converted into a condition for the `ON` clause of the `INNER JOIN`. In order to obtain a *top-level* `WHERE` clause, instead of an `ON` clause, something different must be done. This will be shown next. - -#### Referring to other columns - -If you want to apply a `WHERE` clause in an included model referring to a value from an associated model, you can simply use the `Sequelize.col` function, as show in the example below: - -```js -// Find all projects with a least one task where task.state === project.state -Project.findAll({ - include: { - model: Task, - where: { - state: Sequelize.col('project.state') - } - } -}) -``` - -### Complex where clauses at the top-level - -To obtain top-level `WHERE` clauses that involve nested columns, Sequelize provides a way to reference nested columns: the `'$nested.column$'` syntax. - -It can be used, for example, to move the where conditions from an included model from the `ON` condition to a top-level `WHERE` clause. - -```js -User.findAll({ - where: { - '$Instruments.size$': { [Op.ne]: 'small' } - }, - include: [{ - model: Tool, - as: 'Instruments' - }] -}); -``` - -Generated SQL: - -```sql -SELECT - `user`.`id`, - `user`.`name`, - `Instruments`.`id` AS `Instruments.id`, - `Instruments`.`name` AS `Instruments.name`, - `Instruments`.`size` AS `Instruments.size`, - `Instruments`.`userId` AS `Instruments.userId` -FROM `users` AS `user` -LEFT OUTER JOIN `tools` AS `Instruments` ON - `user`.`id` = `Instruments`.`userId` -WHERE `Instruments`.`size` != 'small'; -``` - -The `$nested.column$` syntax also works for columns that are nested several levels deep, such as `$some.super.deeply.nested.column$`. Therefore, you can use this to make complex filters on deeply nested columns. - -For a better understanding of all differences between the inner `where` option (used inside an `include`), with and without the `required` option, and a top-level `where` using the `$nested.column$` syntax, below we have four examples for you: - -```js -// Inner where, with default `required: true` -await User.findAll({ - include: { - model: Tool, - as: 'Instruments', - where: { - size: { [Op.ne]: 'small' } - } - } -}); - -// Inner where, `required: false` -await User.findAll({ - include: { - model: Tool, - as: 'Instruments', - where: { - size: { [Op.ne]: 'small' } - }, - required: false - } -}); - -// Top-level where, with default `required: false` -await User.findAll({ - where: { - '$Instruments.size$': { [Op.ne]: 'small' } - }, - include: { - model: Tool, - as: 'Instruments' - } -}); - -// Top-level where, `required: true` -await User.findAll({ - where: { - '$Instruments.size$': { [Op.ne]: 'small' } - }, - include: { - model: Tool, - as: 'Instruments', - required: true - } -}); -``` - -Generated SQLs, in order: - -```sql --- Inner where, with default `required: true` -SELECT [...] FROM `users` AS `user` -INNER JOIN `tools` AS `Instruments` ON - `user`.`id` = `Instruments`.`userId` - AND `Instruments`.`size` != 'small'; - --- Inner where, `required: false` -SELECT [...] FROM `users` AS `user` -LEFT OUTER JOIN `tools` AS `Instruments` ON - `user`.`id` = `Instruments`.`userId` - AND `Instruments`.`size` != 'small'; - --- Top-level where, with default `required: false` -SELECT [...] FROM `users` AS `user` -LEFT OUTER JOIN `tools` AS `Instruments` ON - `user`.`id` = `Instruments`.`userId` -WHERE `Instruments`.`size` != 'small'; - --- Top-level where, `required: true` -SELECT [...] FROM `users` AS `user` -INNER JOIN `tools` AS `Instruments` ON - `user`.`id` = `Instruments`.`userId` -WHERE `Instruments`.`size` != 'small'; -``` - -### Fetching with `RIGHT OUTER JOIN` (MySQL, MariaDB, PostgreSQL and MSSQL only) - -By default, associations are loaded using a `LEFT OUTER JOIN` - that is to say it only includes records from the parent table. You can change this behavior to a `RIGHT OUTER JOIN` by passing the `right` option, if the dialect you are using supports it. - -Currenly, SQLite does not support [right joins](https://www.sqlite.org/omitted.html). - -*Note:* `right` is only respected if `required` is false. - -```js -User.findAll({ - include: [{ - model: Task // will create a left join - }] -}); -User.findAll({ - include: [{ - model: Task, - right: true // will create a right join - }] -}); -User.findAll({ - include: [{ - model: Task, - required: true, - right: true // has no effect, will create an inner join - }] -}); -User.findAll({ - include: [{ - model: Task, - where: { name: { [Op.ne]: 'empty trash' } }, - right: true // has no effect, will create an inner join - }] -}); -User.findAll({ - include: [{ - model: Tool, - where: { name: { [Op.ne]: 'empty trash' } }, - required: false // will create a left join - }] -}); -User.findAll({ - include: [{ - model: Tool, - where: { name: { [Op.ne]: 'empty trash' } }, - required: false - right: true // will create a right join - }] -}); -``` - -## Multiple eager loading - -The `include` option can receive an array in order to fetch multiple associated models at once: - -```js -Foo.findAll({ - include: [ - { - model: Bar, - required: true - }, - { - model: Baz, - where: /* ... */ - }, - Qux // Shorthand syntax for { model: Qux } also works here - ] -}) -``` - -## Eager loading with Many-to-Many relationships - -When you perform eager loading on a model with a Belongs-to-Many relationship, Sequelize will fetch the junction table data as well, by default. For example: - -```js -const Foo = sequelize.define('Foo', { name: DataTypes.TEXT }); -const Bar = sequelize.define('Bar', { name: DataTypes.TEXT }); -Foo.belongsToMany(Bar, { through: 'Foo_Bar' }); -Bar.belongsToMany(Foo, { through: 'Foo_Bar' }); - -await sequelize.sync(); -const foo = await Foo.create({ name: 'foo' }); -const bar = await Bar.create({ name: 'bar' }); -await foo.addBar(bar); -const fetchedFoo = await Foo.findOne({ include: Bar }); -console.log(JSON.stringify(fetchedFoo, null, 2)); -``` - -Output: - -```json -{ - "id": 1, - "name": "foo", - "Bars": [ - { - "id": 1, - "name": "bar", - "Foo_Bar": { - "FooId": 1, - "BarId": 1 - } - } - ] -} -``` - -Note that every bar instance eager loaded into the `"Bars"` property has an extra property called `Foo_Bar` which is the relevant Sequelize instance of the junction model. By default, Sequelize fetches all attributes from the junction table in order to build this extra property. - -However, you can specify which attributes you want fetched. This is done with the `attributes` option applied inside the `through` option of the include. For example: - -```js -Foo.findAll({ - include: [{ - model: Bar, - through: { - attributes: [/* list the wanted attributes here */] - } - }] -}); -``` - -If you don't want anything from the junction table, you can explicitly provide an empty array to the `attributes` option inside the `through` option of the `include` option, and in this case nothing will be fetched and the extra property will not even be created: - -```js -Foo.findOne({ - include: { - model: Bar, - through: { - attributes: [] - } - } -}); -``` - -Output: - -```json -{ - "id": 1, - "name": "foo", - "Bars": [ - { - "id": 1, - "name": "bar" - } - ] -} -``` - -Whenever including a model from a Many-to-Many relationship, you can also apply a filter on the junction table. This is done with the `where` option applied inside the `through` option of the include. For example: - -```js -User.findAll({ - include: [{ - model: Project, - through: { - where: { - // Here, `completed` is a column present at the junction table - completed: true - } - } - }] -}); -``` - -Generated SQL (using SQLite): - -```sql -SELECT - `User`.`id`, - `User`.`name`, - `Projects`.`id` AS `Projects.id`, - `Projects`.`name` AS `Projects.name`, - `Projects->User_Project`.`completed` AS `Projects.User_Project.completed`, - `Projects->User_Project`.`UserId` AS `Projects.User_Project.UserId`, - `Projects->User_Project`.`ProjectId` AS `Projects.User_Project.ProjectId` -FROM `Users` AS `User` -LEFT OUTER JOIN `User_Projects` AS `Projects->User_Project` ON - `User`.`id` = `Projects->User_Project`.`UserId` -LEFT OUTER JOIN `Projects` AS `Projects` ON - `Projects`.`id` = `Projects->User_Project`.`ProjectId` AND - `Projects->User_Project`.`completed` = 1; -``` - -## Including everything - -To include all associated models, you can use the `all` and `nested` options: - -```js -// Fetch all models associated with User -User.findAll({ include: { all: true }}); - -// Fetch all models associated with User and their nested associations (recursively) -User.findAll({ include: { all: true, nested: true }}); -``` - -## Including soft deleted records - -In case you want to eager load soft deleted records you can do that by setting `include.paranoid` to `false`: - -```js -User.findAll({ - include: [{ - model: Tool, - as: 'Instruments', - where: { size: { [Op.ne]: 'small' } }, - paranoid: false - }] -}); -``` - -## Ordering eager loaded associations - -When you want to apply `ORDER` clauses to eager loaded models, you must use the top-level `order` option with augmented arrays, starting with the specification of the nested model you want to sort. - -This is better understood with examples. - -```js -Company.findAll({ - include: Division, - order: [ - // We start the order array with the model we want to sort - [Division, 'name', 'ASC'] - ] -}); -Company.findAll({ - include: Division, - order: [ - [Division, 'name', 'DESC'] - ] -}); -Company.findAll({ - // If the include uses an alias... - include: { model: Division, as: 'Div' }, - order: [ - // ...we use the same syntax from the include - // in the beginning of the order array - [{ model: Division, as: 'Div' }, 'name', 'DESC'] - ] -}); - -Company.findAll({ - // If we have includes nested in several levels... - include: { - model: Division, - include: Department - }, - order: [ - // ... we replicate the include chain of interest - // at the beginning of the order array - [Division, Department, 'name', 'DESC'] - ] -}); -``` - -In the case of many-to-many relationships, you are also able to sort by attributes in the through table. For example, assuming we have a Many-to-Many relationship between `Division` and `Department` whose junction model is `DepartmentDivision`, you can do: - -```js -Company.findAll({ - include: { - model: Division, - include: Department - }, - order: [ - [Division, DepartmentDivision, 'name', 'ASC'] - ] -}); -``` - -In all the above examples, you have noticed that the `order` option is used at the top-level. The only situation in which `order` also works inside the include option is when `separate: true` is used. In that case, the usage is as follows: - -```js -// This only works for `separate: true` (which in turn -// only works for has-many relationships). -User.findAll({ - include: { - model: Post, - separate: true, - order: [ - ['createdAt', 'DESC'] - ] - } -}); -``` - -### Complex ordering involving sub-queries - -Take a look at the [guide on sub-queries](sub-queries.html) for an example of how to use a sub-query to assist a more complex ordering. - -## Nested eager loading - -You can use nested eager loading to load all related models of a related model: - -```js -const users = await User.findAll({ - include: { - model: Tool, - as: 'Instruments', - include: { - model: Teacher, - include: [ /* etc */ ] - } - } -}); -console.log(JSON.stringify(users, null, 2)); -``` - -Output: - -```json -[{ - "name": "John Doe", - "id": 1, - "Instruments": [{ // 1:M and N:M association - "name": "Scissor", - "id": 1, - "userId": 1, - "Teacher": { // 1:1 association - "name": "Jimi Hendrix" - } - }] -}] -``` - -This will produce an outer join. However, a `where` clause on a related model will create an inner join and return only the instances that have matching sub-models. To return all parent instances, you should add `required: false`. - -```js -User.findAll({ - include: [{ - model: Tool, - as: 'Instruments', - include: [{ - model: Teacher, - where: { - school: "Woodstock Music School" - }, - required: false - }] - }] -}); -``` - -The query above will return all users, and all their instruments, but only those teachers associated with `Woodstock Music School`. - -## Using `findAndCountAll` with includes - -The `findAndCountAll` utility function supports includes. Only the includes that are marked as `required` will be considered in `count`. For example, if you want to find and count all users who have a profile: - -```js -User.findAndCountAll({ - include: [ - { model: Profile, required: true } - ], - limit: 3 -}); -``` - -Because the include for `Profile` has `required` set it will result in an inner join, and only the users who have a profile will be counted. If we remove `required` from the include, both users with and without profiles will be counted. Adding a `where` clause to the include automatically makes it required: - -```js -User.findAndCountAll({ - include: [ - { model: Profile, where: { active: true } } - ], - limit: 3 -}); -``` - -The query above will only count users who have an active profile, because `required` is implicitly set to true when you add a where clause to the include. diff --git a/docs/manual/advanced-association-concepts/polymorphic-associations.md b/docs/manual/advanced-association-concepts/polymorphic-associations.md deleted file mode 100644 index 2a1ade8f216b..000000000000 --- a/docs/manual/advanced-association-concepts/polymorphic-associations.md +++ /dev/null @@ -1,427 +0,0 @@ -# Polymorphic Associations - -_**Note:** the usage of polymorphic associations in Sequelize, as outlined in this guide, should be done with caution. Don't just copy-paste code from here, otherwise you might easily make mistakes and introduce bugs in your code. Make sure you understand what is going on._ - -## Concept - -A **polymorphic association** consists on two (or more) associations happening with the same foreign key. - -For example, consider the models `Image`, `Video` and `Comment`. The first two represent something that a user might post. We want to allow comments to be placed in both of them. This way, we immediately think of establishing the following associations: - -* A One-to-Many association between `Image` and `Comment`: - - ```js - Image.hasMany(Comment); - Comment.belongsTo(Image); - ``` - -* A One-to-Many association between `Video` and `Comment`: - - ```js - Video.hasMany(Comment); - Comment.belongsTo(Video); - ``` - -However, the above would cause Sequelize to create two foreign keys on the `Comment` table: `ImageId` and `VideoId`. This is not ideal because this structure makes it look like a comment can be attached at the same time to one image and one video, which isn't true. Instead, what we really want here is precisely a polymorphic association, in which a `Comment` points to a single **Commentable**, an abstract polymorphic entity that represents one of `Image` or `Video`. - -Before proceeding to how to configure such an association, let's see how using it looks like: - -```js -const image = await Image.create({ url: "https://placekitten.com/408/287" }); -const comment = await image.createComment({ content: "Awesome!" }); - -console.log(comment.commentableId === image.id); // true - -// We can also retrieve which type of commentable a comment is associated to. -// The following prints the model name of the associated commentable instance. -console.log(comment.commentableType); // "Image" - -// We can use a polymorphic method to retrieve the associated commentable, without -// having to worry whether it's an Image or a Video. -const associatedCommentable = await comment.getCommentable(); - -// In this example, `associatedCommentable` is the same thing as `image`: -const isDeepEqual = require('deep-equal'); -console.log(isDeepEqual(image, commentable)); // true -``` - -## Configuring a One-to-Many polymorphic association - -To setup the polymorphic association for the example above (which is an example of One-to-Many polymorphic association), we have the following steps: - -* Define a string field called `commentableType` in the `Comment` model; -* Define the `hasMany` and `belongsTo` association between `Image`/`Video` and `Comment`: - * Disabling constraints (i.e. using `{ constraints: false }`), since the same foreign key is referencing multiple tables; - * Specifying the appropriate [association scopes](association-scopes.html); -* To properly support lazy loading, define a new instance method on the `Comment` model called `getCommentable` which calls, under the hood, the correct mixin to fetch the appropriate commentable; -* To properly support eager loading, define an `afterFind` hook on the `Comment` model that automatically populates the `commentable` field in every instance; -* To prevent bugs/mistakes in eager loading, you can also delete the concrete fields `image` and `video` from Comment instances in the same `afterFind` hook, leaving only the abstract `commentable` field available. - -Here is an example: - -```js -// Helper function -const uppercaseFirst = str => `${str[0].toUpperCase()}${str.substr(1)}`; - -class Image extends Model {} -Image.init({ - title: DataTypes.STRING, - url: DataTypes.STRING -}, { sequelize, modelName: 'image' }); - -class Video extends Model {} -Video.init({ - title: DataTypes.STRING, - text: DataTypes.STRING -}, { sequelize, modelName: 'video' }); - -class Comment extends Model { - getCommentable(options) { - if (!this.commentableType) return Promise.resolve(null); - const mixinMethodName = `get${uppercaseFirst(this.commentableType)}`; - return this[mixinMethodName](options); - } -} -Comment.init({ - title: DataTypes.STRING, - commentableId: DataTypes.INTEGER, - commentableType: DataTypes.STRING -}, { sequelize, modelName: 'comment' }); - -Image.hasMany(Comment, { - foreignKey: 'commentableId', - constraints: false, - scope: { - commentableType: 'image' - } -}); -Comment.belongsTo(Image, { foreignKey: 'commentableId', constraints: false }); - -Video.hasMany(Comment, { - foreignKey: 'commentableId', - constraints: false, - scope: { - commentableType: 'video' - } -}); -Comment.belongsTo(Video, { foreignKey: 'commentableId', constraints: false }); - -Comment.addHook("afterFind", findResult => { - if (!Array.isArray(findResult)) findResult = [findResult]; - for (const instance of findResult) { - if (instance.commentableType === "image" && instance.image !== undefined) { - instance.commentable = instance.image; - } else if (instance.commentableType === "video" && instance.video !== undefined) { - instance.commentable = instance.video; - } - // To prevent mistakes: - delete instance.image; - delete instance.dataValues.image; - delete instance.video; - delete instance.dataValues.video; - } -}); -``` - -Since the `commentableId` column references several tables (two in this case), we cannot add a `REFERENCES` constraint to it. This is why the `constraints: false` option was used. - -Note that, in the code above: - -* The *Image -> Comment* association defined an association scope: `{ commentableType: 'image' }` -* The *Video -> Comment* association defined an association scope: `{ commentableType: 'video' }` - -These scopes are automatically applied when using the association functions (as explained in the [Association Scopes](association-scopes.html) guide). Some examples are below, with their generated SQL statements: - -* `image.getComments()`: - - ```sql - SELECT "id", "title", "commentableType", "commentableId", "createdAt", "updatedAt" - FROM "comments" AS "comment" - WHERE "comment"."commentableType" = 'image' AND "comment"."commentableId" = 1; - ``` - - Here we can see that `` `comment`.`commentableType` = 'image'`` was automatically added to the `WHERE` clause of the generated SQL. This is exactly the behavior we want. - -* `image.createComment({ title: 'Awesome!' })`: - - ```sql - INSERT INTO "comments" ( - "id", "title", "commentableType", "commentableId", "createdAt", "updatedAt" - ) VALUES ( - DEFAULT, 'Awesome!', 'image', 1, - '2018-04-17 05:36:40.454 +00:00', '2018-04-17 05:36:40.454 +00:00' - ) RETURNING *; - ``` - -* `image.addComment(comment)`: - - ```sql - UPDATE "comments" - SET "commentableId"=1, "commentableType"='image', "updatedAt"='2018-04-17 05:38:43.948 +00:00' - WHERE "id" IN (1) - ``` - -### Polymorphic lazy loading - -The `getCommentable` instance method on `Comment` provides an abstraction for lazy loading the associated commentable - working whether the comment belongs to an Image or a Video. - -It works by simply converting the `commentableType` string into a call to the correct mixin (either `getImage` or `getVideo`). - -Note that the `getCommentable` implementation above: - -* Returns `null` when no association is present (which is good); -* Allows you to pass an options object to `getCommentable(options)`, just like any other standard Sequelize method. This is useful to specify where-conditions or includes, for example. - -### Polymorphic eager loading - -Now, we want to perform a polymorphic eager loading of the associated commentables for one (or more) comments. We want to achieve something similar to the following idea: - -```js -const comment = await Comment.findOne({ - include: [ /* What to put here? */ ] -}); -console.log(comment.commentable); // This is our goal -``` - -The solution is to tell Sequelize to include both Images and Videos, so that our `afterFind` hook defined above will do the work, automatically adding the `commentable` field to the instance object, providing the abstraction we want. - -For example: - -```js -const comments = await Comment.findAll({ - include: [Image, Video] -}); -for (const comment of comments) { - const message = `Found comment #${comment.id} with ${comment.commentableType} commentable:`; - console.log(message, comment.commentable.toJSON()); -} -``` - -Output example: - -```text -Found comment #1 with image commentable: { id: 1, - title: 'Meow', - url: 'https://placekitten.com/408/287', - createdAt: 2019-12-26T15:04:53.047Z, - updatedAt: 2019-12-26T15:04:53.047Z } -``` - -### Caution - possibly invalid eager/lazy loading! - -Consider a comment `Foo` whose `commentableId` is 2 and `commentableType` is `image`. Consider also that `Image A` and `Video X` both happen to have an id equal to 2. Conceptually, it is clear that `Video X` is not associated to `Foo`, because even though its id is 2, the `commentableType` of `Foo` is `image`, not `video`. However, this distinction is made by Sequelize only at the level of the abstractions performed by `getCommentable` and the hook we created above. - -This means that if you call `Comment.findAll({ include: Video })` in the situation above, `Video X` will be eager loaded into `Foo`. Thankfully, our `afterFind` hook will delete it automatically, to help prevent bugs, but regardless it is important that you understand what is going on. - -The best way to prevent this kind of mistake is to **avoid using the concrete accessors and mixins directly at all costs** (such as `.image`, `.getVideo()`, `.setImage()`, etc), always preferring the abstractions we created, such as `.getCommentable()` and `.commentable`. If you really need to access eager-loaded `.image` and `.video` for some reason, make sure you wrap that in a type check such as `comment.commentableType === 'image'`. - -## Configuring a Many-to-Many polymorphic association - -In the above example, we had the models `Image` and `Video` being abstractly called *commentables*, with one *commentable* having many comments. However, one given comment would belong to a single *commentable* - this is why the whole situation is a One-to-Many polymorphic association. - -Now, to consider a Many-to-Many polymorphic association, instead of considering comments, we will consider tags. For convenience, instead of calling Image and Video as *commentables*, we will now call them *taggables*. One *taggable* may have several tags, and at the same time one tag can be placed in several *taggables*. - -The setup for this goes as follows: - -* Define the junction model explicitly, specifying the two foreign keys as `tagId` and `taggableId` (this way it is a junction model for a Many-to-Many relationship between `Tag` and the abstract concept of *taggable*); -* Define a string field called `taggableType` in the junction model; -* Define the `belongsToMany` associations between the two models and `Tag`: - * Disabling constraints (i.e. using `{ constraints: false }`), since the same foreign key is referencing multiple tables; - * Specifying the appropriate [association scopes](association-scopes.html); -* Define a new instance method on the `Tag` model called `getTaggables` which calls, under the hood, the correct mixin to fetch the appropriate taggables. - -Implementation: - -```js -class Tag extends Model { - getTaggables(options) { - const images = await this.getImages(options); - const videos = await this.getVideos(options); - // Concat images and videos in a single array of taggables - return images.concat(videos); - } -} -Tag.init({ - name: DataTypes.STRING -}, { sequelize, modelName: 'tag' }); - -// Here we define the junction model explicitly -class Tag_Taggable extends Model {} -Tag_Taggable.init({ - tagId: { - type: DataTypes.INTEGER, - unique: 'tt_unique_constraint' - }, - taggableId: { - type: DataTypes.INTEGER, - unique: 'tt_unique_constraint', - references: null - }, - taggableType: { - type: DataTypes.STRING, - unique: 'tt_unique_constraint' - } -}, { sequelize, modelName: 'tag_taggable' }); - -Image.belongsToMany(Tag, { - through: { - model: Tag_Taggable, - unique: false, - scope: { - taggableType: 'image' - } - }, - foreignKey: 'taggableId', - constraints: false -}); -Tag.belongsToMany(Image, { - through: { - model: Tag_Taggable, - unique: false - }, - foreignKey: 'tagId', - constraints: false -}); - -Video.belongsToMany(Tag, { - through: { - model: Tag_Taggable, - unique: false, - scope: { - taggableType: 'video' - } - }, - foreignKey: 'taggableId', - constraints: false -}); -Tag.belongsToMany(Video, { - through: { - model: Tag_Taggable, - unique: false - }, - foreignKey: 'tagId', - constraints: false -}); -``` - -The `constraints: false` option disables references constraints, as the `taggableId` column references several tables, we cannot add a `REFERENCES` constraint to it. - -Note that: - -* The *Image -> Tag* association defined an association scope: `{ taggableType: 'image' }` -* The *Video -> Tag* association defined an association scope: `{ taggableType: 'video' }` - -These scopes are automatically applied when using the association functions. Some examples are below, with their generated SQL statements: - -* `image.getTags()`: - - ```sql - SELECT - `tag`.`id`, - `tag`.`name`, - `tag`.`createdAt`, - `tag`.`updatedAt`, - `tag_taggable`.`tagId` AS `tag_taggable.tagId`, - `tag_taggable`.`taggableId` AS `tag_taggable.taggableId`, - `tag_taggable`.`taggableType` AS `tag_taggable.taggableType`, - `tag_taggable`.`createdAt` AS `tag_taggable.createdAt`, - `tag_taggable`.`updatedAt` AS `tag_taggable.updatedAt` - FROM `tags` AS `tag` - INNER JOIN `tag_taggables` AS `tag_taggable` ON - `tag`.`id` = `tag_taggable`.`tagId` AND - `tag_taggable`.`taggableId` = 1 AND - `tag_taggable`.`taggableType` = 'image'; - ``` - - Here we can see that `` `tag_taggable`.`taggableType` = 'image'`` was automatically added to the `WHERE` clause of the generated SQL. This is exactly the behavior we want. - -* `tag.getTaggables()`: - - ```sql - SELECT - `image`.`id`, - `image`.`url`, - `image`.`createdAt`, - `image`.`updatedAt`, - `tag_taggable`.`tagId` AS `tag_taggable.tagId`, - `tag_taggable`.`taggableId` AS `tag_taggable.taggableId`, - `tag_taggable`.`taggableType` AS `tag_taggable.taggableType`, - `tag_taggable`.`createdAt` AS `tag_taggable.createdAt`, - `tag_taggable`.`updatedAt` AS `tag_taggable.updatedAt` - FROM `images` AS `image` - INNER JOIN `tag_taggables` AS `tag_taggable` ON - `image`.`id` = `tag_taggable`.`taggableId` AND - `tag_taggable`.`tagId` = 1; - - SELECT - `video`.`id`, - `video`.`url`, - `video`.`createdAt`, - `video`.`updatedAt`, - `tag_taggable`.`tagId` AS `tag_taggable.tagId`, - `tag_taggable`.`taggableId` AS `tag_taggable.taggableId`, - `tag_taggable`.`taggableType` AS `tag_taggable.taggableType`, - `tag_taggable`.`createdAt` AS `tag_taggable.createdAt`, - `tag_taggable`.`updatedAt` AS `tag_taggable.updatedAt` - FROM `videos` AS `video` - INNER JOIN `tag_taggables` AS `tag_taggable` ON - `video`.`id` = `tag_taggable`.`taggableId` AND - `tag_taggable`.`tagId` = 1; - ``` - -Note that the above implementation of `getTaggables()` allows you to pass an options object to `getCommentable(options)`, just like any other standard Sequelize method. This is useful to specify where-conditions or includes, for example. - -### Applying scopes on the target model - -In the example above, the `scope` options (such as `scope: { taggableType: 'image' }`) were applied to the *through* model, not the *target* model, since it was used under the `through` option. - -We can also apply an association scope on the target model. We can even do both at the same time. - -To illustrate this, consider an extension of the above example between tags and taggables, where each tag has a status. This way, to get all pending tags of an image, we could establish another `belognsToMany` relationship between `Image` and `Tag`, this time applying a scope on the through model and another scope on the target model: - -```js -Image.belongsToMany(Tag, { - through: { - model: Tag_Taggable, - unique: false, - scope: { - taggableType: 'image' - } - }, - scope: { - status: 'pending' - }, - as: 'pendingTags', - foreignKey: 'taggableId', - constraints: false -}); -``` - -This way, when calling `image.getPendingTags()`, the following SQL query will be generated: - -```sql -SELECT - `tag`.`id`, - `tag`.`name`, - `tag`.`status`, - `tag`.`createdAt`, - `tag`.`updatedAt`, - `tag_taggable`.`tagId` AS `tag_taggable.tagId`, - `tag_taggable`.`taggableId` AS `tag_taggable.taggableId`, - `tag_taggable`.`taggableType` AS `tag_taggable.taggableType`, - `tag_taggable`.`createdAt` AS `tag_taggable.createdAt`, - `tag_taggable`.`updatedAt` AS `tag_taggable.updatedAt` -FROM `tags` AS `tag` -INNER JOIN `tag_taggables` AS `tag_taggable` ON - `tag`.`id` = `tag_taggable`.`tagId` AND - `tag_taggable`.`taggableId` = 1 AND - `tag_taggable`.`taggableType` = 'image' -WHERE ( - `tag`.`status` = 'pending' -); -``` - -We can see that both scopes were applied automatically: - -* `` `tag_taggable`.`taggableType` = 'image'`` was added automatically to the `INNER JOIN`; -* `` `tag`.`status` = 'pending'`` was added automatically to an outer where clause. diff --git a/docs/manual/core-concepts/assocs.md b/docs/manual/core-concepts/assocs.md deleted file mode 100644 index bff3b1b5fe49..000000000000 --- a/docs/manual/core-concepts/assocs.md +++ /dev/null @@ -1,799 +0,0 @@ -# Associations - -Sequelize supports the standard associations: [One-To-One](https://en.wikipedia.org/wiki/One-to-one_%28data_model%29), [One-To-Many](https://en.wikipedia.org/wiki/One-to-many_%28data_model%29) and [Many-To-Many](https://en.wikipedia.org/wiki/Many-to-many_%28data_model%29). - -To do this, Sequelize provides **four** types of associations that should be combined to create them: - -* The `HasOne` association -* The `BelongsTo` association -* The `HasMany` association -* The `BelongsToMany` association - -The guide will start explaining how to define these four types of associations, and then will follow up to explain how to combine those to define the three standard association types ([One-To-One](https://en.wikipedia.org/wiki/One-to-one_%28data_model%29), [One-To-Many](https://en.wikipedia.org/wiki/One-to-many_%28data_model%29) and [Many-To-Many](https://en.wikipedia.org/wiki/Many-to-many_%28data_model%29)). - -## Defining the Sequelize associations - -The four association types are defined in a very similar way. Let's say we have two models, `A` and `B`. Telling Sequelize that you want an association between the two needs just a function call: - -```js -const A = sequelize.define('A', /* ... */); -const B = sequelize.define('B', /* ... */); - -A.hasOne(B); // A HasOne B -A.belongsTo(B); // A BelongsTo B -A.hasMany(B); // A HasMany B -A.belongsToMany(B, { through: 'C' }); // A BelongsToMany B through the junction table C -``` - -They all accept an options object as a second parameter (optional for the first three, mandatory for `belongsToMany` containing at least the `through` property): - -```js -A.hasOne(B, { /* options */ }); -A.belongsTo(B, { /* options */ }); -A.hasMany(B, { /* options */ }); -A.belongsToMany(B, { through: 'C', /* options */ }); -``` - -The order in which the association is defined is relevant. In other words, the order matters, for the four cases. In all examples above, `A` is called the **source** model and `B` is called the **target** model. This terminology is important. - -The `A.hasOne(B)` association means that a One-To-One relationship exists between `A` and `B`, with the foreign key being defined in the target model (`B`). - -The `A.belongsTo(B)` association means that a One-To-One relationship exists between `A` and `B`, with the foreign key being defined in the source model (`A`). - -The `A.hasMany(B)` association means that a One-To-Many relationship exists between `A` and `B`, with the foreign key being defined in the target model (`B`). - -These three calls will cause Sequelize to automatically add foreign keys to the appropriate models (unless they are already present). - -The `A.belongsToMany(B, { through: 'C' })` association means that a Many-To-Many relationship exists between `A` and `B`, using table `C` as [junction table](https://en.wikipedia.org/wiki/Associative_entity), which will have the foreign keys (`aId` and `bId`, for example). Sequelize will automatically create this model `C` (unless it already exists) and define the appropriate foreign keys on it. - -*Note: In the examples above for `belongsToMany`, a string (`'C'`) was passed to the through option. In this case, Sequelize automatically generates a model with this name. However, you can also pass a model directly, if you have already defined it.* - -These are the main ideas involved in each type of association. However, these relationships are often used in pairs, in order to enable better usage with Sequelize. This will be seen later on. - -## Creating the standard relationships - -As mentioned, usually the Sequelize associations are defined in pairs. In summary: - -* To create a **One-To-One** relationship, the `hasOne` and `belongsTo` associations are used together; -* To create a **One-To-Many** relationship, the `hasMany` and `belongsTo` associations are used together; -* To create a **Many-To-Many** relationship, two `belongsToMany` calls are used together. - * Note: there is also a *Super Many-To-Many* relationship, which uses six associations at once, and will be discussed in the [Advanced Many-to-Many relationships guide](advanced-many-to-many.html). - -This will all be seen in detail next. The advantages of using these pairs instead of one single association will be discussed in the end of this chapter. - -## One-To-One relationships - -### Philosophy - -Before digging into the aspects of using Sequelize, it is useful to take a step back to consider what happens with a One-To-One relationship. - -Let's say we have two models, `Foo` and `Bar`. We want to establish a One-To-One relationship between Foo and Bar. We know that in a relational database, this will be done by establishing a foreign key in one of the tables. So in this case, a very relevant question is: in which table do we want this foreign key to be? In other words, do we want `Foo` to have a `barId` column, or should `Bar` have a `fooId` column instead? - -In principle, both options are a valid way to establish a One-To-One relationship between Foo and Bar. However, when we say something like *"there is a One-To-One relationship between Foo and Bar"*, it is unclear whether or not the relationship is *mandatory* or optional. In other words, can a Foo exist without a Bar? Can a Bar exist without a Foo? The answers to these questions helps figuring out where we want the foreign key column to be. - -### Goal - -For the rest of this example, let's assume that we have two models, `Foo` and `Bar`. We want to setup a One-To-One relationship between them such that `Bar` gets a `fooId` column. - -### Implementation - -The main setup to achieve the goal is as follows: - -```js -Foo.hasOne(Bar); -Bar.belongsTo(Foo); -``` - -Since no option was passed, Sequelize will infer what to do from the names of the models. In this case, Sequelize knows that a `fooId` column must be added to `Bar`. - -This way, calling `Bar.sync()` after the above will yield the following SQL (on PostgreSQL, for example): - -```sql -CREATE TABLE IF NOT EXISTS "foos" ( - /* ... */ -); -CREATE TABLE IF NOT EXISTS "bars" ( - /* ... */ - "fooId" INTEGER REFERENCES "foos" ("id") ON DELETE SET NULL ON UPDATE CASCADE - /* ... */ -); -``` - -### Options - -Various options can be passed as a second parameter of the association call. - -#### `onDelete` and `onUpdate` - -For example, to configure the `ON DELETE` and `ON UPDATE` behaviors, you can do: - -```js -Foo.hasOne(Bar, { - onDelete: 'RESTRICT', - onUpdate: 'RESTRICT' -}); -Bar.belongsTo(Foo); -``` - -The possible choices are `RESTRICT`, `CASCADE`, `NO ACTION`, `SET DEFAULT` and `SET NULL`. - -The defaults for the One-To-One associations is `SET NULL` for `ON DELETE` and `CASCADE` for `ON UPDATE`. - -#### Customizing the foreign key - -Both the `hasOne` and `belongsTo` calls shown above will infer that the foreign key to be created should be called `fooId`. To use a different name, such as `myFooId`: - -```js -// Option 1 -Foo.hasOne(Bar, { - foreignKey: 'myFooId' -}); -Bar.belongsTo(Foo); - -// Option 2 -Foo.hasOne(Bar, { - foreignKey: { - name: 'myFooId' - } -}); -Bar.belongsTo(Foo); - -// Option 3 -Foo.hasOne(Bar); -Bar.belongsTo(Foo, { - foreignKey: 'myFooId' -}); - -// Option 4 -Foo.hasOne(Bar); -Bar.belongsTo(Foo, { - foreignKey: { - name: 'myFooId' - } -}); -``` - -As shown above, the `foreignKey` option accepts a string or an object. When receiving an object, this object will be used as the definition for the column just like it would do in a standard `sequelize.define` call. Therefore, specifying options such as `type`, `allowNull`, `defaultValue`, etc, just work. - -For example, to use `UUID` as the foreign key data type instead of the default (`INTEGER`), you can simply do: - -```js -const { DataTypes } = require("Sequelize"); - -Foo.hasOne(Bar, { - foreignKey: { - // name: 'myFooId' - type: DataTypes.UUID - } -}); -Bar.belongsTo(Foo); -``` - -#### Mandatory versus optional associations - -By default, the association is considered optional. In other words, in our example, the `fooId` is allowed to be null, meaning that one Bar can exist without a Foo. Changing this is just a matter of specifying `allowNull: false` in the foreign key options: - -```js -Foo.hasOne(Bar, { - foreignKey: { - allowNull: false - } -}); -// "fooId" INTEGER NOT NULL REFERENCES "foos" ("id") ON DELETE RESTRICT ON UPDATE RESTRICT -``` - -## One-To-Many relationships - -### Philosophy - -One-To-Many associations are connecting one source with multiple targets, while all these targets are connected only with this single source. - -This means that, unlike the One-To-One association, in which we had to choose where the foreign key would be placed, there is only one option in One-To-Many associations. For example, if one Foo has many Bars (and this way each Bar belongs to one Foo), then the only sensible implementation is to have a `fooId` column in the `Bar` table. The opposite is impossible, since one Foo has many Bars. - -### Goal - -In this example, we have the models `Team` and `Player`. We want to tell Sequelize that there is a One-To-Many relationship between them, meaning that one Team has many Players, while each Player belongs to a single Team. - -### Implementation - -The main way to do this is as follows: - -```js -Team.hasMany(Player); -Player.belongsTo(Team); -``` - -Again, as mentioned, the main way to do it used a pair of Sequelize associations (`hasMany` and `belongsTo`). - -For example, in PostgreSQL, the above setup will yield the following SQL upon `sync()`: - -```sql -CREATE TABLE IF NOT EXISTS "Teams" ( - /* ... */ -); -CREATE TABLE IF NOT EXISTS "Players" ( - /* ... */ - "TeamId" INTEGER REFERENCES "Teams" ("id") ON DELETE SET NULL ON UPDATE CASCADE, - /* ... */ -); -``` - -### Options - -The options to be applied in this case are the same from the One-To-One case. For example, to change the name of the foreign key and make sure that the relationship is mandatory, we can do: - -```js -Team.hasMany(Player, { - foreignKey: 'clubId' -}); -Player.belongsTo(Team); -``` - -Like One-To-One relationships, `ON DELETE` defaults to `SET NULL` and `ON UPDATE` defaults to `CASCADE`. - -## Many-To-Many relationships - -### Philosophy - -Many-To-Many associations connect one source with multiple targets, while all these targets can in turn be connected to other sources beyond the first. - -This cannot be represented by adding one foreign key to one of the tables, like the other relationships did. Instead, the concept of a [Junction Model](https://en.wikipedia.org/wiki/Associative_entity) is used. This will be an extra model (and extra table in the database) which will have two foreign key columns and will keep track of the associations. The junction table is also sometimes called *join table* or *through table*. - -### Goal - -For this example, we will consider the models `Movie` and `Actor`. One actor may have participated in many movies, and one movie had many actors involved with its production. The junction table that will keep track of the associations will be called `ActorMovies`, which will contain the foreign keys `movieId` and `actorId`. - -### Implementation - -The main way to do this in Sequelize is as follows: - -```js -const Movie = sequelize.define('Movie', { name: DataTypes.STRING }); -const Actor = sequelize.define('Actor', { name: DataTypes.STRING }); -Movie.belongsToMany(Actor, { through: 'ActorMovies' }); -Actor.belongsToMany(Movie, { through: 'ActorMovies' }); -``` - -Since a string was given in the `through` option of the `belongsToMany` call, Sequelize will automatically create the `ActorMovies` model which will act as the junction model. For example, in PostgreSQL: - -```sql -CREATE TABLE IF NOT EXISTS "ActorMovies" ( - "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL, - "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL, - "MovieId" INTEGER REFERENCES "Movies" ("id") ON DELETE CASCADE ON UPDATE CASCADE, - "ActorId" INTEGER REFERENCES "Actors" ("id") ON DELETE CASCADE ON UPDATE CASCADE, - PRIMARY KEY ("MovieId","ActorId") -); -``` - -Instead of a string, passing a model directly is also supported, and in that case the given model will be used as the junction model (and no model will be created automatically). For example: - -```js -const Movie = sequelize.define('Movie', { name: DataTypes.STRING }); -const Actor = sequelize.define('Actor', { name: DataTypes.STRING }); -const ActorMovies = sequelize.define('ActorMovies', { - MovieId: { - type: DataTypes.INTEGER, - references: { - model: Movie, // 'Movies' would also work - key: 'id' - } - }, - ActorId: { - type: DataTypes.INTEGER, - references: { - model: Actor, // 'Actors' would also work - key: 'id' - } - } -}); -Movie.belongsToMany(Actor, { through: ActorMovies }); -Actor.belongsToMany(Movie, { through: ActorMovies }); -``` - -The above yields the following SQL in PostgreSQL, which is equivalent to the one shown above: - -```sql -CREATE TABLE IF NOT EXISTS "ActorMovies" ( - "MovieId" INTEGER NOT NULL REFERENCES "Movies" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, - "ActorId" INTEGER NOT NULL REFERENCES "Actors" ("id") ON DELETE RESTRICT ON UPDATE CASCADE, - "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL, - "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL, - UNIQUE ("MovieId", "ActorId"), -- Note: Sequelize generated this UNIQUE constraint but - PRIMARY KEY ("MovieId","ActorId") -- it is irrelevant since it's also a PRIMARY KEY -); -``` - -### Options - -Unlike One-To-One and One-To-Many relationships, the defaults for both `ON UPDATE` and `ON DELETE` are `CASCADE` for Many-To-Many relationships. - -Belongs-To-Many creates a unique key on through model. This unique key name can be overridden using **uniqueKey** option. To prevent creating this unique key, use the ***unique: false*** option. - -```js -Project.belongsToMany(User, { through: UserProjects, uniqueKey: 'my_custom_unique' }) -``` - -## Basics of queries involving associations - -With the basics of defining associations covered, we can look at queries involving associations. The most common queries on this matter are the *read* queries (i.e. SELECTs). Later on, other types of queries will be shown. - -In order to study this, we will consider an example in which we have Ships and Captains, and a one-to-one relationship between them. We will allow null on foreign keys (the default), meaning that a Ship can exist without a Captain and vice-versa. - -```js -// This is the setup of our models for the examples below -const Ship = sequelize.define('ship', { - name: DataTypes.TEXT, - crewCapacity: DataTypes.INTEGER, - amountOfSails: DataTypes.INTEGER -}, { timestamps: false }); -const Captain = sequelize.define('captain', { - name: DataTypes.TEXT, - skillLevel: { - type: DataTypes.INTEGER, - validate: { min: 1, max: 10 } - } -}, { timestamps: false }); -Captain.hasOne(Ship); -Ship.belongsTo(Captain); -``` - -### Fetching associations - Eager Loading vs Lazy Loading - -The concepts of Eager Loading and Lazy Loading are fundamental to understand how fetching associations work in Sequelize. Lazy Loading refers to the technique of fetching the associated data only when you really want it; Eager Loading, on the other hand, refers to the technique of fetching everything at once, since the beginning, with a larger query. - -#### Lazy Loading example - -```js -const awesomeCaptain = await Captain.findOne({ - where: { - name: "Jack Sparrow" - } -}); -// Do stuff with the fetched captain -console.log('Name:', awesomeCaptain.name); -console.log('Skill Level:', awesomeCaptain.skillLevel); -// Now we want information about his ship! -const hisShip = await awesomeCaptain.getShip(); -// Do stuff with the ship -console.log('Ship Name:', hisShip.name); -console.log('Amount of Sails:', hisShip.amountOfSails); -``` - -Observe that in the example above, we made two queries, only fetching the associated ship when we wanted to use it. This can be especially useful if we may or may not need the ship, perhaps we want to fetch it conditionally, only in a few cases; this way we can save time and memory by only fetching it when necessary. - -Note: the `getShip()` instance method used above is one of the methods Sequelize automatically adds to `Captain` instances. There are others. You will learn more about them later in this guide. - -#### Eager Loading Example - -```js -const awesomeCaptain = await Captain.findOne({ - where: { - name: "Jack Sparrow" - }, - include: Ship -}); -// Now the ship comes with it -console.log('Name:', awesomeCaptain.name); -console.log('Skill Level:', awesomeCaptain.skillLevel); -console.log('Ship Name:', awesomeCaptain.ship.name); -console.log('Amount of Sails:', awesomeCaptain.ship.amountOfSails); -``` - -As shown above, Eager Loading is performed in Sequelize by using the `include` option. Observe that here only one query was performed to the database (which brings the associated data along with the instance). - -This was just a quick introduction to Eager Loading in Sequelize. There is a lot more to it, which you can learn at [the dedicated guide on Eager Loading](eager-loading.html). - -### Creating, updating and deleting - -The above showed the basics on queries for fetching data involving associations. For creating, updating and deleting, you can either: - -* Use the standard model queries directly: - - ```js - // Example: creating an associated model using the standard methods - Bar.create({ - name: 'My Bar', - fooId: 5 - }); - // This creates a Bar belonging to the Foo of ID 5 (since fooId is - // a regular column, after all). Nothing very clever going on here. - ``` - -* Or use the *[special methods/mixins](#special-methods-mixins-added-to-instances)* available for associated models, which are explained later on this page. - -**Note:** The [`save()` instance method](../class/lib/model.js~Model.html#instance-method-save) is not aware of associations. In other words, if you change a value from a *child* object that was eager loaded along a *parent* object, calling `save()` on the parent will completely ignore the change that happened on the child. - -## Association Aliases & Custom Foreign Keys - -In all the above examples, Sequelize automatically defined the foreign key names. For example, in the Ship and Captain example, Sequelize automatically defined a `captainId` field on the Ship model. However, it is easy to specify a custom foreign key. - -Let's consider the models Ship and Captain in a simplified form, just to focus on the current topic, as shown below (less fields): - -```js -const Ship = sequelize.define('ship', { name: DataTypes.TEXT }, { timestamps: false }); -const Captain = sequelize.define('captain', { name: DataTypes.TEXT }, { timestamps: false }); -``` - -There are three ways to specify a different name for the foreign key: - -* By providing the foreign key name directly -* By defining an Alias -* By doing both things - -### Recap: the default setup - -By using simply `Ship.belongsTo(Captain)`, sequelize will generate the foreign key name automatically: - -```js -Ship.belongsTo(Captain); // This creates the `captainId` foreign key in Ship. - -// Eager Loading is done by passing the model to `include`: -console.log((await Ship.findAll({ include: Captain })).toJSON()); -// Or by providing the associated model name: -console.log((await Ship.findAll({ include: 'captain' })).toJSON()); - -// Also, instances obtain a `getCaptain()` method for Lazy Loading: -const ship = Ship.findOne(); -console.log((await ship.getCaptain()).toJSON()); -``` - -### Providing the foreign key name directly - -The foreign key name can be provided directly with an option in the association definition, as follows: - -```js -Ship.belongsTo(Captain, { foreignKey: 'bossId' }); // This creates the `bossId` foreign key in Ship. - -// Eager Loading is done by passing the model to `include`: -console.log((await Ship.findAll({ include: Captain })).toJSON()); -// Or by providing the associated model name: -console.log((await Ship.findAll({ include: 'Captain' })).toJSON()); - -// Also, instances obtain a `getCaptain()` method for Lazy Loading: -const ship = Ship.findOne(); -console.log((await ship.getCaptain()).toJSON()); -``` - -### Defining an Alias - -Defining an Alias is more powerful than simply specifying a custom name for the foreign key. This is better understood with an example: - - - -```js -Ship.belongsTo(Captain, { as: 'leader' }); // This creates the `leaderId` foreign key in Ship. - -// Eager Loading no longer works by passing the model to `include`: -console.log((await Ship.findAll({ include: Captain })).toJSON()); // Throws an error -// Instead, you have to pass the alias: -console.log((await Ship.findAll({ include: 'leader' })).toJSON()); -// Or you can pass an object specifying the model and alias: -console.log((await Ship.findAll({ - include: { - model: Captain, - as: 'leader' - } -})).toJSON()); - -// Also, instances obtain a `getLeader()` method for Lazy Loading: -const ship = Ship.findOne(); -console.log((await ship.getLeader()).toJSON()); -``` - -Aliases are especially useful when you need to define two different associations between the same models. For example, if we have the models `Mail` and `Person`, we may want to associate them twice, to represent the `sender` and `receiver` of the Mail. In this case we must use an alias for each association, since otherwise a call like `mail.getPerson()` would be ambiguous. With the `sender` and `receiver` aliases, we would have the two methods available and working: `mail.getSender()` and `mail.getReceiver()`, both of them returning a `Promise`. - -When defining an alias for a `hasOne` or `belongsTo` association, you should use the singular form of a word (such as `leader`, in the example above). On the other hand, when defining an alias for `hasMany` and `belongsToMany`, you should use the plural form. Defining aliases for Many-to-Many relationships (with `belongsToMany`) is covered in the [Advanced Many-to-Many Associations guide](advanced-many-to-many.html). - -### Doing both things - -We can define and alias and also directly define the foreign key: - -```js -Ship.belongsTo(Captain, { as: 'leader', foreignKey: 'bossId' }); // This creates the `bossId` foreign key in Ship. - -// Since an alias was defined, eager Loading doesn't work by simply passing the model to `include`: -console.log((await Ship.findAll({ include: Captain })).toJSON()); // Throws an error -// Instead, you have to pass the alias: -console.log((await Ship.findAll({ include: 'leader' })).toJSON()); -// Or you can pass an object specifying the model and alias: -console.log((await Ship.findAll({ - include: { - model: Captain, - as: 'leader' - } -})).toJSON()); - -// Also, instances obtain a `getLeader()` method for Lazy Loading: -const ship = Ship.findOne(); -console.log((await ship.getLeader()).toJSON()); -``` - -## Special methods/mixins added to instances - -When an association is defined between two models, the instances of those models gain special methods to interact with their associated counterparts. - -For example, if we have two models, `Foo` and `Bar`, and they are associated, their instances will have the following methods/mixins available, depending on the association type: - -### `Foo.hasOne(Bar)` - -* `fooInstance.getBar()` -* `fooInstance.setBar()` -* `fooInstance.createBar()` - -Example: - -```js -const foo = await Foo.create({ name: 'the-foo' }); -const bar1 = await Bar.create({ name: 'some-bar' }); -const bar2 = await Bar.create({ name: 'another-bar' }); -console.log(await foo.getBar()); // null -await foo.setBar(bar1); -console.log((await foo.getBar()).name); // 'some-bar' -await foo.createBar({ name: 'yet-another-bar' }); -const newlyAssociatedBar = await foo.getBar(); -console.log(newlyAssociatedBar.name); // 'yet-another-bar' -await foo.setBar(null); // Un-associate -console.log(await foo.getBar()); // null -``` - -### `Foo.belongsTo(Bar)` - -The same ones from `Foo.hasOne(Bar)`: - -* `fooInstance.getBar()` -* `fooInstance.setBar()` -* `fooInstance.createBar()` - -### `Foo.hasMany(Bar)` - -* `fooInstance.getBars()` -* `fooInstance.countBars()` -* `fooInstance.hasBar()` -* `fooInstance.hasBars()` -* `fooInstance.setBars()` -* `fooInstance.addBar()` -* `fooInstance.addBars()` -* `fooInstance.removeBar()` -* `fooInstance.removeBars()` -* `fooInstance.createBar()` - -Example: - -```js -const foo = await Foo.create({ name: 'the-foo' }); -const bar1 = await Bar.create({ name: 'some-bar' }); -const bar2 = await Bar.create({ name: 'another-bar' }); -console.log(await foo.getBars()); // [] -console.log(await foo.countBars()); // 0 -console.log(await foo.hasBar(bar1)); // false -await foo.addBars([bar1, bar2]); -console.log(await foo.countBars()); // 2 -await foo.addBar(bar1); -console.log(await foo.countBars()); // 2 -console.log(await foo.hasBar(bar1)); // true -await foo.removeBar(bar2); -console.log(await foo.countBars()); // 1 -await foo.createBar({ name: 'yet-another-bar' }); -console.log(await foo.countBars()); // 2 -await foo.setBars([]); // Un-associate all previously associated bars -console.log(await foo.countBars()); // 0 -``` - -The getter method accepts options just like the usual finder methods (such as `findAll`): - -```js -const easyTasks = await project.getTasks({ - where: { - difficulty: { - [Op.lte]: 5 - } - } -}); -const taskTitles = (await project.getTasks({ - attributes: ['title'], - raw: true -})).map(task => task.title); -``` - -### `Foo.belongsToMany(Bar, { through: Baz })` - -The same ones from `Foo.hasMany(Bar)`: - -* `fooInstance.getBars()` -* `fooInstance.countBars()` -* `fooInstance.hasBar()` -* `fooInstance.hasBars()` -* `fooInstance.setBars()` -* `fooInstance.addBar()` -* `fooInstance.addBars()` -* `fooInstance.removeBar()` -* `fooInstance.removeBars()` -* `fooInstance.createBar()` - -For belongsToMany relationships, by default `getBars()` will return all fields from the join table. Note that any `include` options will apply to the target `Bar` object, so trying to set options for the join table as you would when eager loading with `find` methods is not possible. To choose what attributes of the join table to include, `getBars()` supports a `joinTableAttributes` option that can be used similarly to setting `through.attributes` in an `include`. As an example, given Foo belongsToMany Bar, the following will both output results without join table fields: - -```js -const foo = Foo.findByPk(id, { - include: [{ - model: Bar, - through: { attributes: [] } - }] -}) -console.log(foo.bars) - -const foo = Foo.findByPk(id) -console.log(foo.getBars({ joinTableAttributes: [] })) -``` - -### Note: Method names - -As shown in the examples above, the names Sequelize gives to these special methods are formed by a prefix (e.g. `get`, `add`, `set`) concatenated with the model name (with the first letter in uppercase). When necessary, the plural is used, such as in `fooInstance.setBars()`. Again, irregular plurals are also handled automatically by Sequelize. For example, `Person` becomes `People` and `Hypothesis` becomes `Hypotheses`. - -If an alias was defined, it will be used instead of the model name to form the method names. For example: - -```js -Task.hasOne(User, { as: 'Author' }); -``` - -* `taskInstance.getAuthor()` -* `taskInstance.setAuthor()` -* `taskInstance.createAuthor()` - -## Why associations are defined in pairs? - -As mentioned earlier and shown in most examples above, usually associations in Sequelize are defined in pairs: - -* To create a **One-To-One** relationship, the `hasOne` and `belongsTo` associations are used together; -* To create a **One-To-Many** relationship, the `hasMany` and `belongsTo` associations are used together; -* To create a **Many-To-Many** relationship, two `belongsToMany` calls are used together. - -When a Sequelize association is defined between two models, only the *source* model *knows about it*. So, for example, when using `Foo.hasOne(Bar)` (so `Foo` is the source model and `Bar` is the target model), only `Foo` knows about the existence of this association. This is why in this case, as shown above, `Foo` instances gain the methods `getBar()`, `setBar()` and `createBar()`, while on the other hand `Bar` instances get nothing. - -Similarly, for `Foo.hasOne(Bar)`, since `Foo` knows about the relationship, we can perform eager loading as in `Foo.findOne({ include: Bar })`, but we can't do `Bar.findOne({ include: Foo })`. - -Therefore, to bring full power to Sequelize usage, we usually setup the relationship in pairs, so that both models get to *know about it*. - -Practical demonstration: - -* If we do not define the pair of associations, calling for example just `Foo.hasOne(Bar)`: - - ```js - // This works... - await Foo.findOne({ include: Bar }); - - // But this throws an error: - await Bar.findOne({ include: Foo }); - // SequelizeEagerLoadingError: foo is not associated to bar! - ``` - -* If we define the pair as recommended, i.e., both `Foo.hasOne(Bar)` and `Bar.belongsTo(Foo)`: - - ```js - // This works! - await Foo.findOne({ include: Bar }); - - // This also works! - await Bar.findOne({ include: Foo }); - ``` - -## Multiple associations involving the same models - -In Sequelize, it is possible to define multiple associations between the same models. You just have to define different aliases for them: - -```js -Team.hasOne(Game, { as: 'HomeTeam', foreignKey: 'homeTeamId' }); -Team.hasOne(Game, { as: 'AwayTeam', foreignKey: 'awayTeamId' }); -Game.belongsTo(Team); -``` - -## Creating associations referencing a field which is not the primary key - -In all the examples above, the associations were defined by referencing the primary keys of the involved models (in our case, their IDs). However, Sequelize allows you to define an association that uses another field, instead of the primary key field, to establish the association. - -This other field must have a unique constraint on it (otherwise, it wouldn't make sense). - -### For `belongsTo` relationships - -First, recall that the `A.belongsTo(B)` association places the foreign key in the *source model* (i.e., in `A`). - -Let's again use the example of Ships and Captains. Additionally, we will assume that Captain names are unique: - -```js -const Ship = sequelize.define('ship', { name: DataTypes.TEXT }, { timestamps: false }); -const Captain = sequelize.define('captain', { - name: { type: DataTypes.TEXT, unique: true } -}, { timestamps: false }); -``` - -This way, instead of keeping the `captainId` on our Ships, we could keep a `captainName` instead and use it as our association tracker. In other words, instead of referencing the `id` from the target model (Captain), our relationship will reference another column on the target model: the `name` column. To specify this, we have to define a *target key*. We will also have to specify a name for the foreign key itself: - -```js -Ship.belongsTo(Captain, { targetKey: 'name', foreignKey: 'captainName' }); -// This creates a foreign key called `captainName` in the source model (Ship) -// which references the `name` field from the target model (Captain). -``` - -Now we can do things like: - -```js -await Captain.create({ name: "Jack Sparrow" }); -const ship = await Ship.create({ name: "Black Pearl", captainName: "Jack Sparrow" }); -console.log((await ship.getCaptain()).name); // "Jack Sparrow" -``` - -### For `hasOne` and `hasMany` relationships - -The exact same idea can be applied to the `hasOne` and `hasMany` associations, but instead of providing a `targetKey`, we provide a `sourceKey` when defining the association. This is because unlike `belongsTo`, the `hasOne` and `hasMany` associations keep the foreign key on the target model: - -```js -const Foo = sequelize.define('foo', { - name: { type: DataTypes.TEXT, unique: true } -}, { timestamps: false }); -const Bar = sequelize.define('bar', { - title: { type: DataTypes.TEXT, unique: true } -}, { timestamps: false }); -const Baz = sequelize.define('baz', { summary: DataTypes.TEXT }, { timestamps: false }); -Foo.hasOne(Bar, { sourceKey: 'name', foreignKey: 'fooName' }); -Bar.hasMany(Baz, { sourceKey: 'title', foreignKey: 'barTitle' }); -// [...] -await Bar.setFoo("Foo's Name Here"); -await Baz.addBar("Bar's Title Here"); -``` - -### For `belongsToMany` relationships - -The same idea can also be applied to `belongsToMany` relationships. However, unlike the other situations, in which we have only one foreign key involved, the `belongsToMany` relationship involves two foreign keys which are kept on an extra table (the junction table). - -Consider the following setup: - -```js -const Foo = sequelize.define('foo', { - name: { type: DataTypes.TEXT, unique: true } -}, { timestamps: false }); -const Bar = sequelize.define('bar', { - title: { type: DataTypes.TEXT, unique: true } -}, { timestamps: false }); -``` - -There are four cases to consider: - -* We might want a many-to-many relationship using the default primary keys for both `Foo` and `Bar`: - -```js -Foo.belongsToMany(Bar, { through: 'foo_bar' }); -// This creates a junction table `foo_bar` with fields `fooId` and `barId` -``` - -* We might want a many-to-many relationship using the default primary key for `Foo` but a different field for `Bar`: - -```js -Foo.belongsToMany(Bar, { through: 'foo_bar', targetKey: 'title' }); -// This creates a junction table `foo_bar` with fields `fooId` and `barTitle` -``` - -* We might want a many-to-many relationship using the a different field for `Foo` and the default primary key for `Bar`: - -```js -Foo.belongsToMany(Bar, { through: 'foo_bar', sourceKey: 'name' }); -// This creates a junction table `foo_bar` with fields `fooName` and `barId` -``` - -* We might want a many-to-many relationship using different fields for both `Foo` and `Bar`: - -```js -Foo.belongsToMany(Bar, { through: 'foo_bar', sourceKey: 'name', targetKey: 'title' }); -// This creates a junction table `foo_bar` with fields `fooName` and `barTitle` -``` - -### Notes - -Don't forget that the field referenced in the association must have a unique constraint placed on it. Otherwise, an error will be thrown (and sometimes with a mysterious error message - such as `SequelizeDatabaseError: SQLITE_ERROR: foreign key mismatch - "ships" referencing "captains"` for SQLite). - -The trick to deciding between `sourceKey` and `targetKey` is just to remember where each relationship places its foreign key. As mentioned in the beginning of this guide: - -* `A.belongsTo(B)` keeps the foreign key in the source model (`A`), therefore the referenced key is in the target model, hence the usage of `targetKey`. - -* `A.hasOne(B)` and `A.hasMany(B)` keep the foreign key in the target model (`B`), therefore the referenced key is in the source model, hence the usage of `sourceKey`. - -* `A.belongsToMany(B)` involves an extra table (the junction table), therefore both `sourceKey` and `targetKey` are usable, with `sourceKey` corresponding to some field in `A` (the source) and `targetKey` corresponding to some field in `B` (the target). diff --git a/docs/manual/core-concepts/getters-setters-virtuals.md b/docs/manual/core-concepts/getters-setters-virtuals.md deleted file mode 100644 index 5940095eee02..000000000000 --- a/docs/manual/core-concepts/getters-setters-virtuals.md +++ /dev/null @@ -1,201 +0,0 @@ -# Getters, Setters & Virtuals - -Sequelize allows you to define custom getters and setters for the attributes of your models. - -Sequelize also allows you to specify the so-called *virtual attributes*, which are attributes on the Sequelize Model that doesn't really exist in the underlying SQL table, but instead are populated automatically by Sequelize. They are very useful to create custom attributes which also could simplify your code, for example. - -## Getters - -A getter is a `get()` function defined for one column in the model definition: - -```js -const User = sequelize.define('user', { - // Let's say we wanted to see every username in uppercase, even - // though they are not necessarily uppercase in the database itself - username: { - type: DataTypes.STRING, - get() { - const rawValue = this.getDataValue('username'); - return rawValue ? rawValue.toUpperCase() : null; - } - } -}); -``` - -This getter, just like a standard JavaScript getter, is called automatically when the field value is read: - -```js -const user = User.build({ username: 'SuperUser123' }); -console.log(user.username); // 'SUPERUSER123' -console.log(user.getDataValue('username')); // 'SuperUser123' -``` - -Note that, although `SUPERUSER123` was logged above, the value truly stored in the database is still `SuperUser123`. We used `this.getDataValue('username')` to obtain this value, and converted it to uppercase. - -Had we tried to use `this.username` in the getter instead, we would have gotten an infinite loop! This is why Sequelize provides the `getDataValue` method. - -## Setters - -A setter is a `set()` function defined for one column in the model definition. It receives the value being set: - -```js -const User = sequelize.define('user', { - username: DataTypes.STRING, - password: { - type: DataTypes.STRING, - set(value) { - // Storing passwords in plaintext in the database is terrible. - // Hashing the value with an appropriate cryptographic hash function is better. - this.setDataValue('password', hash(value)); - } - } -}); -``` - -```js -const user = User.build({ username: 'someone', password: 'NotSo§tr0ngP4$SW0RD!' }); -console.log(user.password); // '7cfc84b8ea898bb72462e78b4643cfccd77e9f05678ec2ce78754147ba947acc' -console.log(user.getDataValue('password')); // '7cfc84b8ea898bb72462e78b4643cfccd77e9f05678ec2ce78754147ba947acc' -``` - -Observe that Sequelize called the setter automatically, before even sending data to the database. The only data the database ever saw was the already hashed value. - -If we wanted to involve another field from our model instance in the computation, that is possible and very easy! - -```js -const User = sequelize.define('user', { - username: DataTypes.STRING, - password: { - type: DataTypes.STRING, - set(value) { - // Storing passwords in plaintext in the database is terrible. - // Hashing the value with an appropriate cryptographic hash function is better. - // Using the username as a salt is better. - this.setDataValue('password', hash(this.username + value)); - } - } -}); -``` - -**Note:** The above examples involving password handling, although much better than simply storing the password in plaintext, are far from perfect security. Handling passwords properly is hard, everything here is just for the sake of an example to show Sequelize functionality. We suggest involving a cybersecurity expert and/or reading [OWASP](https://www.owasp.org/) documents and/or visiting the [InfoSec StackExchange](https://security.stackexchange.com/). - -## Combining getters and setters - -Getters and setters can be both defined in the same field. - -For the sake of an example, let's say we are modeling a `Post`, whose `content` is a text of unlimited length. To improve memory usage, let's say we want to store a gzipped version of the content. - -*Note: modern databases should do some compression automatically in these cases. Please note that this is just for the sake of an example.* - -```js -const { gzipSync, gunzipSync } = require('zlib'); - -const Post = sequelize.define('post', { - content: { - type: DataTypes.TEXT, - get() { - const storedValue = this.getDataValue('content'); - const gzippedBuffer = Buffer.from(storedValue, 'base64'); - const unzippedBuffer = gunzipSync(gzippedBuffer); - return unzippedBuffer.toString(); - }, - set(value) { - const gzippedBuffer = gzipSync(value); - this.setDataValue('content', gzippedBuffer.toString('base64')); - } - } -}); -``` - -With the above setup, whenever we try to interact with the `content` field of our `Post` model, Sequelize will automatically handle the custom getter and setter. For example: - -```js -const post = await Post.create({ content: 'Hello everyone!' }); - -console.log(post.content); // 'Hello everyone!' -// Everything is happening under the hood, so we can even forget that the -// content is actually being stored as a gzipped base64 string! - -// However, if we are really curious, we can get the 'raw' data... -console.log(post.getDataValue('content')); -// Output: 'H4sIAAAAAAAACvNIzcnJV0gtSy2qzM9LVQQAUuk9jQ8AAAA=' -``` - -## Virtual fields - -Virtual fields are fields that Sequelize populates under the hood, but in reality they don't even exist in the database. - -For example, let's say we have the `firstName` and `lastName` attributes for a User. - -*Again, this is [only for the sake of an example](https://www.kalzumeus.com/2010/06/17/falsehoods-programmers-believe-about-names/).* - -It would be nice to have a simple way to obtain the *full name* directly! We can combine the idea of `getters` with the special data type Sequelize provides for this kind of situation: `DataTypes.VIRTUAL`: - -```js -const { DataTypes } = require("sequelize"); - -const User = sequelize.define('user', { - firstName: DataTypes.TEXT, - lastName: DataTypes.TEXT, - fullName: { - type: DataTypes.VIRTUAL, - get() { - return `${this.firstName} ${this.lastName}`; - }, - set(value) { - throw new Error('Do not try to set the `fullName` value!'); - } - } -}); -``` - -The `VIRTUAL` field does not cause a column in the table to exist. In other words, the model above will not have a `fullName` column. However, it will appear to have it! - -```js -const user = await User.create({ firstName: 'John', lastName: 'Doe' }); -console.log(user.fullName); // 'John Doe' -``` - -## Deprecated in Sequelize v7: `getterMethods` and `setterMethods` - -Sequelize also provides the `getterMethods` and `setterMethods` options in the model definition to specify things that look like, but aren't exactly the same as, virtual attributes. This usage is discouraged and likely to be **deprecated** in the future (in favor of using virtual attributes directly). - -Example: - -```js -const { Sequelize, DataTypes } = require('sequelize'); -const sequelize = new Sequelize('sqlite::memory:'); - -const User = sequelize.define('user', { - firstName: DataTypes.STRING, - lastName: DataTypes.STRING -}, { - getterMethods: { - fullName() { - return this.firstName + ' ' + this.lastName; - } - }, - setterMethods: { - fullName(value) { - // Note: this is just for demonstration. - // See: https://www.kalzumeus.com/2010/06/17/falsehoods-programmers-believe-about-names/ - const names = value.split(' '); - const firstName = names[0]; - const lastName = names.slice(1).join(' '); - this.setDataValue('firstName', firstName); - this.setDataValue('lastName', lastName); - } - } -}); - -(async () => { - await sequelize.sync(); - let user = await User.create({ firstName: 'John', lastName: 'Doe' }); - console.log(user.fullName); // 'John Doe' - user.fullName = 'Someone Else'; - await user.save(); - user = await User.findOne(); - console.log(user.firstName); // 'Someone' - console.log(user.lastName); // 'Else' -})(); -``` diff --git a/docs/manual/core-concepts/getting-started.md b/docs/manual/core-concepts/getting-started.md deleted file mode 100644 index 94bd14933049..000000000000 --- a/docs/manual/core-concepts/getting-started.md +++ /dev/null @@ -1,111 +0,0 @@ -# Getting Started - -In this tutorial you will learn to make a simple setup of Sequelize. - -## Installing - -Sequelize is available via [npm](https://www.npmjs.com/package/sequelize) (or [yarn](https://yarnpkg.com/package/sequelize)). - -```sh -npm install --save sequelize -``` - -You'll also have to manually install the driver for your database of choice: - -```sh -# One of the following: -$ npm install --save pg pg-hstore # Postgres -$ npm install --save mysql2 -$ npm install --save mariadb -$ npm install --save sqlite3 -$ npm install --save tedious # Microsoft SQL Server -``` - -## Connecting to a database - -To connect to the database, you must create a Sequelize instance. This can be done by either passing the connection parameters separately to the Sequelize constructor or by passing a single connection URI: - -```js -const { Sequelize } = require('sequelize'); - -// Option 1: Passing a connection URI -const sequelize = new Sequelize('sqlite::memory:') // Example for sqlite -const sequelize = new Sequelize('postgres://user:pass@example.com:5432/dbname') // Example for postgres - -// Option 2: Passing parameters separately (sqlite) -const sequelize = new Sequelize({ - dialect: 'sqlite', - storage: 'path/to/database.sqlite' -}); - -// Option 3: Passing parameters separately (other dialects) -const sequelize = new Sequelize('database', 'username', 'password', { - host: 'localhost', - dialect: /* one of 'mysql' | 'mariadb' | 'postgres' | 'mssql' */ -}); -``` - -The Sequelize constructor accepts a lot of options. They are documented in the [API Reference](../class/lib/sequelize.js~Sequelize.html#instance-constructor-constructor). - -### Testing the connection - -You can use the `.authenticate()` function to test if the connection is OK: - -```js -try { - await sequelize.authenticate(); - console.log('Connection has been established successfully.'); -} catch (error) { - console.error('Unable to connect to the database:', error); -} -``` - -### Closing the connection - -Sequelize will keep the connection open by default, and use the same connection for all queries. If you need to close the connection, call `sequelize.close()` (which is asynchronous and returns a Promise). - -## Terminology convention - -Observe that, in the examples above, `Sequelize` refers to the library itself while `sequelize` refers to an instance of Sequelize, which represents a connection to one database. This is the recommended convention and it will be followed throughout the documentation. - -## Tip for reading the docs - -You are encouraged to run code examples locally while reading the Sequelize docs. This will help you learn faster. The easiest way to do this is using the SQLite dialect: - -```js -const { Sequelize, Op, Model, DataTypes } = require("sequelize"); -const sequelize = new Sequelize("sqlite::memory:"); - -// Code here! It works! -``` - -To experiment with the other dialects, which are harder to setup locally, you can use the [Sequelize SSCCE](https://github.com/papb/sequelize-sscce) GitHub repository, which allows you to run code on all supported dialects directly from GitHub, for free, without any setup! - -## New databases versus existing databases - -If you are starting a project from scratch, and your database is still empty, Sequelize can be used since the beginning in order to automate the creation of every table in your database. - -Also, if you want to use Sequelize to connect to a database that is already filled with tables and data, that works as well! Sequelize has got you covered in both cases. - -## Logging - -By default, Sequelize will log to console every SQL query it performs. The `options.logging` option can be used to customize this behavior, by defining the function that gets executed every time Sequelize would log something. The default value is `console.log` and when using that only the first log parameter of log function call is displayed. For example, for query logging the first parameter is the raw query and the second (hidden by default) is the Sequelize object. - -Common useful values for `options.logging`: - -```js -const sequelize = new Sequelize('sqlite::memory:', { - // Choose one of the logging options - logging: console.log, // Default, displays the first parameter of the log function call - logging: (...msg) => console.log(msg), // Displays all log function call parameters - logging: false, // Disables logging - logging: msg => logger.debug(msg), // Use custom logger (e.g. Winston or Bunyan), displays the first parameter - logging: logger.debug.bind(logger) // Alternative way to use custom logger, displays all messages -}); -``` - -## Promises and async/await - -Most of the methods provided by Sequelize are asynchronous and therefore return Promises. They are all [Promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) , so you can use the Promise API (for example, using `then`, `catch`, `finally`) out of the box. - -Of course, using `async` and `await` works normally as well. diff --git a/docs/manual/core-concepts/model-basics.md b/docs/manual/core-concepts/model-basics.md deleted file mode 100644 index 487ce33a397e..000000000000 --- a/docs/manual/core-concepts/model-basics.md +++ /dev/null @@ -1,500 +0,0 @@ -# Model Basics - -In this tutorial you will learn what models are in Sequelize and how to use them. - -## Concept - -Models are the essence of Sequelize. A model is an abstraction that represents a table in your database. In Sequelize, it is a class that extends [Model](../class/lib/model.js~Model.html). - -The model tells Sequelize several things about the entity it represents, such as the name of the table in the database and which columns it has (and their data types). - -A model in Sequelize has a name. This name does not have to be the same name of the table it represents in the database. Usually, models have singular names (such as `User`) while tables have pluralized names (such as `Users`), although this is fully configurable. - -## Model Definition - -Models can be defined in two equivalent ways in Sequelize: - -* Calling [`sequelize.define(modelName, attributes, options)`](../class/lib/sequelize.js~Sequelize.html#instance-method-define) -* Extending [Model](../class/lib/model.js~Model.html) and calling [`init(attributes, options)`](../class/lib/model.js~Model.html#static-method-init) - -After a model is defined, it is available within `sequelize.models` by its model name. - -To learn with an example, we will consider that we want to create a model to represent users, which have a `firstName` and a `lastName`. We want our model to be called `User`, and the table it represents is called `Users` in the database. - -Both ways to define this model are shown below. After being defined, we can access our model with `sequelize.models.User`. - -### Using [`sequelize.define`](../class/lib/sequelize.js~Sequelize.html#instance-method-define): - -```js -const { Sequelize, DataTypes } = require('sequelize'); -const sequelize = new Sequelize('sqlite::memory:'); - -const User = sequelize.define('User', { - // Model attributes are defined here - firstName: { - type: DataTypes.STRING, - allowNull: false - }, - lastName: { - type: DataTypes.STRING - // allowNull defaults to true - } -}, { - // Other model options go here -}); - -// `sequelize.define` also returns the model -console.log(User === sequelize.models.User); // true -``` - -### Extending [Model](../class/lib/model.js~Model.html) - -```js -const { Sequelize, DataTypes, Model } = require('sequelize'); -const sequelize = new Sequelize('sqlite::memory:'); - -class User extends Model {} - -User.init({ - // Model attributes are defined here - firstName: { - type: DataTypes.STRING, - allowNull: false - }, - lastName: { - type: DataTypes.STRING - // allowNull defaults to true - } -}, { - // Other model options go here - sequelize, // We need to pass the connection instance - modelName: 'User' // We need to choose the model name -}); - -// the defined model is the class itself -console.log(User === sequelize.models.User); // true -``` - -Internally, `sequelize.define` calls `Model.init`, so both approaches are essentially equivalent. - -#### Caveat with Public Class Fields - -Adding a [Public Class Field](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/Public_class_fields) with the same name as one of the model's attribute is going to cause issues. -Sequelize adds a getter & a setter for each attribute defined through `Model.init`. -Adding a Public Class Field will shadow those getter and setters, blocking access to the model's actual data. - -```typescript -// Invalid -class User extends Model { - id; // this field will shadow sequelize's getter & setter. It should be removed. - otherPublicField; // this field does not shadow anything. It is fine. -} - -User.init({ - id: { - type: DataTypes.INTEGER, - autoIncrement: true, - primaryKey: true - } -}, { sequelize }); - -const user = new User({ id: 1 }); -user.id; // undefined -``` - -```typescript -// Valid -class User extends Model { - otherPublicField; -} - -User.init({ - id: { - type: DataTypes.INTEGER, - autoIncrement: true, - primaryKey: true - } -}, { sequelize }); - -const user = new User({ id: 1 }); -user.id; // 1 -``` - -In TypeScript, you can add typing information without adding an actual public class field by using the `declare` keyword: - -```typescript -// Valid -class User extends Model { - declare id: number; // this is ok! The 'declare' keyword ensures this field will not be emitted by TypeScript. -} - -User.init({ - id: { - type: DataTypes.INTEGER, - autoIncrement: true, - primaryKey: true - } -}, { sequelize }); - -const user = new User({ id: 1 }); -user.id; // 1 -``` - -## Table name inference - -Observe that, in both methods above, the table name (`Users`) was never explicitly defined. However, the model name was given (`User`). - -By default, when the table name is not given, Sequelize automatically pluralizes the model name and uses that as the table name. This pluralization is done under the hood by a library called [inflection](https://www.npmjs.com/package/inflection), so that irregular plurals (such as `person -> people`) are computed correctly. - -Of course, this behavior is easily configurable. - -### Enforcing the table name to be equal to the model name - -You can stop the auto-pluralization performed by Sequelize using the `freezeTableName: true` option. This way, Sequelize will infer the table name to be equal to the model name, without any modifications: - -```js -sequelize.define('User', { - // ... (attributes) -}, { - freezeTableName: true -}); -``` - -The example above will create a model named `User` pointing to a table also named `User`. - -This behavior can also be defined globally for the sequelize instance, when it is created: - -```js -const sequelize = new Sequelize('sqlite::memory:', { - define: { - freezeTableName: true - } -}); -``` - -This way, all tables will use the same name as the model name. - -### Providing the table name directly - -You can simply tell Sequelize the name of the table directly as well: - -```js -sequelize.define('User', { - // ... (attributes) -}, { - tableName: 'Employees' -}); -``` - -## Model synchronization - -When you define a model, you're telling Sequelize a few things about its table in the database. However, what if the table actually doesn't even exist in the database? What if it exists, but it has different columns, less columns, or any other difference? - -This is where model synchronization comes in. A model can be synchronized with the database by calling [`model.sync(options)`](https://sequelize.org/master/class/lib/model.js~Model.html#static-method-sync), an asynchronous function (that returns a Promise). With this call, Sequelize will automatically perform an SQL query to the database. Note that this changes only the table in the database, not the model in the JavaScript side. - -* `User.sync()` - This creates the table if it doesn't exist (and does nothing if it already exists) -* `User.sync({ force: true })` - This creates the table, dropping it first if it already existed -* `User.sync({ alter: true })` - This checks what is the current state of the table in the database (which columns it has, what are their data types, etc), and then performs the necessary changes in the table to make it match the model. - -Example: - -```js -await User.sync({ force: true }); -console.log("The table for the User model was just (re)created!"); -``` - -### Synchronizing all models at once - -You can use [`sequelize.sync()`](../class/lib/sequelize.js~Sequelize.html#instance-method-sync) to automatically synchronize all models. Example: - -```js -await sequelize.sync({ force: true }); -console.log("All models were synchronized successfully."); -``` - -### Dropping tables - -To drop the table related to a model: - -```js -await User.drop(); -console.log("User table dropped!"); -``` - -To drop all tables: - -```js -await sequelize.drop(); -console.log("All tables dropped!"); -``` - -### Database safety check - -As shown above, the `sync` and `drop` operations are destructive. Sequelize accepts a `match` option as an additional safety check, which receives a RegExp: - -```js -// This will run .sync() only if database name ends with '_test' -sequelize.sync({ force: true, match: /_test$/ }); -``` - -### Synchronization in production - -As shown above, `sync({ force: true })` and `sync({ alter: true })` can be destructive operations. Therefore, they are not recommended for production-level software. Instead, synchronization should be done with the advanced concept of [Migrations](migrations.html), with the help of the [Sequelize CLI](https://github.com/sequelize/cli). - -## Timestamps - -By default, Sequelize automatically adds the fields `createdAt` and `updatedAt` to every model, using the data type `DataTypes.DATE`. Those fields are automatically managed as well - whenever you use Sequelize to create or update something, those fields will be set correctly. The `createdAt` field will contain the timestamp representing the moment of creation, and the `updatedAt` will contain the timestamp of the latest update. - -**Note:** This is done in the Sequelize level (i.e. not done with *SQL triggers*). This means that direct SQL queries (for example queries performed without Sequelize by any other means) will not cause these fields to be updated automatically. - -This behavior can be disabled for a model with the `timestamps: false` option: - -```js -sequelize.define('User', { - // ... (attributes) -}, { - timestamps: false -}); -``` - -It is also possible to enable only one of `createdAt`/`updatedAt`, and to provide a custom name for these columns: - -```js -class Foo extends Model {} -Foo.init({ /* attributes */ }, { - sequelize, - - // don't forget to enable timestamps! - timestamps: true, - - // I don't want createdAt - createdAt: false, - - // I want updatedAt to actually be called updateTimestamp - updatedAt: 'updateTimestamp' -}); -``` - -## Column declaration shorthand syntax - -If the only thing being specified about a column is its data type, the syntax can be shortened: - -```js -// This: -sequelize.define('User', { - name: { - type: DataTypes.STRING - } -}); - -// Can be simplified to: -sequelize.define('User', { name: DataTypes.STRING }); -``` - -## Default Values - -By default, Sequelize assumes that the default value of a column is `NULL`. This behavior can be changed by passing a specific `defaultValue` to the column definition: - -```js -sequelize.define('User', { - name: { - type: DataTypes.STRING, - defaultValue: "John Doe" - } -}); -``` - -Some special values, such as `DataTypes.NOW`, are also accepted: - -```js -sequelize.define('Foo', { - bar: { - type: DataTypes.DATETIME, - defaultValue: DataTypes.NOW - // This way, the current date/time will be used to populate this column (at the moment of insertion) - } -}); -``` - -## Data Types - -Every column you define in your model must have a data type. Sequelize provides [a lot of built-in data types](https://github.com/sequelize/sequelize/blob/main/lib/data-types.js). To access a built-in data type, you must import `DataTypes`: - -```js -const { DataTypes } = require("sequelize"); // Import the built-in data types -``` - -### Strings - -```js -DataTypes.STRING // VARCHAR(255) -DataTypes.STRING(1234) // VARCHAR(1234) -DataTypes.STRING.BINARY // VARCHAR BINARY -DataTypes.TEXT // TEXT -DataTypes.TEXT('tiny') // TINYTEXT -DataTypes.CITEXT // CITEXT PostgreSQL and SQLite only. -DataTypes.TSVECTOR // TSVECTOR PostgreSQL only. -``` - -### Boolean - -```js -DataTypes.BOOLEAN // TINYINT(1) -``` - -### Numbers - -```js -DataTypes.INTEGER // INTEGER -DataTypes.BIGINT // BIGINT -DataTypes.BIGINT(11) // BIGINT(11) - -DataTypes.FLOAT // FLOAT -DataTypes.FLOAT(11) // FLOAT(11) -DataTypes.FLOAT(11, 10) // FLOAT(11,10) - -DataTypes.REAL // REAL PostgreSQL only. -DataTypes.REAL(11) // REAL(11) PostgreSQL only. -DataTypes.REAL(11, 12) // REAL(11,12) PostgreSQL only. - -DataTypes.DOUBLE // DOUBLE -DataTypes.DOUBLE(11) // DOUBLE(11) -DataTypes.DOUBLE(11, 10) // DOUBLE(11,10) - -DataTypes.DECIMAL // DECIMAL -DataTypes.DECIMAL(10, 2) // DECIMAL(10,2) -``` - -#### Unsigned & Zerofill integers - MySQL/MariaDB only - -In MySQL and MariaDB, the data types `INTEGER`, `BIGINT`, `FLOAT` and `DOUBLE` can be set as unsigned or zerofill (or both), as follows: - -```js -DataTypes.INTEGER.UNSIGNED -DataTypes.INTEGER.ZEROFILL -DataTypes.INTEGER.UNSIGNED.ZEROFILL -// You can also specify the size i.e. INTEGER(10) instead of simply INTEGER -// Same for BIGINT, FLOAT and DOUBLE -``` - -### Dates - -```js -DataTypes.DATE // DATETIME for mysql / sqlite, TIMESTAMP WITH TIME ZONE for postgres -DataTypes.DATE(6) // DATETIME(6) for mysql 5.6.4+. Fractional seconds support with up to 6 digits of precision -DataTypes.DATEONLY // DATE without time -``` - -### UUIDs - -For UUIDs, use `DataTypes.UUID`. It becomes the `UUID` data type for PostgreSQL and SQLite, and `CHAR(36)` for MySQL. Sequelize can generate UUIDs automatically for these fields, simply use `DataTypes.UUIDV1` or `DataTypes.UUIDV4` as the default value: - -```js -{ - type: DataTypes.UUID, - defaultValue: DataTypes.UUIDV4 // Or DataTypes.UUIDV1 -} -``` - -### Others - -There are other data types, covered in a [separate guide](other-data-types.html). - -## Column Options - -When defining a column, apart from specifying the `type` of the column, and the `allowNull` and `defaultValue` options mentioned above, there are a lot more options that can be used. Some examples are below. - -```js -const { Model, DataTypes, Deferrable } = require("sequelize"); - -class Foo extends Model {} -Foo.init({ - // instantiating will automatically set the flag to true if not set - flag: { type: DataTypes.BOOLEAN, allowNull: false, defaultValue: true }, - - // default values for dates => current time - myDate: { type: DataTypes.DATE, defaultValue: DataTypes.NOW }, - - // setting allowNull to false will add NOT NULL to the column, which means an error will be - // thrown from the DB when the query is executed if the column is null. If you want to check that a value - // is not null before querying the DB, look at the validations section below. - title: { type: DataTypes.STRING, allowNull: false }, - - // Creating two objects with the same value will throw an error. The unique property can be either a - // boolean, or a string. If you provide the same string for multiple columns, they will form a - // composite unique key. - uniqueOne: { type: DataTypes.STRING, unique: 'compositeIndex' }, - uniqueTwo: { type: DataTypes.INTEGER, unique: 'compositeIndex' }, - - // The unique property is simply a shorthand to create a unique constraint. - someUnique: { type: DataTypes.STRING, unique: true }, - - // Go on reading for further information about primary keys - identifier: { type: DataTypes.STRING, primaryKey: true }, - - // autoIncrement can be used to create auto_incrementing integer columns - incrementMe: { type: DataTypes.INTEGER, autoIncrement: true }, - - // You can specify a custom column name via the 'field' attribute: - fieldWithUnderscores: { type: DataTypes.STRING, field: 'field_with_underscores' }, - - // It is possible to create foreign keys: - bar_id: { - type: DataTypes.INTEGER, - - references: { - // This is a reference to another model - model: Bar, - - // This is the column name of the referenced model - key: 'id', - - // With PostgreSQL, it is optionally possible to declare when to check the foreign key constraint, passing the Deferrable type. - deferrable: Deferrable.INITIALLY_IMMEDIATE - // Options: - // - `Deferrable.INITIALLY_IMMEDIATE` - Immediately check the foreign key constraints - // - `Deferrable.INITIALLY_DEFERRED` - Defer all foreign key constraint check to the end of a transaction - // - `Deferrable.NOT` - Don't defer the checks at all (default) - This won't allow you to dynamically change the rule in a transaction - } - }, - - // Comments can only be added to columns in MySQL, MariaDB, PostgreSQL and MSSQL - commentMe: { - type: DataTypes.INTEGER, - comment: 'This is a column name that has a comment' - } -}, { - sequelize, - modelName: 'foo', - - // Using `unique: true` in an attribute above is exactly the same as creating the index in the model's options: - indexes: [{ unique: true, fields: ['someUnique'] }] -}); -``` - -## Taking advantage of Models being classes - -The Sequelize models are [ES6 classes](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes). You can very easily add custom instance or class level methods. - -```js -class User extends Model { - static classLevelMethod() { - return 'foo'; - } - instanceLevelMethod() { - return 'bar'; - } - getFullname() { - return [this.firstname, this.lastname].join(' '); - } -} -User.init({ - firstname: Sequelize.TEXT, - lastname: Sequelize.TEXT -}, { sequelize }); - -console.log(User.classLevelMethod()); // 'foo' -const user = User.build({ firstname: 'Jane', lastname: 'Doe' }); -console.log(user.instanceLevelMethod()); // 'bar' -console.log(user.getFullname()); // 'Jane Doe' -``` diff --git a/docs/manual/core-concepts/model-instances.md b/docs/manual/core-concepts/model-instances.md deleted file mode 100644 index 8c47810ddffb..000000000000 --- a/docs/manual/core-concepts/model-instances.md +++ /dev/null @@ -1,197 +0,0 @@ -# Model Instances - -As you already know, a model is an [ES6 class](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes). An instance of the class represents one object from that model (which maps to one row of the table in the database). This way, model instances are [DAOs](https://en.wikipedia.org/wiki/Data_access_object). - -For this guide, the following setup will be assumed: - -```js -const { Sequelize, Model, DataTypes } = require("sequelize"); -const sequelize = new Sequelize("sqlite::memory:"); - -const User = sequelize.define("user", { - name: DataTypes.TEXT, - favoriteColor: { - type: DataTypes.TEXT, - defaultValue: 'green' - }, - age: DataTypes.INTEGER, - cash: DataTypes.INTEGER -}); - -(async () => { - await sequelize.sync({ force: true }); - // Code here -})(); -``` - -## Creating an instance - -Although a model is a class, you should not create instances by using the `new` operator directly. Instead, the [`build`](../class/lib/model.js~Model.html#static-method-build) method should be used: - -```js -const jane = User.build({ name: "Jane" }); -console.log(jane instanceof User); // true -console.log(jane.name); // "Jane" -``` - -However, the code above does not communicate with the database at all (note that it is not even asynchronous)! This is because the [`build`](../class/lib/model.js~Model.html#static-method-build) method only creates an object that *represents* data that *can* be mapped to a database. In order to really save (i.e. persist) this instance in the database, the [`save`](../class/lib/model.js~Model.html#instance-method-save) method should be used: - -```js -await jane.save(); -console.log('Jane was saved to the database!'); -``` - -Note, from the usage of `await` in the snippet above, that `save` is an asynchronous method. In fact, almost every Sequelize method is asynchronous; `build` is one of the very few exceptions. - -### A very useful shortcut: the `create` method - -Sequelize provides the [`create`](../class/lib/model.js~Model.html#static-method-create) method, which combines the `build` and `save` methods shown above into a single method: - -```js -const jane = await User.create({ name: "Jane" }); -// Jane exists in the database now! -console.log(jane instanceof User); // true -console.log(jane.name); // "Jane" -``` - -## Note: logging instances - -Trying to log a model instance directly to `console.log` will produce a lot of clutter, since Sequelize instances have a lot of things attached to them. Instead, you can use the `.toJSON()` method (which, by the way, automatically guarantees the instances to be `JSON.stringify`-ed well). - -```js -const jane = await User.create({ name: "Jane" }); -// console.log(jane); // Don't do this -console.log(jane.toJSON()); // This is good! -console.log(JSON.stringify(jane, null, 4)); // This is also good! -``` - -## Default values - -Built instances will automatically get default values: - -```js -const jane = User.build({ name: "Jane" }); -console.log(jane.favoriteColor); // "green" -``` - -## Updating an instance - -If you change the value of some field of an instance, calling `save` again will update it accordingly: - -```js -const jane = await User.create({ name: "Jane" }); -console.log(jane.name); // "Jane" -jane.name = "Ada"; -// the name is still "Jane" in the database -await jane.save(); -// Now the name was updated to "Ada" in the database! -``` - -You can update several fields at once with the [`set`](../class/lib/model.js~Model.html#instance-method-set) method: - -```js -const jane = await User.create({ name: "Jane" }); - -jane.set({ - name: "Ada", - favoriteColor: "blue" -}); -// As above, the database still has "Jane" and "green" -await jane.save(); -// The database now has "Ada" and "blue" for name and favorite color -``` - -Note that the `save()` here will also persist any other changes that have been made on this instance, not just those in the previous `set` call. If you want to update a specific set of fields, you can use [`update`](../class/lib/model.js~Model.html#instance-method-update): - -```js -const jane = await User.create({ name: "Jane" }); -jane.favoriteColor = "blue" -await jane.update({ name: "Ada" }) -// The database now has "Ada" for name, but still has the default "green" for favorite color -await jane.save() -// Now the database has "Ada" for name and "blue" for favorite color -``` - -## Deleting an instance - -You can delete an instance by calling [`destroy`](../class/lib/model.js~Model.html#instance-method-destroy): - -```js -const jane = await User.create({ name: "Jane" }); -console.log(jane.name); // "Jane" -await jane.destroy(); -// Now this entry was removed from the database -``` - -## Reloading an instance - -You can reload an instance from the database by calling [`reload`](../class/lib/model.js~Model.html#instance-method-reload): - -```js -const jane = await User.create({ name: "Jane" }); -console.log(jane.name); // "Jane" -jane.name = "Ada"; -// the name is still "Jane" in the database -await jane.reload(); -console.log(jane.name); // "Jane" -``` - -The reload call generates a `SELECT` query to get the up-to-date data from the database. - -## Saving only some fields - -It is possible to define which attributes should be saved when calling `save`, by passing an array of column names. - -This is useful when you set attributes based on a previously defined object, for example, when you get the values of an object via a form of a web app. Furthermore, this is used internally in the `update` implementation. This is how it looks like: - -```js -const jane = await User.create({ name: "Jane" }); -console.log(jane.name); // "Jane" -console.log(jane.favoriteColor); // "green" -jane.name = "Jane II"; -jane.favoriteColor = "blue"; -await jane.save({ fields: ['name'] }); -console.log(jane.name); // "Jane II" -console.log(jane.favoriteColor); // "blue" -// The above printed blue because the local object has it set to blue, but -// in the database it is still "green": -await jane.reload(); -console.log(jane.name); // "Jane II" -console.log(jane.favoriteColor); // "green" -``` - -## Change-awareness of save - -The `save` method is optimized internally to only update fields that really changed. This means that if you don't change anything and call `save`, Sequelize will know that the save is superfluous and do nothing, i.e., no query will be generated (it will still return a Promise, but it will resolve immediately). - -Also, if only a few attributes have changed when you call `save`, only those fields will be sent in the `UPDATE` query, to improve performance. - -## Incrementing and decrementing integer values - -In order to increment/decrement values of an instance without running into concurrency issues, Sequelize provides the [`increment`](../class/lib/model.js~Model.html#instance-method-increment) and [`decrement`](../class/lib/model.js~Model.html#instance-method-decrement) instance methods. - -```js -const jane = await User.create({ name: "Jane", age: 100 }); -const incrementResult = await jane.increment('age', { by: 2 }); -// Note: to increment by 1 you can omit the `by` option and just do `user.increment('age')` - -// In PostgreSQL, `incrementResult` will be the updated user, unless the option -// `{ returning: false }` was set (and then it will be undefined). - -// In other dialects, `incrementResult` will be undefined. If you need the updated instance, you will have to call `user.reload()`. -``` - -You can also increment multiple fields at once: - -```js -const jane = await User.create({ name: "Jane", age: 100, cash: 5000 }); -await jane.increment({ - 'age': 2, - 'cash': 100 -}); - -// If the values are incremented by the same amount, you can use this other syntax as well: -await jane.increment(['age', 'cash'], { by: 2 }); -``` - -Decrementing works in the exact same way. diff --git a/docs/manual/core-concepts/model-querying-basics.md b/docs/manual/core-concepts/model-querying-basics.md deleted file mode 100644 index 91a890208982..000000000000 --- a/docs/manual/core-concepts/model-querying-basics.md +++ /dev/null @@ -1,712 +0,0 @@ -# Model Querying - Basics - -Sequelize provides various methods to assist querying your database for data. - -*Important notice: to perform production-ready queries with Sequelize, make sure you have read the [Transactions guide](transactions.html) as well. Transactions are important to ensure data integrity and to provide other benefits.* - -This guide will show how to make the standard [CRUD](https://en.wikipedia.org/wiki/Create,_read,_update_and_delete) queries. - -## Simple INSERT queries - -First, a simple example: - -```js -// Create a new user -const jane = await User.create({ firstName: "Jane", lastName: "Doe" }); -console.log("Jane's auto-generated ID:", jane.id); -``` - -The [`Model.create()`](../class/lib/model.js~Model.html#static-method-create) method is a shorthand for building an unsaved instance with [`Model.build()`](../class/lib/model.js~Model.html#static-method-build) and saving the instance with [`instance.save()`](../class/lib/model.js~Model.html#instance-method-save). - -It is also possible to define which attributes can be set in the `create` method. This can be especially useful if you create database entries based on a form which can be filled by a user. Using that would, for example, allow you to restrict the `User` model to set only an username but not an admin flag (i.e., `isAdmin`): - -```js -const user = await User.create({ - username: 'alice123', - isAdmin: true -}, { fields: ['username'] }); -// let's assume the default of isAdmin is false -console.log(user.username); // 'alice123' -console.log(user.isAdmin); // false -``` - -## Simple SELECT queries - -You can read the whole table from the database with the [`findAll`](../class/lib/model.js~Model.html#static-method-findAll) method: - -```js -// Find all users -const users = await User.findAll(); -console.log(users.every(user => user instanceof User)); // true -console.log("All users:", JSON.stringify(users, null, 2)); -``` - -```sql -SELECT * FROM ... -``` - -## Specifying attributes for SELECT queries - -To select only some attributes, you can use the `attributes` option: - -```js -Model.findAll({ - attributes: ['foo', 'bar'] -}); -``` - -```sql -SELECT foo, bar FROM ... -``` - -Attributes can be renamed using a nested array: - -```js -Model.findAll({ - attributes: ['foo', ['bar', 'baz'], 'qux'] -}); -``` - -```sql -SELECT foo, bar AS baz, qux FROM ... -``` - -You can use [`sequelize.fn`](../class/lib/sequelize.js~Sequelize.html#static-method-fn) to do aggregations: - -```js -Model.findAll({ - attributes: [ - 'foo', - [sequelize.fn('COUNT', sequelize.col('hats')), 'n_hats'], - 'bar' - ] -}); -``` - -```sql -SELECT foo, COUNT(hats) AS n_hats, bar FROM ... -``` - -When using aggregation function, you must give it an alias to be able to access it from the model. In the example above you can get the number of hats with `instance.n_hats`. - -Sometimes it may be tiresome to list all the attributes of the model if you only want to add an aggregation: - -```js -// This is a tiresome way of getting the number of hats (along with every column) -Model.findAll({ - attributes: [ - 'id', 'foo', 'bar', 'baz', 'qux', 'hats', // We had to list all attributes... - [sequelize.fn('COUNT', sequelize.col('hats')), 'n_hats'] // To add the aggregation... - ] -}); - -// This is shorter, and less error prone because it still works if you add / remove attributes from your model later -Model.findAll({ - attributes: { - include: [ - [sequelize.fn('COUNT', sequelize.col('hats')), 'n_hats'] - ] - } -}); -``` - -```sql -SELECT id, foo, bar, baz, qux, hats, COUNT(hats) AS n_hats FROM ... -``` - -Similarly, it's also possible to remove a selected few attributes: - -```js -Model.findAll({ - attributes: { exclude: ['baz'] } -}); -``` - -```sql --- Assuming all columns are 'id', 'foo', 'bar', 'baz' and 'qux' -SELECT id, foo, bar, qux FROM ... -``` - -## Applying WHERE clauses - -The `where` option is used to filter the query. There are lots of operators to use for the `where` clause, available as Symbols from [`Op`](../variable/index.html#static-variable-Op). - -### The basics - -```js -Post.findAll({ - where: { - authorId: 2 - } -}); -// SELECT * FROM post WHERE authorId = 2; -``` - -Observe that no operator (from `Op`) was explicitly passed, so Sequelize assumed an equality comparison by default. The above code is equivalent to: - -```js -const { Op } = require("sequelize"); -Post.findAll({ - where: { - authorId: { - [Op.eq]: 2 - } - } -}); -// SELECT * FROM post WHERE authorId = 2; -``` - -Multiple checks can be passed: - -```js -Post.findAll({ - where: { - authorId: 12, - status: 'active' - } -}); -// SELECT * FROM post WHERE authorId = 12 AND status = 'active'; -``` - -Just like Sequelize inferred the `Op.eq` operator in the first example, here Sequelize inferred that the caller wanted an `AND` for the two checks. The code above is equivalent to: - -```js -const { Op } = require("sequelize"); -Post.findAll({ - where: { - [Op.and]: [ - { authorId: 12 }, - { status: 'active' } - ] - } -}); -// SELECT * FROM post WHERE authorId = 12 AND status = 'active'; -``` - -An `OR` can be easily performed in a similar way: - -```js -const { Op } = require("sequelize"); -Post.findAll({ - where: { - [Op.or]: [ - { authorId: 12 }, - { authorId: 13 } - ] - } -}); -// SELECT * FROM post WHERE authorId = 12 OR authorId = 13; -``` - -Since the above was an `OR` involving the same field, Sequelize allows you to use a slightly different structure which is more readable and generates the same behavior: - -```js -const { Op } = require("sequelize"); -Post.destroy({ - where: { - authorId: { - [Op.or]: [12, 13] - } - } -}); -// DELETE FROM post WHERE authorId = 12 OR authorId = 13; -``` - -### Operators - -Sequelize provides several operators. - -```js -const { Op } = require("sequelize"); -Post.findAll({ - where: { - [Op.and]: [{ a: 5 }, { b: 6 }], // (a = 5) AND (b = 6) - [Op.or]: [{ a: 5 }, { b: 6 }], // (a = 5) OR (b = 6) - someAttribute: { - // Basics - [Op.eq]: 3, // = 3 - [Op.ne]: 20, // != 20 - [Op.is]: null, // IS NULL - [Op.not]: true, // IS NOT TRUE - [Op.or]: [5, 6], // (someAttribute = 5) OR (someAttribute = 6) - - // Using dialect specific column identifiers (PG in the following example): - [Op.col]: 'user.organization_id', // = "user"."organization_id" - - // Number comparisons - [Op.gt]: 6, // > 6 - [Op.gte]: 6, // >= 6 - [Op.lt]: 10, // < 10 - [Op.lte]: 10, // <= 10 - [Op.between]: [6, 10], // BETWEEN 6 AND 10 - [Op.notBetween]: [11, 15], // NOT BETWEEN 11 AND 15 - - // Other operators - - [Op.all]: sequelize.literal('SELECT 1'), // > ALL (SELECT 1) - - [Op.in]: [1, 2], // IN [1, 2] - [Op.notIn]: [1, 2], // NOT IN [1, 2] - - [Op.like]: '%hat', // LIKE '%hat' - [Op.notLike]: '%hat', // NOT LIKE '%hat' - [Op.startsWith]: 'hat', // LIKE 'hat%' - [Op.endsWith]: 'hat', // LIKE '%hat' - [Op.substring]: 'hat', // LIKE '%hat%' - [Op.iLike]: '%hat', // ILIKE '%hat' (case insensitive) (PG only) - [Op.notILike]: '%hat', // NOT ILIKE '%hat' (PG only) - [Op.regexp]: '^[h|a|t]', // REGEXP/~ '^[h|a|t]' (MySQL/PG only) - [Op.notRegexp]: '^[h|a|t]', // NOT REGEXP/!~ '^[h|a|t]' (MySQL/PG only) - [Op.iRegexp]: '^[h|a|t]', // ~* '^[h|a|t]' (PG only) - [Op.notIRegexp]: '^[h|a|t]', // !~* '^[h|a|t]' (PG only) - - [Op.any]: [2, 3], // ANY ARRAY[2, 3]::INTEGER (PG only) - [Op.match]: Sequelize.fn('to_tsquery', 'fat & rat') // match text search for strings 'fat' and 'rat' (PG only) - - // In Postgres, Op.like/Op.iLike/Op.notLike can be combined to Op.any: - [Op.like]: { [Op.any]: ['cat', 'hat'] } // LIKE ANY ARRAY['cat', 'hat'] - - // There are more postgres-only range operators, see below - } - } -}); -``` - -#### Shorthand syntax for `Op.in` - -Passing an array directly to the `where` option will implicitly use the `IN` operator: - -```js -Post.findAll({ - where: { - id: [1,2,3] // Same as using `id: { [Op.in]: [1,2,3] }` - } -}); -// SELECT ... FROM "posts" AS "post" WHERE "post"."id" IN (1, 2, 3); -``` - -### Logical combinations with operators - -The operators `Op.and`, `Op.or` and `Op.not` can be used to create arbitrarily complex nested logical comparisons. - -#### Examples with `Op.and` and `Op.or` - -```js -const { Op } = require("sequelize"); - -Foo.findAll({ - where: { - rank: { - [Op.or]: { - [Op.lt]: 1000, - [Op.eq]: null - } - }, - // rank < 1000 OR rank IS NULL - - { - createdAt: { - [Op.lt]: new Date(), - [Op.gt]: new Date(new Date() - 24 * 60 * 60 * 1000) - } - }, - // createdAt < [timestamp] AND createdAt > [timestamp] - - { - [Op.or]: [ - { - title: { - [Op.like]: 'Boat%' - } - }, - { - description: { - [Op.like]: '%boat%' - } - } - ] - } - // title LIKE 'Boat%' OR description LIKE '%boat%' - } -}); -``` - -#### Examples with `Op.not` - -```js -Project.findAll({ - where: { - name: 'Some Project', - [Op.not]: [ - { id: [1,2,3] }, - { - description: { - [Op.like]: 'Hello%' - } - } - ] - } -}); -``` - -The above will generate: - -```sql -SELECT * -FROM `Projects` -WHERE ( - `Projects`.`name` = 'Some Project' - AND NOT ( - `Projects`.`id` IN (1,2,3) - AND - `Projects`.`description` LIKE 'Hello%' - ) -) -``` - -### Advanced queries with functions (not just columns) - -What if you wanted to obtain something like `WHERE char_length("content") = 7`? - -```js -Post.findAll({ - where: sequelize.where(sequelize.fn('char_length', sequelize.col('content')), 7) -}); -// SELECT ... FROM "posts" AS "post" WHERE char_length("content") = 7 -``` - -Note the usage of the [`sequelize.fn`](../class/lib/sequelize.js~Sequelize.html#static-method-fn) and [`sequelize.col`](../class/lib/sequelize.js~Sequelize.html#static-method-col) methods, which should be used to specify an SQL function call and a table column, respectively. These methods should be used instead of passing a plain string (such as `char_length(content)`) because Sequelize needs to treat this situation differently (for example, using other symbol escaping approaches). - -What if you need something even more complex? - -```js -Post.findAll({ - where: { - [Op.or]: [ - sequelize.where(sequelize.fn('char_length', sequelize.col('content')), 7), - { - content: { - [Op.like]: 'Hello%' - } - }, - { - [Op.and]: [ - { status: 'draft' }, - sequelize.where(sequelize.fn('char_length', sequelize.col('content')), { - [Op.gt]: 10 - }) - ] - } - ] - } -}); -``` - -The above generates the following SQL: - -```sql -SELECT - ... -FROM "posts" AS "post" -WHERE ( - char_length("content") = 7 - OR - "post"."content" LIKE 'Hello%' - OR ( - "post"."status" = 'draft' - AND - char_length("content") > 10 - ) -) -``` - -### Postgres-only Range Operators - -Range types can be queried with all supported operators. - -Keep in mind, the provided range value can [define the bound inclusion/exclusion](data-types.html#range-types) as well. - -```js -[Op.contains]: 2, // @> '2'::integer (PG range contains element operator) -[Op.contains]: [1, 2], // @> [1, 2) (PG range contains range operator) -[Op.contained]: [1, 2], // <@ [1, 2) (PG range is contained by operator) -[Op.overlap]: [1, 2], // && [1, 2) (PG range overlap (have points in common) operator) -[Op.adjacent]: [1, 2], // -|- [1, 2) (PG range is adjacent to operator) -[Op.strictLeft]: [1, 2], // << [1, 2) (PG range strictly left of operator) -[Op.strictRight]: [1, 2], // >> [1, 2) (PG range strictly right of operator) -[Op.noExtendRight]: [1, 2], // &< [1, 2) (PG range does not extend to the right of operator) -[Op.noExtendLeft]: [1, 2], // &> [1, 2) (PG range does not extend to the left of operator) -``` - -### Deprecated: Operator Aliases - -In Sequelize v4, it was possible to specify strings to refer to operators, instead of using Symbols. This is now deprecated and heavily discouraged, and will probably be removed in the next major version. If you really need it, you can pass the `operatorAliases` option in the Sequelize constructor. - -For example: - -```js -const { Sequelize, Op } = require("sequelize"); -const sequelize = new Sequelize('sqlite::memory:', { - operatorsAliases: { - $gt: Op.gt - } -}); - -// Now we can use `$gt` instead of `[Op.gt]` in where clauses: -Foo.findAll({ - where: { - $gt: 6 // Works like using [Op.gt] - } -}); -``` - -## Simple UPDATE queries - -Update queries also accept the `where` option, just like the read queries shown above. - -```js -// Change everyone without a last name to "Doe" -await User.update({ lastName: "Doe" }, { - where: { - lastName: null - } -}); -``` - -## Simple DELETE queries - -Delete queries also accept the `where` option, just like the read queries shown above. - -```js -// Delete everyone named "Jane" -await User.destroy({ - where: { - firstName: "Jane" - } -}); -``` - -To destroy everything the `TRUNCATE` SQL can be used: - -```js -// Truncate the table -await User.destroy({ - truncate: true -}); -``` - -## Creating in bulk - -Sequelize provides the `Model.bulkCreate` method to allow creating multiple records at once, with only one query. - -The usage of `Model.bulkCreate` is very similar to `Model.create`, by receiving an array of objects instead of a single object. - -```js -const captains = await Captain.bulkCreate([ - { name: 'Jack Sparrow' }, - { name: 'Davy Jones' } -]); -console.log(captains.length); // 2 -console.log(captains[0] instanceof Captain); // true -console.log(captains[0].name); // 'Jack Sparrow' -console.log(captains[0].id); // 1 // (or another auto-generated value) -``` - -However, by default, `bulkCreate` does not run validations on each object that is going to be created (which `create` does). To make `bulkCreate` run these validations as well, you must pass the `validate: true` option. This will decrease performance. Usage example: - -```js -const Foo = sequelize.define('foo', { - bar: { - type: DataTypes.TEXT, - validate: { - len: [4, 6] - } - } -}); - -// This will not throw an error, both instances will be created -await Foo.bulkCreate([ - { name: 'abc123' }, - { name: 'name too long' } -]); - -// This will throw an error, nothing will be created -await Foo.bulkCreate([ - { name: 'abc123' }, - { name: 'name too long' } -], { validate: true }); -``` - -If you are accepting values directly from the user, it might be beneficial to limit the columns that you want to actually insert. To support this, `bulkCreate()` accepts a `fields` option, an array defining which fields must be considered (the rest will be ignored). - -```js -await User.bulkCreate([ - { username: 'foo' }, - { username: 'bar', admin: true } -], { fields: ['username'] }); -// Neither foo nor bar are admins. -``` - -## Ordering and Grouping - -Sequelize provides the `order` and `group` options to work with `ORDER BY` and `GROUP BY`. - -### Ordering - -The `order` option takes an array of items to order the query by or a sequelize method. These *items* are themselves arrays in the form `[column, direction]`. The column will be escaped correctly and the direction will be checked in a whitelist of valid directions (such as `ASC`, `DESC`, `NULLS FIRST`, etc). - -```js -Subtask.findAll({ - order: [ - // Will escape title and validate DESC against a list of valid direction parameters - ['title', 'DESC'], - - // Will order by max(age) - sequelize.fn('max', sequelize.col('age')), - - // Will order by max(age) DESC - [sequelize.fn('max', sequelize.col('age')), 'DESC'], - - // Will order by otherfunction(`col1`, 12, 'lalala') DESC - [sequelize.fn('otherfunction', sequelize.col('col1'), 12, 'lalala'), 'DESC'], - - // Will order an associated model's createdAt using the model name as the association's name. - [Task, 'createdAt', 'DESC'], - - // Will order through an associated model's createdAt using the model names as the associations' names. - [Task, Project, 'createdAt', 'DESC'], - - // Will order by an associated model's createdAt using the name of the association. - ['Task', 'createdAt', 'DESC'], - - // Will order by a nested associated model's createdAt using the names of the associations. - ['Task', 'Project', 'createdAt', 'DESC'], - - // Will order by an associated model's createdAt using an association object. (preferred method) - [Subtask.associations.Task, 'createdAt', 'DESC'], - - // Will order by a nested associated model's createdAt using association objects. (preferred method) - [Subtask.associations.Task, Task.associations.Project, 'createdAt', 'DESC'], - - // Will order by an associated model's createdAt using a simple association object. - [{model: Task, as: 'Task'}, 'createdAt', 'DESC'], - - // Will order by a nested associated model's createdAt simple association objects. - [{model: Task, as: 'Task'}, {model: Project, as: 'Project'}, 'createdAt', 'DESC'] - ], - - // Will order by max age descending - order: sequelize.literal('max(age) DESC'), - - // Will order by max age ascending assuming ascending is the default order when direction is omitted - order: sequelize.fn('max', sequelize.col('age')), - - // Will order by age ascending assuming ascending is the default order when direction is omitted - order: sequelize.col('age'), - - // Will order randomly based on the dialect (instead of fn('RAND') or fn('RANDOM')) - order: sequelize.random() -}); - -Foo.findOne({ - order: [ - // will return `name` - ['name'], - // will return `username` DESC - ['username', 'DESC'], - // will return max(`age`) - sequelize.fn('max', sequelize.col('age')), - // will return max(`age`) DESC - [sequelize.fn('max', sequelize.col('age')), 'DESC'], - // will return otherfunction(`col1`, 12, 'lalala') DESC - [sequelize.fn('otherfunction', sequelize.col('col1'), 12, 'lalala'), 'DESC'], - // will return otherfunction(awesomefunction(`col`)) DESC, This nesting is potentially infinite! - [sequelize.fn('otherfunction', sequelize.fn('awesomefunction', sequelize.col('col'))), 'DESC'] - ] -}); -``` - -To recap, the elements of the order array can be the following: - -* A string (which will be automatically quoted) -* An array, whose first element will be quoted, second will be appended verbatim -* An object with a `raw` field: - * The content of `raw` will be added verbatim without quoting - * Everything else is ignored, and if raw is not set, the query will fail -* A call to `Sequelize.fn` (which will generate a function call in SQL) -* A call to `Sequelize.col` (which will quoute the column name) - -### Grouping - -The syntax for grouping and ordering are equal, except that grouping does not accept a direction as last argument of the array (there is no `ASC`, `DESC`, `NULLS FIRST`, etc). - -You can also pass a string directly to `group`, which will be included directly (verbatim) into the generated SQL. Use with caution and don't use with user generated content. - -```js -Project.findAll({ group: 'name' }); -// yields 'GROUP BY name' -``` - -## Limits and Pagination - -The `limit` and `offset` options allow you to work with limiting / pagination: - -```js -// Fetch 10 instances/rows -Project.findAll({ limit: 10 }); - -// Skip 8 instances/rows -Project.findAll({ offset: 8 }); - -// Skip 5 instances and fetch the 5 after that -Project.findAll({ offset: 5, limit: 5 }); -``` - -Usually these are used alongside the `order` option. - -## Utility methods - -Sequelize also provides a few utility methods. - -### `count` - -The `count` method simply counts the occurrences of elements in the database. - -```js -console.log(`There are ${await Project.count()} projects`); - -const amount = await Project.count({ - where: { - id: { - [Op.gt]: 25 - } - } -}); -console.log(`There are ${amount} projects with an id greater than 25`); -``` - -### `max`, `min` and `sum` - -Sequelize also provides the `max`, `min` and `sum` convenience methods. - -Let's assume we have three users, whose ages are 10, 5, and 40. - -```js -await User.max('age'); // 40 -await User.max('age', { where: { age: { [Op.lt]: 20 } } }); // 10 -await User.min('age'); // 5 -await User.min('age', { where: { age: { [Op.gt]: 5 } } }); // 10 -await User.sum('age'); // 55 -await User.sum('age', { where: { age: { [Op.gt]: 5 } } }); // 50 -``` - -### `increment`, `decrement` - -Sequelize also provides the `increment` convenience method. - -Let's assume we have a user, whose age is 10. - -```js -await User.increment({age: 5}, { where: { id: 1 } }) // Will increase age to 15 -await User.increment({age: -5}, { where: { id: 1 } }) // Will decrease age to 5 -``` diff --git a/docs/manual/core-concepts/model-querying-finders.md b/docs/manual/core-concepts/model-querying-finders.md deleted file mode 100644 index ebe6c5820324..000000000000 --- a/docs/manual/core-concepts/model-querying-finders.md +++ /dev/null @@ -1,88 +0,0 @@ -# Model Querying - Finders - -Finder methods are the ones that generate `SELECT` queries. - -By default, the results of all finder methods are instances of the model class (as opposed to being just plain JavaScript objects). This means that after the database returns the results, Sequelize automatically wraps everything in proper instance objects. In a few cases, when there are too many results, this wrapping can be inefficient. To disable this wrapping and receive a plain response instead, pass `{ raw: true }` as an option to the finder method. - -## `findAll` - -The `findAll` method is already known from the previous tutorial. It generates a standard `SELECT` query which will retrieve all entries from the table (unless restricted by something like a `where` clause, for example). - -## `findByPk` - -The `findByPk` method obtains only a single entry from the table, using the provided primary key. - -```js -const project = await Project.findByPk(123); -if (project === null) { - console.log('Not found!'); -} else { - console.log(project instanceof Project); // true - // Its primary key is 123 -} -``` - -## `findOne` - -The `findOne` method obtains the first entry it finds (that fulfills the optional query options, if provided). - -```js -const project = await Project.findOne({ where: { title: 'My Title' } }); -if (project === null) { - console.log('Not found!'); -} else { - console.log(project instanceof Project); // true - console.log(project.title); // 'My Title' -} -``` - -## `findOrCreate` - -The method `findOrCreate` will create an entry in the table unless it can find one fulfilling the query options. In both cases, it will return an instance (either the found instance or the created instance) and a boolean indicating whether that instance was created or already existed. - -The `where` option is considered for finding the entry, and the `defaults` option is used to define what must be created in case nothing was found. If the `defaults` do not contain values for every column, Sequelize will take the values given to `where` (if present). - -Let's assume we have an empty database with a `User` model which has a `username` and a `job`. - -```js -const [user, created] = await User.findOrCreate({ - where: { username: 'sdepold' }, - defaults: { - job: 'Technical Lead JavaScript' - } -}); -console.log(user.username); // 'sdepold' -console.log(user.job); // This may or may not be 'Technical Lead JavaScript' -console.log(created); // The boolean indicating whether this instance was just created -if (created) { - console.log(user.job); // This will certainly be 'Technical Lead JavaScript' -} -``` - -## `findAndCountAll` - -The `findAndCountAll` method is a convenience method that combines `findAll` and `count`. This is useful when dealing with queries related to pagination where you want to retrieve data with a `limit` and `offset` but also need to know the total number of records that match the query. - -When `group` is not provided, the `findAndCountAll` method returns an object with two properties: - -* `count` - an integer - the total number records matching the query -* `rows` - an array of objects - the obtained records - -When `group` is provided, the `findAndCountAll` method returns an object with two properties: - -* `count` - an array of objects - contains the count in each group and the projected attributes -* `rows` - an array of objects - the obtained records - -```js -const { count, rows } = await Project.findAndCountAll({ - where: { - title: { - [Op.like]: 'foo%' - } - }, - offset: 10, - limit: 2 -}); -console.log(count); -console.log(rows); -``` diff --git a/docs/manual/core-concepts/paranoid.md b/docs/manual/core-concepts/paranoid.md deleted file mode 100644 index dd580d0578a9..000000000000 --- a/docs/manual/core-concepts/paranoid.md +++ /dev/null @@ -1,105 +0,0 @@ -# Paranoid - -Sequelize supports the concept of *paranoid* tables. A *paranoid* table is one that, when told to delete a record, it will not truly delete it. Instead, a special column called `deletedAt` will have its value set to the timestamp of that deletion request. - -This means that paranoid tables perform a *soft-deletion* of records, instead of a *hard-deletion*. - -## Defining a model as paranoid - -To make a model paranoid, you must pass the `paranoid: true` option to the model definition. Paranoid requires timestamps to work (i.e. it won't work if you also pass `timestamps: false`). - -You can also change the default column name (which is `deletedAt`) to something else. - -```js -class Post extends Model {} -Post.init({ /* attributes here */ }, { - sequelize, - paranoid: true, - - // If you want to give a custom name to the deletedAt column - deletedAt: 'destroyTime' -}); -``` - -## Deleting - -When you call the `destroy` method, a soft-deletion will happen: - -```js -await Post.destroy({ - where: { - id: 1 - } -}); -// UPDATE "posts" SET "deletedAt"=[timestamp] WHERE "deletedAt" IS NULL AND "id" = 1 -``` - -If you really want a hard-deletion and your model is paranoid, you can force it using the `force: true` option: - -```js -await Post.destroy({ - where: { - id: 1 - }, - force: true -}); -// DELETE FROM "posts" WHERE "id" = 1 -``` - -The above examples used the static `destroy` method as an example (`Post.destroy`), but everything works in the same way with the instance method: - -```js -const post = await Post.create({ title: 'test' }); -console.log(post instanceof Post); // true -await post.destroy(); // Would just set the `deletedAt` flag -await post.destroy({ force: true }); // Would really delete the record -``` - -## Restoring - -To restore soft-deleted records, you can use the `restore` method, which comes both in the static version as well as in the instance version: - -```js -// Example showing the instance `restore` method -// We create a post, soft-delete it and then restore it back -const post = await Post.create({ title: 'test' }); -console.log(post instanceof Post); // true -await post.destroy(); -console.log('soft-deleted!'); -await post.restore(); -console.log('restored!'); - -// Example showing the static `restore` method. -// Restoring every soft-deleted post with more than 100 likes -await Post.restore({ - where: { - likes: { - [Op.gt]: 100 - } - } -}); -``` - -## Behavior with other queries - -Every query performed by Sequelize will automatically ignore soft-deleted records (except raw queries, of course). - -This means that, for example, the `findAll` method will not see the soft-deleted records, fetching only the ones that were not deleted. - -Even if you simply call `findByPk` providing the primary key of a soft-deleted record, the result will be `null` as if that record didn't exist. - -If you really want to let the query see the soft-deleted records, you can pass the `paranoid: false` option to the query method. For example: - -```js -await Post.findByPk(123); // This will return `null` if the record of id 123 is soft-deleted -await Post.findByPk(123, { paranoid: false }); // This will retrieve the record - -await Post.findAll({ - where: { foo: 'bar' } -}); // This will not retrieve soft-deleted records - -await Post.findAll({ - where: { foo: 'bar' }, - paranoid: false -}); // This will also retrieve soft-deleted records -``` \ No newline at end of file diff --git a/docs/manual/core-concepts/raw-queries.md b/docs/manual/core-concepts/raw-queries.md deleted file mode 100644 index ff18dffcf8d6..000000000000 --- a/docs/manual/core-concepts/raw-queries.md +++ /dev/null @@ -1,186 +0,0 @@ -# Raw Queries - -As there are often use cases in which it is just easier to execute raw / already prepared SQL queries, you can use the [`sequelize.query`](../class/lib/sequelize.js~Sequelize.html#instance-method-query) method. - -By default the function will return two arguments - a results array, and an object containing metadata (such as amount of affected rows, etc). Note that since this is a raw query, the metadata are dialect specific. Some dialects return the metadata "within" the results object (as properties on an array). However, two arguments will always be returned, but for MSSQL and MySQL it will be two references to the same object. - -```js -const [results, metadata] = await sequelize.query("UPDATE users SET y = 42 WHERE x = 12"); -// Results will be an empty array and metadata will contain the number of affected rows. -``` - -In cases where you don't need to access the metadata you can pass in a query type to tell sequelize how to format the results. For example, for a simple select query you could do: - -```js -const { QueryTypes } = require('sequelize'); -const users = await sequelize.query("SELECT * FROM `users`", { type: QueryTypes.SELECT }); -// We didn't need to destructure the result here - the results were returned directly -``` - -Several other query types are available. [Peek into the source for details](https://github.com/sequelize/sequelize/blob/main/src/query-types.ts). - -A second option is the model. If you pass a model the returned data will be instances of that model. - -```js -// Callee is the model definition. This allows you to easily map a query to a predefined model -const projects = await sequelize.query('SELECT * FROM projects', { - model: Projects, - mapToModel: true // pass true here if you have any mapped fields -}); -// Each element of `projects` is now an instance of Project -``` - -See more options in the [query API reference](../class/lib/sequelize.js~Sequelize.html#instance-method-query). Some examples: - -```js -const { QueryTypes } = require('sequelize'); -await sequelize.query('SELECT 1', { - // A function (or false) for logging your queries - // Will get called for every SQL query that gets sent - // to the server. - logging: console.log, - - // If plain is true, then sequelize will only return the first - // record of the result set. In case of false it will return all records. - plain: false, - - // Set this to true if you don't have a model definition for your query. - raw: false, - - // The type of query you are executing. The query type affects how results are formatted before they are passed back. - type: QueryTypes.SELECT -}); - -// Note the second argument being null! -// Even if we declared a callee here, the raw: true would -// supersede and return a raw object. -console.log(await sequelize.query('SELECT * FROM projects', { raw: true })); -``` - -## "Dotted" attributes and the `nest` option - -If an attribute name of the table contains dots, the resulting objects can become nested objects by setting the `nest: true` option. This is achieved with [dottie.js](https://github.com/mickhansen/dottie.js/) under the hood. See below: - -* Without `nest: true`: - - ```js - const { QueryTypes } = require('sequelize'); - const records = await sequelize.query('select 1 as `foo.bar.baz`', { - type: QueryTypes.SELECT - }); - console.log(JSON.stringify(records[0], null, 2)); - ``` - - ```json - { - "foo.bar.baz": 1 - } - ``` - -* With `nest: true`: - - ```js - const { QueryTypes } = require('sequelize'); - const records = await sequelize.query('select 1 as `foo.bar.baz`', { - nest: true, - type: QueryTypes.SELECT - }); - console.log(JSON.stringify(records[0], null, 2)); - ``` - - ```json - { - "foo": { - "bar": { - "baz": 1 - } - } - } - ``` - -## Replacements - -Replacements in a query can be done in two different ways, either using named parameters (starting with `:`), or unnamed, represented by a `?`. Replacements are passed in the options object. - -* If an array is passed, `?` will be replaced in the order that they appear in the array -* If an object is passed, `:key` will be replaced with the keys from that object. If the object contains keys not found in the query or vice versa, an exception will be thrown. - -```js -const { QueryTypes } = require('sequelize'); - -await sequelize.query( - 'SELECT * FROM projects WHERE status = ?', - { - replacements: ['active'], - type: QueryTypes.SELECT - } -); - -await sequelize.query( - 'SELECT * FROM projects WHERE status = :status', - { - replacements: { status: 'active' }, - type: QueryTypes.SELECT - } -); -``` - -Array replacements will automatically be handled, the following query searches for projects where the status matches an array of values. - -```js -const { QueryTypes } = require('sequelize'); - -await sequelize.query( - 'SELECT * FROM projects WHERE status IN(:status)', - { - replacements: { status: ['active', 'inactive'] }, - type: QueryTypes.SELECT - } -); -``` - -To use the wildcard operator `%`, append it to your replacement. The following query matches users with names that start with 'ben'. - -```js -const { QueryTypes } = require('sequelize'); - -await sequelize.query( - 'SELECT * FROM users WHERE name LIKE :search_name', - { - replacements: { search_name: 'ben%' }, - type: QueryTypes.SELECT - } -); -``` - -## Bind Parameter - -Bind parameters are like replacements. Except replacements are escaped and inserted into the query by sequelize before the query is sent to the database, while bind parameters are sent to the database outside the SQL query text. A query can have either bind parameters or replacements. Bind parameters are referred to by either $1, $2, ... (numeric) or $key (alpha-numeric). This is independent of the dialect. - -* If an array is passed, `$1` is bound to the 1st element in the array (`bind[0]`) -* If an object is passed, `$key` is bound to `object['key']`. Each key must begin with a non-numeric char. `$1` is not a valid key, even if `object['1']` exists. -* In either case `$$` can be used to escape a literal `$` sign. - -The array or object must contain all bound values or Sequelize will throw an exception. This applies even to cases in which the database may ignore the bound parameter. - -The database may add further restrictions to this. Bind parameters cannot be SQL keywords, nor table or column names. They are also ignored in quoted text or data. In PostgreSQL it may also be needed to typecast them, if the type cannot be inferred from the context `$1::varchar`. - -```js -const { QueryTypes } = require('sequelize'); - -await sequelize.query( - 'SELECT *, "text with literal $$1 and literal $$status" as t FROM projects WHERE status = $1', - { - bind: ['active'], - type: QueryTypes.SELECT - } -); - -await sequelize.query( - 'SELECT *, "text with literal $$1 and literal $$status" as t FROM projects WHERE status = $status', - { - bind: { status: 'active' }, - type: QueryTypes.SELECT - } -); -``` diff --git a/docs/manual/core-concepts/validations-and-constraints.md b/docs/manual/core-concepts/validations-and-constraints.md deleted file mode 100644 index fed749072ed7..000000000000 --- a/docs/manual/core-concepts/validations-and-constraints.md +++ /dev/null @@ -1,272 +0,0 @@ -# Validations & Constraints - -In this tutorial you will learn how to setup validations and constraints for your models in Sequelize. - -For this tutorial, the following setup will be assumed: - -```js -const { Sequelize, Op, Model, DataTypes } = require("sequelize"); -const sequelize = new Sequelize("sqlite::memory:"); - -const User = sequelize.define("user", { - username: { - type: DataTypes.TEXT, - allowNull: false, - unique: true - }, - hashedPassword: { - type: DataTypes.STRING(64), - validate: { - is: /^[0-9a-f]{64}$/i - } - } -}); - -(async () => { - await sequelize.sync({ force: true }); - // Code here -})(); -``` - -## Difference between Validations and Constraints - -Validations are checks performed in the Sequelize level, in pure JavaScript. They can be arbitrarily complex if you provide a custom validator function, or can be one of the built-in validators offered by Sequelize. If a validation fails, no SQL query will be sent to the database at all. - -On the other hand, constraints are rules defined at SQL level. The most basic example of constraint is an Unique Constraint. If a constraint check fails, an error will be thrown by the database and Sequelize will forward this error to JavaScript (in this example, throwing a `SequelizeUniqueConstraintError`). Note that in this case, the SQL query was performed, unlike the case for validations. - -## Unique Constraint - -Our code example above defines a unique constraint on the `username` field: - -```js -/* ... */ { - username: { - type: DataTypes.TEXT, - allowNull: false, - unique: true - }, -} /* ... */ -``` - -When this model is synchronized (by calling `sequelize.sync` for example), the `username` field will be created in the table as `` `username` TEXT UNIQUE``, and an attempt to insert an username that already exists there will throw a `SequelizeUniqueConstraintError`. - -## Allowing/disallowing null values - -By default, `null` is an allowed value for every column of a model. This can be disabled setting the `allowNull: false` option for a column, as it was done in the `username` field from our code example: - -```js -/* ... */ { - username: { - type: DataTypes.TEXT, - allowNull: false, - unique: true - }, -} /* ... */ -``` - -Without `allowNull: false`, the call `User.create({})` would work. - -### Note about `allowNull` implementation - -The `allowNull` check is the only check in Sequelize that is a mix of a *validation* and a *constraint* in the senses described at the beginning of this tutorial. This is because: - -* If an attempt is made to set `null` to a field that does not allow null, a `ValidationError` will be thrown *without any SQL query being performed*. -* In addition, after `sequelize.sync`, the column that has `allowNull: false` will be defined with a `NOT NULL` SQL constraint. This way, direct SQL queries that attempt to set the value to `null` will also fail. - -## Validators - -Model validators allow you to specify format/content/inheritance validations for each attribute of the model. Validations are automatically run on `create`, `update` and `save`. You can also call `validate()` to manually validate an instance. - -### Per-attribute validations - -You can define your custom validators or use several built-in validators, implemented by [validator.js (10.11.0)](https://github.com/chriso/validator.js), as shown below. - -```js -sequelize.define('foo', { - bar: { - type: DataTypes.STRING, - validate: { - is: /^[a-z]+$/i, // matches this RegExp - is: ["^[a-z]+$",'i'], // same as above, but constructing the RegExp from a string - not: /^[a-z]+$/i, // does not match this RegExp - not: ["^[a-z]+$",'i'], // same as above, but constructing the RegExp from a string - isEmail: true, // checks for email format (foo@bar.com) - isUrl: true, // checks for url format (http://foo.com) - isIP: true, // checks for IPv4 (129.89.23.1) or IPv6 format - isIPv4: true, // checks for IPv4 (129.89.23.1) - isIPv6: true, // checks for IPv6 format - isAlpha: true, // will only allow letters - isAlphanumeric: true, // will only allow alphanumeric characters, so "_abc" will fail - isNumeric: true, // will only allow numbers - isInt: true, // checks for valid integers - isFloat: true, // checks for valid floating point numbers - isDecimal: true, // checks for any numbers - isLowercase: true, // checks for lowercase - isUppercase: true, // checks for uppercase - notNull: true, // won't allow null - isNull: true, // only allows null - notEmpty: true, // don't allow empty strings - equals: 'specific value', // only allow a specific value - contains: 'foo', // force specific substrings - notIn: [['foo', 'bar']], // check the value is not one of these - isIn: [['foo', 'bar']], // check the value is one of these - notContains: 'bar', // don't allow specific substrings - len: [2,10], // only allow values with length between 2 and 10 - isUUID: 4, // only allow uuids - isDate: true, // only allow date strings - isAfter: "2011-11-05", // only allow date strings after a specific date - isBefore: "2011-11-05", // only allow date strings before a specific date - max: 23, // only allow values <= 23 - min: 23, // only allow values >= 23 - isCreditCard: true, // check for valid credit card numbers - - // Examples of custom validators: - isEven(value) { - if (parseInt(value) % 2 !== 0) { - throw new Error('Only even values are allowed!'); - } - } - isGreaterThanOtherField(value) { - if (parseInt(value) <= parseInt(this.otherField)) { - throw new Error('Bar must be greater than otherField.'); - } - } - } - } -}); -``` - -Note that where multiple arguments need to be passed to the built-in validation functions, the arguments to be passed must be in an array. But if a single array argument is to be passed, for instance an array of acceptable strings for `isIn`, this will be interpreted as multiple string arguments instead of one array argument. To work around this pass a single-length array of arguments, such as `[['foo', 'bar']]` as shown above. - -To use a custom error message instead of that provided by [validator.js](https://github.com/chriso/validator.js), use an object instead of the plain value or array of arguments, for example a validator which needs no argument can be given a custom message with - -```js -isInt: { - msg: "Must be an integer number of pennies" -} -``` - -or if arguments need to also be passed add an `args` property: - -```js -isIn: { - args: [['en', 'zh']], - msg: "Must be English or Chinese" -} -``` - -When using custom validator functions the error message will be whatever message the thrown `Error` object holds. - -See [the validator.js project](https://github.com/chriso/validator.js) for more details on the built in validation methods. - -**Hint:** You can also define a custom function for the logging part. Just pass a function. The first parameter will be the string that is logged. - -### `allowNull` interaction with other validators - -If a particular field of a model is set to not allow null (with `allowNull: false`) and that value has been set to `null`, all validators will be skipped and a `ValidationError` will be thrown. - -On the other hand, if it is set to allow null (with `allowNull: true`) and that value has been set to `null`, only the built-in validators will be skipped, while the custom validators will still run. - -This means you can, for instance, have a string field which validates its length to be between 5 and 10 characters, but which also allows `null` (since the length validator will be skipped automatically when the value is `null`): - -```js -class User extends Model {} -User.init({ - username: { - type: DataTypes.STRING, - allowNull: true, - validate: { - len: [5, 10] - } - } -}, { sequelize }); -``` - -You also can conditionally allow `null` values, with a custom validator, since it won't be skipped: - -```js -class User extends Model {} -User.init({ - age: Sequelize.INTEGER, - name: { - type: DataTypes.STRING, - allowNull: true, - validate: { - customValidator(value) { - if (value === null && this.age !== 10) { - throw new Error("name can't be null unless age is 10"); - } - }) - } - } -}, { sequelize }); -``` - -You can customize `allowNull` error message by setting the `notNull` validator: - -```js -class User extends Model {} -User.init({ - name: { - type: DataTypes.STRING, - allowNull: false, - validate: { - notNull: { - msg: 'Please enter your name' - } - } - } -}, { sequelize }); -``` - -### Model-wide validations - -Validations can also be defined to check the model after the field-specific validators. Using this you could, for example, ensure either neither of `latitude` and `longitude` are set or both, and fail if one but not the other is set. - -Model validator methods are called with the model object's context and are deemed to fail if they throw an error, otherwise pass. This is just the same as with custom field-specific validators. - -Any error messages collected are put in the validation result object alongside the field validation errors, with keys named after the failed validation method's key in the `validate` option object. Even though there can only be one error message for each model validation method at any one time, it is presented as a single string error in an array, to maximize consistency with the field errors. - -An example: - -```js -class Place extends Model {} -Place.init({ - name: Sequelize.STRING, - address: Sequelize.STRING, - latitude: { - type: DataTypes.INTEGER, - validate: { - min: -90, - max: 90 - } - }, - longitude: { - type: DataTypes.INTEGER, - validate: { - min: -180, - max: 180 - } - }, -}, { - sequelize, - validate: { - bothCoordsOrNone() { - if ((this.latitude === null) !== (this.longitude === null)) { - throw new Error('Either both latitude and longitude, or neither!'); - } - } - } -}) -``` - -In this simple case an object fails validation if either latitude or longitude is given, but not both. If we try to build one with an out-of-range latitude and no longitude, `somePlace.validate()` might return: - -```js -{ - 'latitude': ['Invalid number: latitude'], - 'bothCoordsOrNone': ['Either both latitude and longitude, or neither!'] -} -``` - -Such validation could have also been done with a custom validator defined on a single attribute (such as the `latitude` attribute, by checking `(value === null) !== (this.longitude === null)`), but the model-wide validation approach is cleaner. diff --git a/docs/manual/moved/associations.md b/docs/manual/moved/associations.md deleted file mode 100644 index cf001aac731f..000000000000 --- a/docs/manual/moved/associations.md +++ /dev/null @@ -1,16 +0,0 @@ -# \[MOVED\] Associations - -The contents of this page were moved to other specialized guides. - -If you're here, you might be looking for these topics: - -* **Core Concepts** - * [Associations](assocs.html) -* **Advanced Association Concepts** - * [Eager Loading](eager-loading.html) - * [Creating with Associations](creating-with-associations.html) - * [Advanced M:N Associations](advanced-many-to-many.html) - * [Polymorphism & Scopes](polymorphism-and-scopes.html) -* **Other Topics** - * [Naming Strategies](naming-strategies.html) - * [Constraints & Circularities](constraints-and-circularities.html) \ No newline at end of file diff --git a/docs/manual/moved/data-types.md b/docs/manual/moved/data-types.md deleted file mode 100644 index 4ba48b9798d9..000000000000 --- a/docs/manual/moved/data-types.md +++ /dev/null @@ -1,12 +0,0 @@ -# \[MOVED\] Data Types - -The contents of this page were moved to other specialized guides. - -If you're here, you might be looking for these topics: - -* **Core Concepts** - * [Model Basics: Data Types](model-basics.html#data-types) -* **Other Topics** - * [Other Data Types](other-data-types.html) - * [Extending Data Types](extending-data-types.html) - * [Dialect-Specific Things](dialect-specific-things.html) \ No newline at end of file diff --git a/docs/manual/moved/models-definition.md b/docs/manual/moved/models-definition.md deleted file mode 100644 index 420567885bb5..000000000000 --- a/docs/manual/moved/models-definition.md +++ /dev/null @@ -1,57 +0,0 @@ -# \[MOVED\] Models Definition - -The contents of this page were moved to [Model Basics](model-basics.html). - -The only exception is the guide on `sequelize.import`, which is deprecated and was removed from the docs. However, if you really need it, it was kept here. - ----- - -## Deprecated: `sequelize.import` - -> _**Note:** You should not use `sequelize.import`. Please just use [`import`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import), [`import()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#dynamic_imports), or [`require`](https://nodejs.org/api/modules.html#requireid) instead._ -> -> _This documentation has been kept just in case you really need to maintain old code that uses it._ - -`sequelize.import` can only load [CommonJS](https://nodejs.org/api/modules.html) files, and is not capable of loading [`ecmascript modules`](https://nodejs.org/api/esm.html). Use native `import` if you need to load ecmascript modules. - -You can store your model definitions in a single file using the `sequelize.import` method. The returned object is exactly the same as defined in the imported file's function. The import is cached, just like `require`, so you won't run into trouble if importing a file more than once. - -```js -// in your server file - e.g. app.js -const Project = sequelize.import(__dirname + "/path/to/models/project"); - -// The model definition is done in /path/to/models/project.js -module.exports = (sequelize, DataTypes) => { - return sequelize.define('project', { - name: DataTypes.STRING, - description: DataTypes.TEXT - }); -}; -``` - -The `import` method can also accept a callback as an argument. - -```js -sequelize.import('project', (sequelize, DataTypes) => { - return sequelize.define('project', { - name: DataTypes.STRING, - description: DataTypes.TEXT - }); -}); -``` - -This extra capability is useful when, for example, `Error: Cannot find module` is thrown even though `/path/to/models/project` seems to be correct. Some frameworks, such as Meteor, overload `require`, and might raise an error such as: - -```text -Error: Cannot find module '/home/you/meteorApp/.meteor/local/build/programs/server/app/path/to/models/project.js' -``` - -This can be worked around by passing in Meteor's version of `require`: - -```js -// If this fails... -const AuthorModel = db.import('./path/to/models/project'); - -// Try this instead! -const AuthorModel = db.import('project', require('./path/to/models/project')); -``` diff --git a/docs/manual/moved/models-usage.md b/docs/manual/moved/models-usage.md deleted file mode 100644 index 020eeacab726..000000000000 --- a/docs/manual/moved/models-usage.md +++ /dev/null @@ -1,12 +0,0 @@ -# \[MOVED\] Models Usage - -The contents of this page were moved to other specialized guides. - -If you're here, you might be looking for these topics: - -* **Core Concepts** - * [Model Querying - Basics](model-querying-basics.html) - * [Model Querying - Finders](model-querying-finders.html) - * [Raw Queries](raw-queries.html) -* **Advanced Association Concepts** - * [Eager Loading](eager-loading.html) \ No newline at end of file diff --git a/docs/manual/moved/querying.md b/docs/manual/moved/querying.md deleted file mode 100644 index 94b8d8ae9c99..000000000000 --- a/docs/manual/moved/querying.md +++ /dev/null @@ -1,13 +0,0 @@ -# \[MOVED\] Querying - -The contents of this page were moved to other specialized guides. - -If you're here, you might be looking for these topics: - -* **Core Concepts** - * [Model Querying - Basics](model-querying-basics.html) - * [Model Querying - Finders](model-querying-finders.html) - * [Raw Queries](raw-queries.html) - * [Associations](assocs.html) -* **Other Topics** - * [Dialect-Specific Things](dialect-specific-things.html) \ No newline at end of file diff --git a/docs/manual/other-topics/aws-lambda.md b/docs/manual/other-topics/aws-lambda.md deleted file mode 100644 index 002d9b277cf7..000000000000 --- a/docs/manual/other-topics/aws-lambda.md +++ /dev/null @@ -1,730 +0,0 @@ -# Using sequelize in AWS Lambda - -[AWS Lambda](https://aws.amazon.com/lambda/) is a serverless computing service that allows customers -to run code without having to worry about the underlying servers. Using `sequelize` in AWS Lambda -can be tricky if certain concepts are not properly understood and an appropriate configuration is -not used. This guide seeks to clarify some of these concepts so users of the library can properly -configure `sequelize` for AWS Lambda and troubleshoot issues. - -## TL;DR - -If you just want to learn how to properly configure `sequelize` -[connection pooling](./connection-pool.html) for AWS Lambda, all you need to know is that -`sequelize` connection pooling does not get along well with AWS Lambda's Node.js runtime and it ends -up causing more problems than it solves. Therefore, the most appropriate configuration is to **use -pooling within the same invocation** and **avoid pooling across invocations** (i.e. close all -connections at the end): - -```js -const { Sequelize } = require("sequelize"); - -let sequelize = null; - -async function loadSequelize() { - const sequelize = new Sequelize(/* (...) */, { - // (...) - pool: { - /* - * Lambda functions process one request at a time but your code may issue multiple queries - * concurrently. Be wary that `sequelize` has methods that issue 2 queries concurrently - * (e.g. `Model.findAndCountAll()`). Using a value higher than 1 allows concurrent queries to - * be executed in parallel rather than serialized. Careful with executing too many queries in - * parallel per Lambda function execution since that can bring down your database with an - * excessive number of connections. - * - * Ideally you want to choose a `max` number where this holds true: - * max * EXPECTED_MAX_CONCURRENT_LAMBDA_INVOCATIONS < MAX_ALLOWED_DATABASE_CONNECTIONS * 0.8 - */ - max: 2, - /* - * Set this value to 0 so connection pool eviction logic eventually cleans up all connections - * in the event of a Lambda function timeout. - */ - min: 0, - /* - * Set this value to 0 so connections are eligible for cleanup immediately after they're - * returned to the pool. - */ - idle: 0, - // Choose a small enough value that fails fast if a connection takes too long to be established. - acquire: 3000, - /* - * Ensures the connection pool attempts to be cleaned up automatically on the next Lambda - * function invocation, if the previous invocation timed out. - */ - evict: CURRENT_LAMBDA_FUNCTION_TIMEOUT - } - }); - - // or `sequelize.sync()` - await sequelize.authenticate(); - - return sequelize; -} - -module.exports.handler = async function (event, callback) { - // re-use the sequelize instance across invocations to improve performance - if (!sequelize) { - sequelize = await loadSequelize(); - } else { - // restart connection pool to ensure connections are not re-used across invocations - sequelize.connectionManager.initPools(); - - // restore `getConnection()` if it has been overwritten by `close()` - if (sequelize.connectionManager.hasOwnProperty("getConnection")) { - delete sequelize.connectionManager.getConnection; - } - } - - try { - return await doSomethingWithSequelize(sequelize); - } finally { - // close any opened connections during the invocation - // this will wait for any in-progress queries to finish before closing the connections - await sequelize.connectionManager.close(); - } -}; -``` - -### Using AWS RDS Proxy - -If your are using [AWS RDS](https://aws.amazon.com/rds/) and you are using -[Aurora](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/rds-proxy.html) or a -[supported database engine](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/rds-proxy.html), -then connect to your database using [AWS RDS Proxy](https://aws.amazon.com/rds/proxy/). This will -make sure that opening/closing connections on each invocation is not an expensive operation for -your underlying database server. - ---- - -If you want to understand why you must use sequelize this way in AWS Lambda, continue reading the -rest of this document: - -## The Node.js event loop - -The [Node.js event loop](https://nodejs.org/en/docs/guides/event-loop-timers-and-nexttick/) is: - -> what allows Node.js to perform non-blocking I/O operations — despite the fact that JavaScript is -> single-threaded — - -While the event loop implementation is in C++, here's a simplified JavaScript pseudo-implementation -that illustrates how Node.js would execute a script named `index.js`: - -```js -// see: https://nodejs.org/en/docs/guides/event-loop-timers-and-nexttick/ -// see: https://www.youtube.com/watch?v=P9csgxBgaZ8 -// see: https://www.youtube.com/watch?v=PNa9OMajw9w -const process = require('process'); - -/* - * counter of pending events - * - * reference counter is increased for every: - * - * 1. scheduled timer: `setTimeout()`, `setInterval()`, etc. - * 2. scheduled immediate: `setImmediate()`. - * 3. syscall of non-blocking IO: `require('net').Server.listen()`, etc. - * 4. scheduled task to the thread pool: `require('fs').WriteStream.write()`, etc. - * - * reference counter is decreased for every: - * - * 1. elapsed timer - * 2. executed immediate - * 3. completed non-blocking IO - * 4. completed thread pool task - * - * references can be explicitly decreased by invoking `.unref()` on some - * objects like: `require('net').Socket.unref()` - */ -let refs = 0; - -/* - * a heap of timers, sorted by next ocurrence - * - * whenever `setTimeout()` or `setInterval()` is invoked, a timer gets added here - */ -const timersHeap = /* (...) */; - -/* - * a FIFO queue of immediates - * - * whenever `setImmediate()` is invoked, it gets added here - */ -const immediates = /* (...) */; - -/* - * a FIFO queue of next tick callbacks - * - * whenever `require('process').nextTick()` is invoked, the callback gets added here - */ -const nextTickCallbacks = []; - -/* - * a heap of Promise-related callbacks, sorted by promise constructors callbacks first, - * and then resolved/rejected callbacks - * - * whenever a new Promise instance is created via `new Promise` or a promise resolves/rejects - * the appropriate callback (if any) gets added here - */ -const promiseCallbacksHeap = /* ... */; - -function execTicksAndPromises() { - while (nextTickCallbacks.length || promiseCallbacksHeap.size()) { - // execute all callbacks scheduled with `process.nextTick()` - while (nextTickCallbacks.length) { - const callback = nextTickCallbacks.shift(); - callback(); - } - - // execute all promise-related callbacks - while (promiseCallbacksHeap.size()) { - const callback = promiseCallbacksHeap.pop(); - callback(); - } - } -} - -try { - // execute index.js - require('./index'); - execTicksAndPromises(); - - do { - // timers phase: executes all elapsed timers - getElapsedTimerCallbacks(timersHeap).forEach(callback => { - callback(); - execTicksAndPromises(); - }); - - // pending callbacks phase: executes some system operations (like `TCP errors`) that are not - // executed in the poll phase - getPendingCallbacks().forEach(callback => { - callback(); - execTicksAndPromises(); - }) - - // poll phase: gets completed non-blocking I/O events or thread pool tasks and invokes the - // corresponding callbacks; if there are none and there's no pending immediates, - // it blocks waiting for events/completed tasks for a maximum of `maxWait` - const maxWait = computeWhenNextTimerElapses(timersHeap); - pollForEventsFromKernelOrThreadPool(maxWait, immediates).forEach(callback => { - callback(); - execTicksAndPromises(); - }); - - // check phase: execute available immediates; if an immediate callback invokes `setImmediate()` - // it will be invoked on the next event loop iteration - getImmediateCallbacks(immediates).forEach(callback => { - callback(); - execTicksAndPromises(); - }); - - // close callbacks phase: execute special `.on('close')` callbacks - getCloseCallbacks().forEach(callback => { - callback(); - execTicksAndPromises(); - }); - - if (refs === 0) { - // listeners of this event may execute code that increments `refs` - process.emit('beforeExit'); - } - } while (refs > 0); -} catch (err) { - if (!process.listenerCount('uncaughtException')) { - // default behavior: print stack and exit with status code 1 - console.error(err.stack); - process.exit(1); - } else { - // there are listeners: emit the event and exit using `process.exitCode || 0` - process.emit('uncaughtException'); - process.exit(); - } -} -``` - -## AWS Lambda function handler types in Node.js - -AWS Lambda handlers come in two flavors in Node.js: - -[Non-async handlers](https://docs.aws.amazon.com/lambda/latest/dg/nodejs-handler.html#nodejs-handler-sync) -(i.e. `callback`): - -```js -module.exports.handler = function (event, context, callback) { - try { - doSomething(); - callback(null, "Hello World!"); // Lambda returns "Hello World!" - } catch (err) { - // try/catch is not required, uncaught exceptions invoke `callback(err)` implicitly - callback(err); // Lambda fails with `err` - } -}; -``` - -[Async handlers](https://docs.aws.amazon.com/lambda/latest/dg/nodejs-handler.html#nodejs-handler-async) -(i.e. use `async`/`await` or `Promise`s): - -```js -// async/await -module.exports.handler = async function (event, context) { - try { - await doSomethingAsync(); - return "Hello World!"; // equivalent of: callback(null, "Hello World!"); - } catch (err) { - // try/cath is not required, async functions always return a Promise - throw err; // equivalent of: callback(err); - } -}; - -// Promise -module.exports.handler = function (event, context) { - /* - * must return a `Promise` to be considered an async handler - * - * an uncaught exception that prevents a `Promise` to be returned - * by the handler will "downgrade" the handler to non-async - */ - return Promise.resolve() - .then(() => doSomethingAsync()) - .then(() => "Hello World!"); -}; -``` - -While at first glance it seems like async VS non-async handlers are simply a code styling choice, -there is a fundamental difference between the two: - -- In async handlers, a Lambda function execution finishes when the `Promise` returned by the handler - resolves or rejects, regardless of whether the event loop is empty or not. -- In non-async handlers, a Lambda function execution finishes when one of the following conditions - occur: - - The event loop is empty - ([process `'beforeExit'` event](https://nodejs.org/dist/latest-v12.x/docs/api/process.html#process_event_beforeexit) - is used to detect this). - - The `callback` argument is invoked and - [`context.callbackWaitsForEmptyEventLoop`](https://docs.aws.amazon.com/lambda/latest/dg/nodejs-context.html) - is set to `false`. - -This fundamental difference is very important to understand in order to rationalize how `sequelize` -may be affected by it. Here are a few examples to illustrate the difference: - -```js -// no callback invoked -module.exports.handler = function () { - // Lambda finishes AFTER `doSomething()` is invoked - setTimeout(() => doSomething(), 1000); -}; - -// callback invoked -module.exports.handler = function (event, context, callback) { - // Lambda finishes AFTER `doSomething()` is invoked - setTimeout(() => doSomething(), 1000); - callback(null, "Hello World!"); -}; - -// callback invoked, context.callbackWaitsForEmptyEventLoop = false -module.exports.handler = function (event, context, callback) { - // Lambda finishes BEFORE `doSomething()` is invoked - context.callbackWaitsForEmptyEventLoop = false; - setTimeout(() => doSomething(), 2000); - setTimeout(() => callback(null, "Hello World!"), 1000); -}; - -// async/await -module.exports.handler = async function () { - // Lambda finishes BEFORE `doSomething()` is invoked - setTimeout(() => doSomething(), 1000); - return "Hello World!"; -}; - -// Promise -module.exports.handler = function () { - // Lambda finishes BEFORE `doSomething()` is invoked - setTimeout(() => doSomething(), 1000); - return Promise.resolve("Hello World!"); -}; -``` - -## AWS Lambda execution environments (i.e. containers) - -AWS Lambda function handlers are invoked by built-in or custom -[runtimes](https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html) which run in -execution environments (i.e. containers) that -[may or may not be re-used](https://aws.amazon.com/blogs/compute/container-reuse-in-lambda/) -across invocations. Containers can only process -[one request at a time](https://docs.aws.amazon.com/lambda/latest/dg/configuration-concurrency.html). -Concurrent invocations of a Lambda function means that a container instance will be created for each -concurrent request. - -In practice, this means that Lambda functions should be designed to be stateless but developers can -use state for caching purposes: - -```js -let sequelize = null; - -module.exports.handler = async function () { - /* - * sequelize will already be loaded if the container is re-used - * - * containers are never re-used when a Lambda function's code change - * - * while the time elapsed between Lambda invocations is used as a factor to determine whether - * a container is re-used, no assumptions should be made of when a container is actually re-used - * - * AWS does not publicly document the rules of container re-use "by design" since containers - * can be recycled in response to internal AWS Lambda events (e.g. a Lambda function container - * may be recycled even if the function is constanly invoked) - */ - if (!sequelize) { - sequelize = await loadSequelize(); - } - - return await doSomethingWithSequelize(sequelize); -}; -``` - -When a Lambda function doesn't wait for the event loop to be empty and a container is re-used, -the event loop will be "paused" until the next invocation occurs. For example: - -```js -let counter = 0; - -module.exports.handler = function (event, context, callback) { - /* - * The first invocation (i.e. container initialized) will: - * - log: - * - Fast timeout invoked. Request id: 00000000-0000-0000-0000-000000000000 | Elapsed ms: 5XX - * - return: 1 - * - * Wait 3 seconds and invoke the Lambda again. The invocation (i.e. container re-used) will: - * - log: - * - Slow timeout invoked. Request id: 00000000-0000-0000-0000-000000000000 | Elapsed ms: 3XXX - * - Fast timeout invoked. Request id: 11111111-1111-1111-1111-111111111111 | Elapsed ms: 5XX - * - return: 3 - */ - const now = Date.now(); - - context.callbackWaitsForEmptyEventLoop = false; - - setTimeout(() => { - console.log( - "Slow timeout invoked. Request id:", - context.awsRequestId, - "| Elapsed ms:", - Date.now() - now - ); - counter++; - }, 1000); - - setTimeout(() => { - console.log( - "Fast timeout invoked. Request id:", - context.awsRequestId, - "| Elapsed ms:", - Date.now() - now - ); - counter++; - callback(null, counter); - }, 500); -}; -``` - -## Sequelize connection pooling in AWS Lambda - -`sequelize` uses connection pooling for optimizing usage of database connections. The connection -pool used by `sequelize` is implemented using `setTimeout()` callbacks (which are processed by the -Node.js event loop). - -Given the fact that AWS Lambda containers process one request at a time, one would be tempted to -configure `sequelize` as follows: - -```js -const { Sequelize } = require('sequelize'); - -const sequelize = new Sequelize(/* (...) */, { - // (...) - pool: { min: 1, max: 1 } -}); -``` - -This configuration prevents Lambda containers from overwhelming the database server with an -excessive number of connections (since each container takes at most 1 connection). It also makes -sure that the container's connection is not garbage collected when idle so the connection does not -need to be re-established when the Lambda container is re-used. Unfortunately, this configuration -presents a set of issues: - -1. Lambdas that wait for the event loop to be empty will always time out. `sequelize` connection - pools schedule a `setTimeout` every - [`options.pool.evict`](../class/lib/sequelize.js~Sequelize.html#instance-constructor-constructor) - ms until **all idle connections have been closed**. However, since `min` is set to `1`, there - will always be at least one idle connection in the pool, resulting in an infinite event loop. -1. Some operations like - [`Model.findAndCountAll()`](../class/lib/model.js~Model.html#static-method-findAndCountAll) - execute multiple queries asynchronously (e.g. - [`Model.count()`](..class/lib/model.js~Model.html#static-method-count) and - [`Model.findAll()`](../class/lib/model.js~Model.html#static-method-findAll)). Using a maximum of - one connection forces the queries to be exectued serially (rather than in parallel using two - connections). While this may be an acceptable performance compromise in order to - maintain a manageable number of database connections, long running queries may result in - [`ConnectionAcquireTimeoutError`](../class/lib/errors/connection/connection-acquire-timeout-error.js~ConnectionAcquireTimeoutError.html) - if a query takes more than the default or configured - [`options.pool.acquire`](../class/lib/sequelize.js~Sequelize.html#instance-constructor-constructor) - timeout to complete. This is because the serialized query will be stuck waiting on the pool until - the connection used by the other query is released. -1. If the AWS Lambda function times out (i.e. the configured AWS Lambda timeout is exceeded), the - Node.js event loop will be "paused" regardless of its state. This can cause race conditions that - result in connection errors. For example, you may encounter situations where a very expensive - query causes a Lambda function to time out, the event loop is "paused" before the expensive query - finishes and the connection is released back to the pool, and subsequent Lambda invocations fail - with a `ConnectionAcquireTimeoutError` if the container is re-used and the connection has not - been returned after `options.pool.acquire` ms. - -You can attempt to mitigate issue **#2** by using `{ min: 1, max: 2 }`. However, this will still -suffer from issues **#1** and **#3** whilst introducing additional ones: - -1. Race conditions may occur where the even loop "pauses" before a connection pool eviction callback - executes or more than `options.pool.evict` time elapses between Lambda invocations. This can - result in timeout errors, handshake errors, and other connection-related errors. -1. If you use an operation like `Model.findAndCountAll()` and either the underlying `Model.count()` - or `Model.findAll()` queries fail, you won't be able to ensure that the other query has finished - executing (and the connection is put back into the pool) before the Lambda function execution - finishes and the event loop is "paused". This can leave connections in a stale state which can - result in prematurely closed TCP connections and other connection-related errors. - -Using `{ min: 2, max: 2 }` mitigates additional issue **#1**. However, the configuration still -suffers from all the other issues (original **#1**, **#3**, and additional **#2**). - -### Detailed race condition example - -In order to make sense of the example, you'll need a bit more context of how certain parts of -Lambda and `sequelize` are implemented. - -The built-in AWS Lambda runtime for `nodejs.12x` is implemented in Node.js. You can access the -entire source code of the runtime by reading the contents of `/var/runtime/` inside a Node.js Lambda -function. The relevant subset of the code is as follows: - -**runtime/Runtime.js** - -```js -class Runtime { - // (...) - - // each iteration is executed in the event loop `check` phase - scheduleIteration() { - setImmediate(() => this.handleOnce().then(/* (...) */)); - } - - async handleOnce() { - // get next invocation. see: https://docs.aws.amazon.com/lambda/latest/dg/runtimes-api.html#runtimes-api-next - let { bodyJson, headers } = await this.client.nextInvocation(); - - // prepare `context` handler parameter - let invokeContext = new InvokeContext(headers); - invokeContext.updateLoggingContext(); - - // prepare `callback` handler parameter - let [callback, callbackContext] = CallbackContext.build( - this.client, - invokeContext.invokeId, - this.scheduleIteration.bind(this) - ); - - try { - // this listener is subscribed to process.on('beforeExit') - // so that when when `context.callbackWaitsForEmptyEventLoop === true` - // the Lambda execution finishes after the event loop is empty - this._setDefaultExitListener(invokeContext.invokeId); - - // execute handler - const result = this.handler( - JSON.parse(bodyJson), - invokeContext.attachEnvironmentData(callbackContext), - callback - ); - - // finish the execution if the handler is async - if (_isPromise(result)) { - result - .then(callbackContext.succeed, callbackContext.fail) - .catch(callbackContext.fail); - } - } catch (err) { - callback(err); - } - } -} -``` - -The runtime schedules an iteration at the end of the initialization code: - -**runtime/index.js** - -```js -// (...) - -new Runtime(client, handler, errorCallbacks).scheduleIteration(); -``` - -All SQL queries invoked by a Lambda handler using `sequelize` are ultimately executed using -[Sequelize.prototype.query()](../class/lib/sequelize.js~Sequelize.html#instance-method-query). -This method is responsible for obtaining a connection from the pool, executing the query, and -releasing the connection back to the pool when the query completes. The following snippet shows -a simplification of the method's logic for queries without transactions: - -**sequelize.js** - -```js -class Sequelize { - // (...) - - query(sql, options) { - // (...) - - const connection = await this.connectionManager.getConnection(options); - const query = new this.dialect.Query(connection, this, options); - - try { - return await query.run(sql, bindParameters); - } finally { - await this.connectionManager.releaseConnection(connection); - } - } -} -``` - -The field `this.connectionManager` is an instance of a dialect-specific `ConnectionManager` class. -All dialect-specific managers inherit from an abstract `ConnectionManager` class which initializes -the connection pool and configures it to invoke the dialect-specific class' `connect()` method -everytime a new connection needs to be created. The following snippet shows a simplification of the -`mysql` dialect `connect()` method: - -**mysql/connection-manager.js** - -```js -class ConnectionManager { - // (...) - - async connect(config) { - // (...) - return await new Promise((resolve, reject) => { - // uses mysql2's `new Connection()` - const connection = this.lib.createConnection(connectionConfig); - - const errorHandler = (e) => { - connection.removeListener("connect", connectHandler); - connection.removeListener("error", connectHandler); - reject(e); - }; - - const connectHandler = () => { - connection.removeListener("error", errorHandler); - resolve(connection); - }; - - connection.on("error", errorHandler); - connection.once("connect", connectHandler); - }); - } -} -``` - -The field `this.lib` refers to [`mysql2`](https://www.npmjs.com/package/mysql2) and the function -`createConnection()` creates a connection by creating an instance of a `Connection` class. The -relevant subset of this class is as follows: - -**mysql2/connection.js** - -```js -class Connection extends EventEmitter { - constructor(opts) { - // (...) - - // create Socket - this.stream = /* (...) */; - - // when data is received, clear timeout - this.stream.on('data', data => { - if (this.connectTimeout) { - Timers.clearTimeout(this.connectTimeout); - this.connectTimeout = null; - } - this.packetParser.execute(data); - }); - - // (...) - - // when handshake is completed, emit the 'connect' event - handshakeCommand.on('end', () => { - this.emit('connect', handshakeCommand.handshake); - }); - - // set a timeout to trigger if no data is received on the socket - if (this.config.connectTimeout) { - const timeoutHandler = this._handleTimeoutError.bind(this); - this.connectTimeout = Timers.setTimeout( - timeoutHandler, - this.config.connectTimeout - ); - } - } - - // (...) - - _handleTimeoutError() { - if (this.connectTimeout) { - Timers.clearTimeout(this.connectTimeout); - this.connectTimeout = null; - } - this.stream.destroy && this.stream.destroy(); - const err = new Error('connect ETIMEDOUT'); - err.errorno = 'ETIMEDOUT'; - err.code = 'ETIMEDOUT'; - err.syscall = 'connect'; - - // this will emit the 'error' event - this._handleNetworkError(err); - } -} -``` - -Based on the previous code, the following sequence of events shows how a connection pooling -race condition with `{ min: 1, max: 1 }` can result with in a `ETIMEDOUT` error: - -1. A Lambda invocation is received (new container): - 1. The event loop enters the `check` phase and `runtime/Runtime.js`'s `handleOnce()` method is - invoked. - 1. The `handleOnce()` method invokes `await this.client.nextInvocation()` and waits. - 1. The event loop skips the `timers` phase since there no pending timers. - 1. The event loop enters the `poll` phase and the `handleOnce()` method continues. - 1. The Lambda handler is invoked. - 1. The Lambda handler invokes `Model.count()` which invokes `sequelize.js`'s `query()` which - invokes `connectionManager.getConnection()`. - 1. The connection pool initializes a `setTimeout(..., config.pool.acquire)` for `Model.count()` - and invokes `mysql/connection-manager.js`'s `connect()` to create a new connection. - 1. `mysql2/connection.js` creates the TCP socket and initializes a `setTimeout()` for failing - the connection with `ETIMEDOUT`. - 1. The promise returned by the handler rejects (for reasons not detailed here) so the Lambda - function execution finishes and the Node.js event loop is "paused". -1. Enough time elapses beween invocations so that: - 1. `config.pool.acquire` timer elapses. - 1. `mysql2` connection timer has not elapsed yet but has almost elapsed (i.e. race condition). -1. A second Lambda invocation is received (container re-used): - 1. The event loop is "resumed". - 1. The event loop enters the `check` phase and `runtime/Runtime.js`'s `handleOnce()` method is - invoked. - 1. The event loop enters the `timers` phase and the `config.pool.acquire` timer elapses, causing - the previous invocation's `Model.count()` promise to reject with - `ConnectionAcquireTimeoutError`. - 1. The event loop enters the `poll` phase and the `handleOnce()` method continues. - 1. The Lambda handler is invoked. - 1. The Lambda handler invokes `Model.count()` which invokes `sequelize.js`'s `query()` which - invokes `connectionManager.getConnection()`. - 1. The connection pool initializes a `setTimeout(..., config.pool.acquire)` for `Model.count()` - and since `{ max : 1 }` it waits for the pending `connect()` promise to complete. - 1. The event loop skips the `check` phase since there are no pending immediates. - 1. **Race condition:** The event loop enters the `timers` phase and the `mysql2` connection - timeout elapses, resulting in a `ETIMEDOUT` error that is emitted using - `connection.emit('error')`. - 1. The emitted event rejects the promise in `mysql/connection-manager.js`'s `connect()` which - in turn forwards the rejected promise to the `Model.count()` query's promise. - 1. The lambda function fails with an `ETIMEDOUT` error. diff --git a/docs/manual/other-topics/connection-pool.md b/docs/manual/other-topics/connection-pool.md deleted file mode 100644 index d8501ef5ef3c..000000000000 --- a/docs/manual/other-topics/connection-pool.md +++ /dev/null @@ -1,17 +0,0 @@ -# Connection Pool - -If you're connecting to the database from a single process, you should create only one Sequelize instance. Sequelize will set up a connection pool on initialization. This connection pool can be configured through the constructor's `options` parameter (using `options.pool`), as is shown in the following example: - -```js -const sequelize = new Sequelize(/* ... */, { - // ... - pool: { - max: 5, - min: 0, - acquire: 30000, - idle: 10000 - } -}); -``` - -Learn more in the [API Reference for the Sequelize constructor](../class/lib/sequelize.js~Sequelize.html#instance-constructor-constructor). If you're connecting to the database from multiple processes, you'll have to create one instance per process, but each instance should have a maximum connection pool size of such that the total maximum size is respected. For example, if you want a max connection pool size of 90 and you have three processes, the Sequelize instance of each process should have a max connection pool size of 30. diff --git a/docs/manual/other-topics/constraints-and-circularities.md b/docs/manual/other-topics/constraints-and-circularities.md deleted file mode 100644 index c48708a0168f..000000000000 --- a/docs/manual/other-topics/constraints-and-circularities.md +++ /dev/null @@ -1,113 +0,0 @@ -# Constraints & Circularities - -Adding constraints between tables means that tables must be created in the database in a certain order, when using `sequelize.sync`. If `Task` has a reference to `User`, the `User` table must be created before the `Task` table can be created. This can sometimes lead to circular references, where Sequelize cannot find an order in which to sync. Imagine a scenario of documents and versions. A document can have multiple versions, and for convenience, a document has a reference to its current version. - -```js -const { Sequelize, Model, DataTypes } = require("sequelize"); - -class Document extends Model {} -Document.init({ - author: DataTypes.STRING -}, { sequelize, modelName: 'document' }); - -class Version extends Model {} -Version.init({ - timestamp: DataTypes.DATE -}, { sequelize, modelName: 'version' }); - -Document.hasMany(Version); // This adds documentId attribute to version -Document.belongsTo(Version, { - as: 'Current', - foreignKey: 'currentVersionId' -}); // This adds currentVersionId attribute to document -``` - -However, unfortunately the code above will result in the following error: - -```text -Cyclic dependency found. documents is dependent of itself. Dependency chain: documents -> versions => documents -``` - -In order to alleviate that, we can pass `constraints: false` to one of the associations: - -```js -Document.hasMany(Version); -Document.belongsTo(Version, { - as: 'Current', - foreignKey: 'currentVersionId', - constraints: false -}); -``` - -Which will allow us to sync the tables correctly: - -```sql -CREATE TABLE IF NOT EXISTS "documents" ( - "id" SERIAL, - "author" VARCHAR(255), - "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL, - "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL, - "currentVersionId" INTEGER, - PRIMARY KEY ("id") -); - -CREATE TABLE IF NOT EXISTS "versions" ( - "id" SERIAL, - "timestamp" TIMESTAMP WITH TIME ZONE, - "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL, - "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL, - "documentId" INTEGER REFERENCES "documents" ("id") ON DELETE - SET - NULL ON UPDATE CASCADE, - PRIMARY KEY ("id") -); -``` - -## Enforcing a foreign key reference without constraints - -Sometimes you may want to reference another table, without adding any constraints, or associations. In that case you can manually add the reference attributes to your schema definition, and mark the relations between them. - -```js -class Trainer extends Model {} -Trainer.init({ - firstName: Sequelize.STRING, - lastName: Sequelize.STRING -}, { sequelize, modelName: 'trainer' }); - -// Series will have a trainerId = Trainer.id foreign reference key -// after we call Trainer.hasMany(series) -class Series extends Model {} -Series.init({ - title: Sequelize.STRING, - subTitle: Sequelize.STRING, - description: Sequelize.TEXT, - // Set FK relationship (hasMany) with `Trainer` - trainerId: { - type: DataTypes.INTEGER, - references: { - model: Trainer, - key: 'id' - } - } -}, { sequelize, modelName: 'series' }); - -// Video will have seriesId = Series.id foreign reference key -// after we call Series.hasOne(Video) -class Video extends Model {} -Video.init({ - title: Sequelize.STRING, - sequence: Sequelize.INTEGER, - description: Sequelize.TEXT, - // set relationship (hasOne) with `Series` - seriesId: { - type: DataTypes.INTEGER, - references: { - model: Series, // Can be both a string representing the table name or a Sequelize model - key: 'id' - } - } -}, { sequelize, modelName: 'video' }); - -Series.hasOne(Video); -Trainer.hasMany(Series); -``` \ No newline at end of file diff --git a/docs/manual/other-topics/dialect-specific-things.md b/docs/manual/other-topics/dialect-specific-things.md deleted file mode 100644 index ddb84142aa71..000000000000 --- a/docs/manual/other-topics/dialect-specific-things.md +++ /dev/null @@ -1,289 +0,0 @@ -# Dialect-Specific Things - -## Underlying Connector Libraries - -### MySQL - -The underlying connector library used by Sequelize for MySQL is the [mysql2](https://www.npmjs.com/package/mysql2) npm package (version 1.5.2 or higher). - -You can provide custom options to it using the `dialectOptions` in the Sequelize constructor: - -```js -const sequelize = new Sequelize('database', 'username', 'password', { - dialect: 'mysql', - dialectOptions: { - // Your mysql2 options here - } -}) -``` - -`dialectOptions` are passed directly to the MySQL connection constructor. A full list of options can be found in the [MySQL docs](https://www.npmjs.com/package/mysql#connection-options). - -### MariaDB - -The underlying connector library used by Sequelize for MariaDB is the [mariadb](https://www.npmjs.com/package/mariadb) npm package. - -You can provide custom options to it using the `dialectOptions` in the Sequelize constructor: - -```js -const sequelize = new Sequelize('database', 'username', 'password', { - dialect: 'mariadb', - dialectOptions: { - // Your mariadb options here - // connectTimeout: 1000 - } -}); -``` - -`dialectOptions` are passed directly to the MariaDB connection constructor. A full list of options can be found in the [MariaDB docs](https://mariadb.com/kb/en/nodejs-connection-options/). - -### SQLite - -The underlying connector library used by Sequelize for SQLite is the [sqlite3](https://www.npmjs.com/package/sqlite3) npm package (version 4.0.0 or above). - -You specify the storage file in the Sequelize constructor with the `storage` option (use `:memory:` for an in-memory SQLite instance). - -You can provide custom options to it using the `dialectOptions` in the Sequelize constructor: - -```js -const sequelize = new Sequelize('database', 'username', 'password', { - dialect: 'sqlite', - storage: 'path/to/database.sqlite' // or ':memory:' - dialectOptions: { - // Your sqlite3 options here - } -}); -``` - -The following fields may be passed to SQLite `dialectOptions`: - -- `readWriteMode`: Set the opening mode for the SQLite connection. Potential values are provided by the sqlite3 package, and can include sqlite3.OPEN_READONLY, sqlite3.OPEN_READWRITE, or sqlite3.OPEN_CREATE. See the [SQLite C interface documentation for more details]( https://www.sqlite.org/c3ref/open.html). - -### PostgreSQL - -The underlying connector library used by Sequelize for PostgreSQL is the [pg](https://www.npmjs.com/package/pg) npm package (version 7.0.0 or above). The module [pg-hstore](https://www.npmjs.com/package/pg-hstore) is also necessary. - -You can provide custom options to it using the `dialectOptions` in the Sequelize constructor: - -```js -const sequelize = new Sequelize('database', 'username', 'password', { - dialect: 'postgres', - dialectOptions: { - // Your pg options here - } -}); -``` - -The following fields may be passed to Postgres `dialectOptions`: - -- `application_name`: Name of application in pg_stat_activity. See the [Postgres docs](https://www.postgresql.org/docs/current/runtime-config-logging.html#GUC-APPLICATION-NAME) for details. -- `ssl`: SSL options. See the [`pg` docs](https://node-postgres.com/features/ssl) for details. -- `client_encoding`: // Setting 'auto' determines locale based on the client LC_CTYPE environment variable. See the [Postgres docs](https://www.postgresql.org/docs/current/multibyte.html) for details. -- `keepAlive`: Boolean to enable TCP KeepAlive. See the [`pg` changelog](https://github.com/brianc/node-postgres/blob/master/CHANGELOG.md#v600) for details. -- `statement_timeout`: Times out queries after a set time in milliseconds. Added in pg v7.3. See the [Postgres docs](https://www.postgresql.org/docs/current/runtime-config-client.html#GUC-STATEMENT-TIMEOUT) for details. -- `idle_in_transaction_session_timeout`: Terminate any session with an open transaction that has been idle for longer than the specified duration in milliseconds. See the [Postgres docs](https://www.postgresql.org/docs/current/runtime-config-client.html#GUC-IDLE-IN-TRANSACTION-SESSION-TIMEOUT) for details. - -To connect over a unix domain socket, specify the path to the socket directory in the `host` option. The socket path must start with `/`. - -```js -const sequelize = new Sequelize('database', 'username', 'password', { - dialect: 'postgres', - host: '/path/to/socket_directory' -}); -``` - -The default `client_min_messages` config in sequelize is `WARNING`. - -### Redshift - -Most configuration is same as PostgreSQL above. - -Redshift doesn't support `client_min_messages`, 'ignore' is needed to skip the configuration: - -```js -const sequelize = new Sequelize('database', 'username', 'password', { - dialect: 'postgres', - dialectOptions: { - // Your pg options here - // ... - clientMinMessages: 'ignore' // case insensitive - } -}); -``` - -### MSSQL - -The underlying connector library used by Sequelize for MSSQL is the [tedious](https://www.npmjs.com/package/tedious) npm package (version 6.0.0 or above). - -You can provide custom options to it using `dialectOptions.options` in the Sequelize constructor: - -```js -const sequelize = new Sequelize('database', 'username', 'password', { - dialect: 'mssql', - dialectOptions: { - // Observe the need for this nested `options` field for MSSQL - options: { - // Your tedious options here - useUTC: false, - dateFirst: 1 - } - } -}); -``` - -A full list of options can be found in the [tedious docs](https://tediousjs.github.io/tedious/api-connection.html#function_newConnection). - -#### MSSQL Domain Account - -In order to connect with a domain account, use the following format. - -```js -const sequelize = new Sequelize('database', null, null, { - dialect: 'mssql', - dialectOptions: { - authentication: { - type: 'ntlm', - options: { - domain: 'yourDomain', - userName: 'username', - password: 'password' - } - }, - options: { - instanceName: 'SQLEXPRESS' - } - } -}) -``` - -### Snowflake (Experiment) - -The underlying connector library used by Sequelize for Snowflake is the [snowflake-sdk](https://www.npmjs.com/package/snowflake-sdk) npm package. - -In order to connect with an account, use the following format: - -```js -const sequelize = new Sequelize('database', null, null, { - dialect: 'snowflake', - dialectOptions: { - // put your snowflake account here, - account: 'myAccount', // my-app.us-east-1 - - // below option should be optional - role: 'myRole', - warehouse: 'myWarehouse', - schema: 'mySchema' - }, - // same as other dialect - username: 'myUserName', - password: 'myPassword', - database: 'myDatabaseName' -}) -``` - -**NOTE** There is no test sandbox provided so the snowflake integration test is not part of the pipeline. Also it is difficult for core team to triage and debug. This dialect needs to be maintained by the snowflake user/community for now. - -For running integration test: - -```sh -SEQ_ACCOUNT=myAccount SEQ_USER=myUser SEQ_PW=myPassword SEQ_ROLE=myRole SEQ_DB=myDatabaseName SEQ_SCHEMA=mySchema SEQ_WH=myWareHouse npm run test-integration-snowflake -``` - -## Data type: TIMESTAMP WITHOUT TIME ZONE - PostgreSQL only - -If you are working with the PostgreSQL `TIMESTAMP WITHOUT TIME ZONE` and you need to parse it to a different timezone, please use the pg library's own parser: - -```js -require('pg').types.setTypeParser(1114, stringValue => { - return new Date(stringValue + '+0000'); - // e.g., UTC offset. Use any offset that you would like. -}); -``` - -## Data type: ARRAY(ENUM) - PostgreSQL only - -Array(Enum) type requireS special treatment. Whenever Sequelize will talk to the database, it has to typecast array values with ENUM name. - -So this enum name must follow this pattern `enum__`. If you are using `sync` then correct name will automatically be generated. - -## Table Hints - MSSQL only - -The `tableHint` option can be used to define a table hint. The hint must be a value from `TableHints` and should only be used when absolutely necessary. Only a single table hint is currently supported per query. - -Table hints override the default behavior of MSSQL query optimizer by specifing certain options. They only affect the table or view referenced in that clause. - -```js -const { TableHints } = require('sequelize'); -Project.findAll({ - // adding the table hint NOLOCK - tableHint: TableHints.NOLOCK - // this will generate the SQL 'WITH (NOLOCK)' -}) -``` - -## Index Hints - MySQL/MariaDB only - -The `indexHints` option can be used to define index hints. The hint type must be a value from `IndexHints` and the values should reference existing indexes. - -Index hints [override the default behavior of the MySQL query optimizer](https://dev.mysql.com/doc/refman/5.7/en/index-hints.html). - -```js -const { IndexHints } = require("sequelize"); -Project.findAll({ - indexHints: [ - { type: IndexHints.USE, values: ['index_project_on_name'] } - ], - where: { - id: { - [Op.gt]: 623 - }, - name: { - [Op.like]: 'Foo %' - } - } -}); -``` - -The above will generate a MySQL query that looks like this: - -```sql -SELECT * FROM Project USE INDEX (index_project_on_name) WHERE name LIKE 'FOO %' AND id > 623; -``` - -`Sequelize.IndexHints` includes `USE`, `FORCE`, and `IGNORE`. - -See [Issue #9421](https://github.com/sequelize/sequelize/issues/9421) for the original API proposal. - -## Engines - MySQL/MariaDB only - -The default engine for a model is InnoDB. - -You can change the engine for a model with the `engine` option (e.g., to MyISAM): - -```js -const Person = sequelize.define('person', { /* attributes */ }, { - engine: 'MYISAM' -}); -``` - -Like every option for the definition of a model, this setting can also be changed globally with the `define` option of the Sequelize constructor: - -```js -const sequelize = new Sequelize(db, user, pw, { - define: { engine: 'MYISAM' } -}) -``` - -## Table comments - MySQL/MariaDB/PostgreSQL only - -You can specify a comment for a table when defining the model: - -```js -class Person extends Model {} -Person.init({ /* attributes */ }, { - comment: "I'm a table comment!", - sequelize -}) -``` - -The comment will be set when calling `sync()`. diff --git a/docs/manual/other-topics/extending-data-types.md b/docs/manual/other-topics/extending-data-types.md deleted file mode 100644 index 2e0938916faf..000000000000 --- a/docs/manual/other-topics/extending-data-types.md +++ /dev/null @@ -1,113 +0,0 @@ -# Extending Data Types - -Most likely the type you are trying to implement is already included in [DataTypes](data-types.html). If a new datatype is not included, this manual will show how to write it yourself. - -Sequelize doesn't create new datatypes in the database. This tutorial explains how to make Sequelize recognize new datatypes and assumes that those new datatypes are already created in the database. - -To extend Sequelize datatypes, do it before any Sequelize instance is created. - -## Example - -In this example, we will create a type called `SOMETYPE` that replicates the built-in datatype `DataTypes.INTEGER(11).ZEROFILL.UNSIGNED`. - -```js -const { Sequelize, DataTypes, Utils } = require('Sequelize'); -createTheNewDataType(); -const sequelize = new Sequelize('sqlite::memory:'); - -function createTheNewDataType() { - - class SOMETYPE extends DataTypes.ABSTRACT { - // Mandatory: complete definition of the new type in the database - toSql() { - return 'INTEGER(11) UNSIGNED ZEROFILL' - } - - // Optional: validator function - validate(value, options) { - return (typeof value === 'number') && (!Number.isNaN(value)); - } - - // Optional: sanitizer - _sanitize(value) { - // Force all numbers to be positive - return value < 0 ? 0 : Math.round(value); - } - - // Optional: value stringifier before sending to database - _stringify(value) { - return value.toString(); - } - - // Optional: parser for values received from the database - static parse(value) { - return Number.parseInt(value); - } - } - - // Mandatory: set the type key - SOMETYPE.prototype.key = SOMETYPE.key = 'SOMETYPE'; - - // Mandatory: add the new type to DataTypes. Optionally wrap it on `Utils.classToInvokable` to - // be able to use this datatype directly without having to call `new` on it. - DataTypes.SOMETYPE = Utils.classToInvokable(SOMETYPE); - - // Optional: disable escaping after stringifier. Do this at your own risk, since this opens opportunity for SQL injections. - // DataTypes.SOMETYPE.escape = false; - -} -``` - -After creating this new datatype, you need to map this datatype in each database dialect and make some adjustments. - -## PostgreSQL - -Let's say the name of the new datatype is `pg_new_type` in the postgres database. That name has to be mapped to `DataTypes.SOMETYPE`. Additionally, it is required to create a child postgres-specific datatype. - -```js -function createTheNewDataType() { - // [...] - - const PgTypes = DataTypes.postgres; - - // Mandatory: map postgres datatype name - DataTypes.SOMETYPE.types.postgres = ['pg_new_type']; - - // Mandatory: create a postgres-specific child datatype with its own parse - // method. The parser will be dynamically mapped to the OID of pg_new_type. - PgTypes.SOMETYPE = function SOMETYPE() { - if (!(this instanceof PgTypes.SOMETYPE)) { - return new PgTypes.SOMETYPE(); - } - DataTypes.SOMETYPE.apply(this, arguments); - } - const util = require('util'); // Built-in Node package - util.inherits(PgTypes.SOMETYPE, DataTypes.SOMETYPE); - - // Mandatory: create, override or reassign a postgres-specific parser - // PgTypes.SOMETYPE.parse = value => value; - PgTypes.SOMETYPE.parse = DataTypes.SOMETYPE.parse || x => x; - - // Optional: add or override methods of the postgres-specific datatype - // like toSql, escape, validate, _stringify, _sanitize... - -} -``` - -### Ranges - -After a new range type has been [defined in postgres](https://www.postgresql.org/docs/current/static/rangetypes.html#RANGETYPES-DEFINING), it is trivial to add it to Sequelize. - -In this example the name of the postgres range type is `SOMETYPE_range` and the name of the underlying postgres datatype is `pg_new_type`. The key of `subtypes` and `castTypes` is the key of the Sequelize datatype `DataTypes.SOMETYPE.key`, in lower case. - -```js -function createTheNewDataType() { - // [...] - - // Add postgresql range, SOMETYPE comes from DataType.SOMETYPE.key in lower case - DataTypes.RANGE.types.postgres.subtypes.SOMETYPE = 'SOMETYPE_range'; - DataTypes.RANGE.types.postgres.castTypes.SOMETYPE = 'pg_new_type'; -} -``` - -The new range can be used in model definitions as `DataTypes.RANGE(DataTypes.SOMETYPE)` or `DataTypes.RANGE(DataTypes.SOMETYPE)`. diff --git a/docs/manual/other-topics/hooks.md b/docs/manual/other-topics/hooks.md deleted file mode 100644 index 682b6cda7ac9..000000000000 --- a/docs/manual/other-topics/hooks.md +++ /dev/null @@ -1,403 +0,0 @@ -# Hooks - -Hooks (also known as lifecycle events), are functions which are called before and after calls in sequelize are executed. For example, if you want to always set a value on a model before saving it, you can add a `beforeUpdate` hook. - -**Note:** _You can't use hooks with instances. Hooks are used with models._ - -## Available hooks - -Sequelize provides a lot of hooks. The full list can be found in directly in the [source code - lib/hooks.js](https://github.com/sequelize/sequelize/blob/v6/lib/hooks.js#L7). - -## Hooks firing order - -The diagram below shows the firing order for the most common hooks. - -_**Note:** this list is not exhaustive._ - -```text -(1) - beforeBulkCreate(instances, options) - beforeBulkDestroy(options) - beforeBulkUpdate(options) -(2) - beforeValidate(instance, options) - -[... validation happens ...] - -(3) - afterValidate(instance, options) - validationFailed(instance, options, error) -(4) - beforeCreate(instance, options) - beforeDestroy(instance, options) - beforeUpdate(instance, options) - beforeSave(instance, options) - beforeUpsert(values, options) - -[... creation/update/destruction happens ...] - -(5) - afterCreate(instance, options) - afterDestroy(instance, options) - afterUpdate(instance, options) - afterSave(instance, options) - afterUpsert(created, options) -(6) - afterBulkCreate(instances, options) - afterBulkDestroy(options) - afterBulkUpdate(options) -``` - -## Declaring Hooks - -Arguments to hooks are passed by reference. This means, that you can change the values, and this will be reflected in the insert / update statement. A hook may contain async actions - in this case the hook function should return a promise. - -There are currently three ways to programmatically add hooks: - -```js -// Method 1 via the .init() method -class User extends Model {} -User.init({ - username: DataTypes.STRING, - mood: { - type: DataTypes.ENUM, - values: ['happy', 'sad', 'neutral'] - } -}, { - hooks: { - beforeValidate: (user, options) => { - user.mood = 'happy'; - }, - afterValidate: (user, options) => { - user.username = 'Toni'; - } - }, - sequelize -}); - -// Method 2 via the .addHook() method -User.addHook('beforeValidate', (user, options) => { - user.mood = 'happy'; -}); - -User.addHook('afterValidate', 'someCustomName', (user, options) => { - return Promise.reject(new Error("I'm afraid I can't let you do that!")); -}); - -// Method 3 via the direct method -User.beforeCreate(async (user, options) => { - const hashedPassword = await hashPassword(user.password); - user.password = hashedPassword; -}); - -User.afterValidate('myHookAfter', (user, options) => { - user.username = 'Toni'; -}); -``` - -## Removing hooks - -Only a hook with name param can be removed. - -```js -class Book extends Model {} -Book.init({ - title: DataTypes.STRING -}, { sequelize }); - -Book.addHook('afterCreate', 'notifyUsers', (book, options) => { - // ... -}); - -Book.removeHook('afterCreate', 'notifyUsers'); -``` - -You can have many hooks with same name. Calling `.removeHook()` will remove all of them. - -## Global / universal hooks - -Global hooks are hooks that are run for all models. They are especially useful for plugins and can define behaviours that you want for all your models, for example to allow customization on timestamps using `sequelize.define` on your models: - -```js -const User = sequelize.define('User', {}, { - tableName: 'users', - hooks : { - beforeCreate : (record, options) => { - record.dataValues.createdAt = new Date().toISOString().replace(/T/, ' ').replace(/\..+/g, ''); - record.dataValues.updatedAt = new Date().toISOString().replace(/T/, ' ').replace(/\..+/g, ''); - }, - beforeUpdate : (record, options) => { - record.dataValues.updatedAt = new Date().toISOString().replace(/T/, ' ').replace(/\..+/g, ''); - } - } -}); -``` - -They can be defined in many ways, which have slightly different semantics: - -### Default Hooks (on Sequelize constructor options) - -```js -const sequelize = new Sequelize(..., { - define: { - hooks: { - beforeCreate() { - // Do stuff - } - } - } -}); -``` - -This adds a default hook to all models, which is run if the model does not define its own `beforeCreate` hook: - -```js -const User = sequelize.define('User', {}); -const Project = sequelize.define('Project', {}, { - hooks: { - beforeCreate() { - // Do other stuff - } - } -}); - -await User.create({}); // Runs the global hook -await Project.create({}); // Runs its own hook (because the global hook is overwritten) -``` - -### Permanent Hooks (with `sequelize.addHook`) - -```js -sequelize.addHook('beforeCreate', () => { - // Do stuff -}); -``` - -This hook is always run, whether or not the model specifies its own `beforeCreate` hook. Local hooks are always run before global hooks: - -```js -const User = sequelize.define('User', {}); -const Project = sequelize.define('Project', {}, { - hooks: { - beforeCreate() { - // Do other stuff - } - } -}); - -await User.create({}); // Runs the global hook -await Project.create({}); // Runs its own hook, followed by the global hook -``` - -Permanent hooks may also be defined in the options passed to the Sequelize constructor: - -```js -new Sequelize(..., { - hooks: { - beforeCreate() { - // do stuff - } - } -}); -``` - -Note that the above is not the same as the *Default Hooks* mentioned above. That one uses the `define` option of the constructor. This one does not. - -### Connection Hooks - -Sequelize provides four hooks that are executed immediately before and after a database connection is obtained or released: - -* `sequelize.beforeConnect(callback)` - * The callback has the form `async (config) => /* ... */` -* `sequelize.afterConnect(callback)` - * The callback has the form `async (connection, config) => /* ... */` -* `sequelize.beforeDisconnect(callback)` - * The callback has the form `async (connection) => /* ... */` -* `sequelize.afterDisconnect(callback)` - * The callback has the form `async (connection) => /* ... */` - -These hooks can be useful if you need to asynchronously obtain database credentials, or need to directly access the low-level database connection after it has been created. - -For example, we can asynchronously obtain a database password from a rotating token store, and mutate Sequelize's configuration object with the new credentials: - -```js -sequelize.beforeConnect(async (config) => { - config.password = await getAuthToken(); -}); -``` - -These hooks may *only* be declared as a permanent global hook, as the connection pool is shared by all models. - -## Instance hooks - -The following hooks will emit whenever you're editing a single object: - -* `beforeValidate` -* `afterValidate` / `validationFailed` -* `beforeCreate` / `beforeUpdate` / `beforeSave` / `beforeDestroy` -* `afterCreate` / `afterUpdate` / `afterSave` / `afterDestroy` - -```js -User.beforeCreate(user => { - if (user.accessLevel > 10 && user.username !== "Boss") { - throw new Error("You can't grant this user an access level above 10!"); - } -}); -``` - -The following example will throw an error: - -```js -try { - await User.create({ username: 'Not a Boss', accessLevel: 20 }); -} catch (error) { - console.log(error); // You can't grant this user an access level above 10! -}; -``` - -The following example will be successful: - -```js -const user = await User.create({ username: 'Boss', accessLevel: 20 }); -console.log(user); // user object with username 'Boss' and accessLevel of 20 -``` - -### Model hooks - -Sometimes you'll be editing more than one record at a time by using methods like `bulkCreate`, `update` and `destroy`. The following hooks will emit whenever you're using one of those methods: - -* `YourModel.beforeBulkCreate(callback)` - * The callback has the form `(instances, options) => /* ... */` -* `YourModel.beforeBulkUpdate(callback)` - * The callback has the form `(options) => /* ... */` -* `YourModel.beforeBulkDestroy(callback)` - * The callback has the form `(options) => /* ... */` -* `YourModel.afterBulkCreate(callback)` - * The callback has the form `(instances, options) => /* ... */` -* `YourModel.afterBulkUpdate(callback)` - * The callback has the form `(options) => /* ... */` -* `YourModel.afterBulkDestroy(callback)` - * The callback has the form `(options) => /* ... */` - -Note: methods like `bulkCreate` do not emit individual hooks by default - only the bulk hooks. However, if you want individual hooks to be emitted as well, you can pass the `{ individualHooks: true }` option to the query call. However, this can drastically impact performance, depending on the number of records involved (since, among other things, all instances will be loaded into memory). Examples: - -```js -await Model.destroy({ - where: { accessLevel: 0 }, - individualHooks: true -}); -// This will select all records that are about to be deleted and emit `beforeDestroy` and `afterDestroy` on each instance. - -await Model.update({ username: 'Tony' }, { - where: { accessLevel: 0 }, - individualHooks: true -}); -// This will select all records that are about to be updated and emit `beforeUpdate` and `afterUpdate` on each instance. -``` - -If you use `Model.bulkCreate(...)` with the `updateOnDuplicate` option, changes made in the hook to fields that aren't given in the `updateOnDuplicate` array will not be persisted to the database. However it is possible to change the `updateOnDuplicate` option inside the hook if this is what you want. - -```js -User.beforeBulkCreate((users, options) => { - for (const user of users) { - if (user.isMember) { - user.memberSince = new Date(); - } - } - - // Add `memberSince` to updateOnDuplicate otherwise it won't be persisted - if (options.updateOnDuplicate && !options.updateOnDuplicate.includes('memberSince')) { - options.updateOnDuplicate.push('memberSince'); - } -}); - -// Bulk updating existing users with updateOnDuplicate option -await Users.bulkCreate([ - { id: 1, isMember: true }, - { id: 2, isMember: false } -], { - updateOnDuplicate: ['isMember'] -}); -``` - -## Associations - -For the most part hooks will work the same for instances when being associated. - -### One-to-One and One-to-Many associations - -* When using `add`/`set` mixin methods the `beforeUpdate` and `afterUpdate` hooks will run. - -* The `beforeDestroy` and `afterDestroy` hooks will only be called on associations that have `onDelete: 'CASCADE'` and `hooks: true`. For example: - -```js -class Projects extends Model {} -Projects.init({ - title: DataTypes.STRING -}, { sequelize }); - -class Tasks extends Model {} -Tasks.init({ - title: DataTypes.STRING -}, { sequelize }); - -Projects.hasMany(Tasks, { onDelete: 'CASCADE', hooks: true }); -Tasks.belongsTo(Projects); -``` - -This code will run `beforeDestroy` and `afterDestroy` hooks on the Tasks model. - -Sequelize, by default, will try to optimize your queries as much as possible. When calling cascade on delete, Sequelize will simply execute: - -```sql -DELETE FROM `table` WHERE associatedIdentifier = associatedIdentifier.primaryKey -``` - -However, adding `hooks: true` explicitly tells Sequelize that optimization is not of your concern. Then, Sequelize will first perform a `SELECT` on the associated objects and destroy each instance, one by one, in order to be able to properly call the hooks (with the right parameters). - -### Many-to-Many associations - -* When using `add` mixin methods for `belongsToMany` relationships (that will add one or more records to the junction table) the `beforeBulkCreate` and `afterBulkCreate` hooks in the junction model will run. - * If `{ individualHooks: true }` was passed to the call, then each individual hook will also run. - -* When using `remove` mixin methods for `belongsToMany` relationships (that will remove one or more records to the junction table) the `beforeBulkDestroy` and `afterBulkDestroy` hooks in the junction model will run. - * If `{ individualHooks: true }` was passed to the call, then each individual hook will also run. - -If your association is Many-to-Many, you may be interested in firing hooks on the through model when using the `remove` call. Internally, sequelize is using `Model.destroy` resulting in calling the `bulkDestroy` instead of the `before/afterDestroy` hooks on each through instance. - -## Hooks and Transactions - -Many model operations in Sequelize allow you to specify a transaction in the options parameter of the method. If a transaction *is* specified in the original call, it will be present in the options parameter passed to the hook function. For example, consider the following snippet: - -```js -User.addHook('afterCreate', async (user, options) => { - // We can use `options.transaction` to perform some other call - // using the same transaction of the call that triggered this hook - await User.update({ mood: 'sad' }, { - where: { - id: user.id - }, - transaction: options.transaction - }); -}); - -await sequelize.transaction(async t => { - await User.create({ - username: 'someguy', - mood: 'happy' - }, { - transaction: t - }); -}); -``` - -If we had not included the transaction option in our call to `User.update` in the preceding code, no change would have occurred, since our newly created user does not exist in the database until the pending transaction has been committed. - -### Internal Transactions - -It is very important to recognize that sequelize may make use of transactions internally for certain operations such as `Model.findOrCreate`. If your hook functions execute read or write operations that rely on the object's presence in the database, or modify the object's stored values like the example in the preceding section, you should always specify `{ transaction: options.transaction }`: - -* If a transaction was used, then `{ transaction: options.transaction }` will ensure it is used again; -* Otherwise, `{ transaction: options.transaction }` will be equivalent to `{ transaction: undefined }`, which won't use a transaction (which is ok). - -This way your hooks will always behave correctly. diff --git a/docs/manual/other-topics/indexes.md b/docs/manual/other-topics/indexes.md deleted file mode 100644 index 123ec878457e..000000000000 --- a/docs/manual/other-topics/indexes.md +++ /dev/null @@ -1,47 +0,0 @@ -# Indexes - -Sequelize supports adding indexes to the model definition which will be created on [`sequelize.sync()`](../class/lib/sequelize.js~Sequelize.html#instance-method-sync). - -```js -const User = sequelize.define('User', { /* attributes */ }, { - indexes: [ - // Create a unique index on email - { - unique: true, - fields: ['email'] - }, - - // Creates a gin index on data with the jsonb_path_ops operator - { - fields: ['data'], - using: 'gin', - operator: 'jsonb_path_ops' - }, - - // By default index name will be [table]_[fields] - // Creates a multi column partial index - { - name: 'public_by_author', - fields: ['author', 'status'], - where: { - status: 'public' - } - }, - - // A BTREE index with an ordered field - { - name: 'title_index', - using: 'BTREE', - fields: [ - 'author', - { - attribute: 'title', - collate: 'en_US', - order: 'DESC', - length: 5 - } - ] - } - ] -}); -``` \ No newline at end of file diff --git a/docs/manual/other-topics/legacy.md b/docs/manual/other-topics/legacy.md deleted file mode 100644 index 249f5a9638de..000000000000 --- a/docs/manual/other-topics/legacy.md +++ /dev/null @@ -1,71 +0,0 @@ -# Working with Legacy Tables - -While out of the box Sequelize will seem a bit opinionated it's easy to work legacy tables and forward proof your application by defining (otherwise generated) table and field names. - -## Tables - -```js -class User extends Model {} -User.init({ - // ... -}, { - modelName: 'user', - tableName: 'users', - sequelize, -}); -``` - -## Fields - -```js -class MyModel extends Model {} -MyModel.init({ - userId: { - type: DataTypes.INTEGER, - field: 'user_id' - } -}, { sequelize }); -``` - -## Primary keys - -Sequelize will assume your table has a `id` primary key property by default. - -To define your own primary key: - -```js -class Collection extends Model {} -Collection.init({ - uid: { - type: DataTypes.INTEGER, - primaryKey: true, - autoIncrement: true // Automatically gets converted to SERIAL for postgres - } -}, { sequelize }); - -class Collection extends Model {} -Collection.init({ - uuid: { - type: DataTypes.UUID, - primaryKey: true - } -}, { sequelize }); -``` - -And if your model has no primary key at all you can use `Model.removeAttribute('id');` - -## Foreign keys - -```js -// 1:1 -Organization.belongsTo(User, { foreignKey: 'owner_id' }); -User.hasOne(Organization, { foreignKey: 'owner_id' }); - -// 1:M -Project.hasMany(Task, { foreignKey: 'tasks_pk' }); -Task.belongsTo(Project, { foreignKey: 'tasks_pk' }); - -// N:M -User.belongsToMany(Role, { through: 'user_has_roles', foreignKey: 'user_role_user_id' }); -Role.belongsToMany(User, { through: 'user_has_roles', foreignKey: 'roles_identifier' }); -``` diff --git a/docs/manual/other-topics/legal.md b/docs/manual/other-topics/legal.md deleted file mode 100644 index 0d8d4b428b2a..000000000000 --- a/docs/manual/other-topics/legal.md +++ /dev/null @@ -1,49 +0,0 @@ -# Legal Notice - -## License - -Sequelize library is distributed with MIT license. You can find original license [here.](https://github.com/sequelize/sequelize/blob/main/LICENSE) - -```text -MIT License - -Copyright (c) 2014-present Sequelize contributors - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -``` - -## AUTHOR(S) - -```text -Main author: - -Sascha Depold -Uhlandstr. 160 -10719 Berlin -sascha [at] depold [dot] com -[plus] 49 152 [slash] 03878582 - -``` - -## INHALTLICHE VERANTWORTUNG - -```text -Ich übernehme keine Haftung für ausgehende Links. -Daher musst du dich bei Problemen an deren Betreiber wenden! -``` diff --git a/docs/manual/other-topics/migrations.md b/docs/manual/other-topics/migrations.md deleted file mode 100644 index 7b869738146c..000000000000 --- a/docs/manual/other-topics/migrations.md +++ /dev/null @@ -1,565 +0,0 @@ -# Migrations - -Just like you use [version control](https://en.wikipedia.org/wiki/Version_control) systems such as [Git](https://en.wikipedia.org/wiki/Git) to manage changes in your source code, you can use **migrations** to keep track of changes to the database. With migrations you can transfer your existing database into another state and vice versa: Those state transitions are saved in migration files, which describe how to get to the new state and how to revert the changes in order to get back to the old state. - -You will need the [Sequelize Command-Line Interface (CLI)](https://github.com/sequelize/cli). The CLI ships support for migrations and project bootstrapping. - -A Migration in Sequelize is javascript file which exports two functions, `up` and `down`, that dictate how to perform the migration and undo it. You define those functions manually, but you don't call them manually; they will be called automatically by the CLI. In these functions, you should simply perform whatever queries you need, with the help of `sequelize.query` and whichever other methods Sequelize provides to you. There is no extra magic beyond that. - -## Installing the CLI - -To install the Sequelize CLI: - -```text -npm install --save-dev sequelize-cli -``` - -For details see the [CLI GitHub repository](https://github.com/sequelize/cli). - -## Project bootstrapping - -To create an empty project you will need to execute `init` command - -```text -npx sequelize-cli init -``` - -This will create following folders - -- `config`, contains config file, which tells CLI how to connect with database -- `models`, contains all models for your project -- `migrations`, contains all migration files -- `seeders`, contains all seed files - -### Configuration - -Before continuing further we will need to tell the CLI how to connect to the database. To do that let's open default config file `config/config.json`. It looks something like this: - -```json -{ - "development": { - "username": "root", - "password": null, - "database": "database_development", - "host": "127.0.0.1", - "dialect": "mysql" - }, - "test": { - "username": "root", - "password": null, - "database": "database_test", - "host": "127.0.0.1", - "dialect": "mysql" - }, - "production": { - "username": "root", - "password": null, - "database": "database_production", - "host": "127.0.0.1", - "dialect": "mysql" - } -} -``` - -Note that the Sequelize CLI assumes mysql by default. If you're using another dialect, you need to change the content of the `"dialect"` option. - -Now edit this file and set correct database credentials and dialect. The keys of the objects (e.g. "development") are used on `model/index.js` for matching `process.env.NODE_ENV` (When undefined, "development" is a default value). - -Sequelize will use the default connection port for each dialect (for example, for postgres, it is port 5432). If you need to specify a different port, use the `"port"` field (it is not present by default in `config/config.js` but you can simply add it). - -**Note:** _If your database doesn't exist yet, you can just call `db:create` command. With proper access it will create that database for you._ - -## Creating the first Model (and Migration) - -Once you have properly configured CLI config file you are ready to create your first migration. It's as simple as executing a simple command. - -We will use `model:generate` command. This command requires two options: - -- `name`: the name of the model; -- `attributes`: the list of model attributes. - -Let's create a model named `User`. - -```text -npx sequelize-cli model:generate --name User --attributes firstName:string,lastName:string,email:string -``` - -This will: - -- Create a model file `user` in `models` folder; -- Create a migration file with name like `XXXXXXXXXXXXXX-create-user.js` in `migrations` folder. - -**Note:** _Sequelize will only use Model files, it's the table representation. On the other hand, the migration file is a change in that model or more specifically that table, used by CLI. Treat migrations like a commit or a log for some change in database._ - -## Running Migrations - -Until this step, we haven't inserted anything into the database. We have just created the required model and migration files for our first model, `User`. Now to actually create that table in the database you need to run `db:migrate` command. - -```text -npx sequelize-cli db:migrate -``` - -This command will execute these steps: - -- Will ensure a table called `SequelizeMeta` in database. This table is used to record which migrations have run on the current database -- Start looking for any migration files which haven't run yet. This is possible by checking `SequelizeMeta` table. In this case it will run `XXXXXXXXXXXXXX-create-user.js` migration, which we created in last step. -- Creates a table called `Users` with all columns as specified in its migration file. - -## Undoing Migrations - -Now our table has been created and saved in the database. With migration you can revert to old state by just running a command. - -You can use `db:migrate:undo`, this command will revert most the recent migration. - -```text -npx sequelize-cli db:migrate:undo -``` - -You can revert back to the initial state by undoing all migrations with the `db:migrate:undo:all` command. You can also revert back to a specific migration by passing its name with the `--to` option. - -```text -npx sequelize-cli db:migrate:undo:all --to XXXXXXXXXXXXXX-create-posts.js -``` - -### Creating the first Seed - -Suppose we want to insert some data into a few tables by default. If we follow up on the previous example we can consider creating a demo user for the `User` table. - -To manage all data migrations you can use seeders. Seed files are some change in data that can be used to populate database tables with sample or test data. - -Let's create a seed file which will add a demo user to our `User` table. - -```text -npx sequelize-cli seed:generate --name demo-user -``` - -This command will create a seed file in `seeders` folder. File name will look something like `XXXXXXXXXXXXXX-demo-user.js`. It follows the same `up / down` semantics as the migration files. - -Now we should edit this file to insert demo user to `User` table. - -```js -module.exports = { - up: (queryInterface, Sequelize) => { - return queryInterface.bulkInsert('Users', [{ - firstName: 'John', - lastName: 'Doe', - email: 'example@example.com', - createdAt: new Date(), - updatedAt: new Date() - }]); - }, - down: (queryInterface, Sequelize) => { - return queryInterface.bulkDelete('Users', null, {}); - } -}; -``` - -## Running Seeds - -In last step you created a seed file; however, it has not been committed to the database. To do that we run a simple command. - -```text -npx sequelize-cli db:seed:all -``` - -This will execute that seed file and a demo user will be inserted into the `User` table. - -**Note:** _Seeder execution history is not stored anywhere, unlike migrations, which use the `SequelizeMeta` table. If you wish to change this behavior, please read the `Storage` section._ - -## Undoing Seeds - -Seeders can be undone if they are using any storage. There are two commands available for that: - -If you wish to undo the most recent seed: - -```text -npx sequelize-cli db:seed:undo -``` - -If you wish to undo a specific seed: - -```text -npx sequelize-cli db:seed:undo --seed name-of-seed-as-in-data -``` - -If you wish to undo all seeds: - -```text -npx sequelize-cli db:seed:undo:all -``` - -## Migration Skeleton - -The following skeleton shows a typical migration file. - -```js -module.exports = { - up: (queryInterface, Sequelize) => { - // logic for transforming into the new state - }, - down: (queryInterface, Sequelize) => { - // logic for reverting the changes - } -} -``` - -We can generate this file using `migration:generate`. This will create `xxx-migration-skeleton.js` in your migration folder. - -```text -npx sequelize-cli migration:generate --name migration-skeleton -``` - -The passed `queryInterface` object can be used to modify the database. The `Sequelize` object stores the available data types such as `STRING` or `INTEGER`. Function `up` or `down` should return a `Promise`. Let's look at an example: - -```js -module.exports = { - up: (queryInterface, Sequelize) => { - return queryInterface.createTable('Person', { - name: Sequelize.DataTypes.STRING, - isBetaMember: { - type: Sequelize.DataTypes.BOOLEAN, - defaultValue: false, - allowNull: false - } - }); - }, - down: (queryInterface, Sequelize) => { - return queryInterface.dropTable('Person'); - } -}; -``` - -The following is an example of a migration that performs two changes in the database, using an automatically-managed transaction to ensure that all instructions are successfully executed or rolled back in case of failure: - -```js -module.exports = { - up: (queryInterface, Sequelize) => { - return queryInterface.sequelize.transaction(t => { - return Promise.all([ - queryInterface.addColumn('Person', 'petName', { - type: Sequelize.DataTypes.STRING - }, { transaction: t }), - queryInterface.addColumn('Person', 'favoriteColor', { - type: Sequelize.DataTypes.STRING, - }, { transaction: t }) - ]); - }); - }, - down: (queryInterface, Sequelize) => { - return queryInterface.sequelize.transaction(t => { - return Promise.all([ - queryInterface.removeColumn('Person', 'petName', { transaction: t }), - queryInterface.removeColumn('Person', 'favoriteColor', { transaction: t }) - ]); - }); - } -}; -``` - -The next example is of a migration that has a foreign key. You can use references to specify a foreign key: - -```js -module.exports = { - up: (queryInterface, Sequelize) => { - return queryInterface.createTable('Person', { - name: Sequelize.DataTypes.STRING, - isBetaMember: { - type: Sequelize.DataTypes.BOOLEAN, - defaultValue: false, - allowNull: false - }, - userId: { - type: Sequelize.DataTypes.INTEGER, - references: { - model: { - tableName: 'users', - schema: 'schema' - }, - key: 'id' - }, - allowNull: false - }, - }); - }, - down: (queryInterface, Sequelize) => { - return queryInterface.dropTable('Person'); - } -} -``` - -The next example is of a migration that uses async/await where you create an unique index on a new column, with a manually-managed transaction: - -```js -module.exports = { - async up(queryInterface, Sequelize) { - const transaction = await queryInterface.sequelize.transaction(); - try { - await queryInterface.addColumn( - 'Person', - 'petName', - { - type: Sequelize.DataTypes.STRING, - }, - { transaction } - ); - await queryInterface.addIndex( - 'Person', - 'petName', - { - fields: 'petName', - unique: true, - transaction, - } - ); - await transaction.commit(); - } catch (err) { - await transaction.rollback(); - throw err; - } - }, - async down(queryInterface, Sequelize) { - const transaction = await queryInterface.sequelize.transaction(); - try { - await queryInterface.removeColumn('Person', 'petName', { transaction }); - await transaction.commit(); - } catch (err) { - await transaction.rollback(); - throw err; - } - } -}; -``` - -The next example is of a migration that creates an unique index composed of multiple fields with a condition, which allows a relation to exist multiple times but only one can satisfy the condition: - -```js -module.exports = { - up: (queryInterface, Sequelize) => { - queryInterface.createTable('Person', { - name: Sequelize.DataTypes.STRING, - bool: { - type: Sequelize.DataTypes.BOOLEAN, - defaultValue: false - } - }).then((queryInterface, Sequelize) => { - queryInterface.addIndex( - 'Person', - ['name', 'bool'], - { - indicesType: 'UNIQUE', - where: { bool : 'true' }, - } - ); - }); - }, - down: (queryInterface, Sequelize) => { - return queryInterface.dropTable('Person'); - } -} -``` - -### The `.sequelizerc` file - -This is a special configuration file. It lets you specify the following options that you would usually pass as arguments to CLI: - -- `env`: The environment to run the command in -- `config`: The path to the config file -- `options-path`: The path to a JSON file with additional options -- `migrations-path`: The path to the migrations folder -- `seeders-path`: The path to the seeders folder -- `models-path`: The path to the models folder -- `url`: The database connection string to use. Alternative to using --config files -- `debug`: When available show various debug information - -Some scenarios where you can use it: - -- You want to override default path to `migrations`, `models`, `seeders` or `config` folder. -- You want to rename `config.json` to something else like `database.json` - -And a whole lot more. Let's see how you can use this file for custom configuration. - -To begin, let's create the `.sequelizerc` file in the root directory of your project, with the following content: - -```js -// .sequelizerc - -const path = require('path'); - -module.exports = { - 'config': path.resolve('config', 'database.json'), - 'models-path': path.resolve('db', 'models'), - 'seeders-path': path.resolve('db', 'seeders'), - 'migrations-path': path.resolve('db', 'migrations') -}; -``` - -With this config you are telling the CLI to: - -- Use `config/database.json` file for config settings; -- Use `db/models` as models folder; -- Use `db/seeders` as seeders folder; -- Use `db/migrations` as migrations folder. - -### Dynamic configuration - -The configuration file is by default a JSON file called `config.json`. But sometimes you need a dynamic configuration, for example to access environment variables or execute some other code to determine the configuration. - -Thankfully, the Sequelize CLI can read from both `.json` and `.js` files. This can be setup with `.sequelizerc` file. You just have to provide the path to your `.js` file as the `config` option of your exported object: - -```js -const path = require('path'); - -module.exports = { - 'config': path.resolve('config', 'config.js') -} -``` - -Now the Sequelize CLI will load `config/config.js` for getting configuration options. - -An example of `config/config.js` file: - -```js -const fs = require('fs'); - -module.exports = { - development: { - username: 'database_dev', - password: 'database_dev', - database: 'database_dev', - host: '127.0.0.1', - port: 3306, - dialect: 'mysql', - dialectOptions: { - bigNumberStrings: true - } - }, - test: { - username: process.env.CI_DB_USERNAME, - password: process.env.CI_DB_PASSWORD, - database: process.env.CI_DB_NAME, - host: '127.0.0.1', - port: 3306, - dialect: 'mysql', - dialectOptions: { - bigNumberStrings: true - } - }, - production: { - username: process.env.PROD_DB_USERNAME, - password: process.env.PROD_DB_PASSWORD, - database: process.env.PROD_DB_NAME, - host: process.env.PROD_DB_HOSTNAME, - port: process.env.PROD_DB_PORT, - dialect: 'mysql', - dialectOptions: { - bigNumberStrings: true, - ssl: { - ca: fs.readFileSync(__dirname + '/mysql-ca-main.crt') - } - } - } -}; -``` - -The example above also shows how to add custom dialect options to the configuration. - -### Using Babel - -To enable more modern constructions in your migrations and seeders, you can simply install `babel-register` and require it at the beginning of `.sequelizerc`: - -```text -npm i --save-dev babel-register -``` - -```js -// .sequelizerc - -require("babel-register"); - -const path = require('path'); - -module.exports = { - 'config': path.resolve('config', 'config.json'), - 'models-path': path.resolve('models'), - 'seeders-path': path.resolve('seeders'), - 'migrations-path': path.resolve('migrations') -} -``` - -Of course, the outcome will depend upon your babel configuration (such as in a `.babelrc` file). Learn more at [babeljs.io](https://babeljs.io). - -### Security tip - -Use environment variables for config settings. This is because secrets such as passwords should never be part of the source code (and especially not committed to version control). - -### Storage - -There are three types of storage that you can use: `sequelize`, `json`, and `none`. - -- `sequelize` : stores migrations and seeds in a table on the sequelize database -- `json` : stores migrations and seeds on a json file -- `none` : does not store any migration/seed - -#### Migration Storage - -By default the CLI will create a table in your database called `SequelizeMeta` containing an entry for each executed migration. To change this behavior, there are three options you can add to the configuration file. Using `migrationStorage`, you can choose the type of storage to be used for migrations. If you choose `json`, you can specify the path of the file using `migrationStoragePath` or the CLI will write to the file `sequelize-meta.json`. If you want to keep the information in the database, using `sequelize`, but want to use a different table, you can change the table name using `migrationStorageTableName`. Also you can define a different schema for the `SequelizeMeta` table by providing the `migrationStorageTableSchema` property. - -```json -{ - "development": { - "username": "root", - "password": null, - "database": "database_development", - "host": "127.0.0.1", - "dialect": "mysql", - - // Use a different storage type. Default: sequelize - "migrationStorage": "json", - - // Use a different file name. Default: sequelize-meta.json - "migrationStoragePath": "sequelizeMeta.json", - - // Use a different table name. Default: SequelizeMeta - "migrationStorageTableName": "sequelize_meta", - - // Use a different schema for the SequelizeMeta table - "migrationStorageTableSchema": "custom_schema" - } -} -``` - -**Note:** _The `none` storage is not recommended as a migration storage. If you decide to use it, be aware of the implications of having no record of what migrations did or didn't run._ - -#### Seed Storage - -By default the CLI will not save any seed that is executed. If you choose to change this behavior (!), you can use `seederStorage` in the configuration file to change the storage type. If you choose `json`, you can specify the path of the file using `seederStoragePath` or the CLI will write to the file `sequelize-data.json`. If you want to keep the information in the database, using `sequelize`, you can specify the table name using `seederStorageTableName`, or it will default to `SequelizeData`. - -```json -{ - "development": { - "username": "root", - "password": null, - "database": "database_development", - "host": "127.0.0.1", - "dialect": "mysql", - // Use a different storage. Default: none - "seederStorage": "json", - // Use a different file name. Default: sequelize-data.json - "seederStoragePath": "sequelizeData.json", - // Use a different table name. Default: SequelizeData - "seederStorageTableName": "sequelize_data" - } -} -``` - -### Configuration Connection String - -As an alternative to the `--config` option with configuration files defining your database, you can use the `--url` option to pass in a connection string. For example: - -```text -npx sequelize-cli db:migrate --url 'mysql://root:password@mysql_host.com/database_name' -``` - -### Programmatic usage - -Sequelize has a sister library called [umzug](https://github.com/sequelize/umzug) for programmatically handling execution and logging of migration tasks. diff --git a/docs/manual/other-topics/naming-strategies.md b/docs/manual/other-topics/naming-strategies.md deleted file mode 100644 index 9daf8b1a3567..000000000000 --- a/docs/manual/other-topics/naming-strategies.md +++ /dev/null @@ -1,157 +0,0 @@ -# Naming Strategies - -## The `underscored` option - -Sequelize provides the `underscored` option for a model. When `true`, this option will set the `field` option on all attributes to the [snake_case](https://en.wikipedia.org/wiki/Snake_case) version of its name. This also applies to foreign keys automatically generated by associations and other automatically generated fields. Example: - -```js -const User = sequelize.define('user', { username: Sequelize.STRING }, { - underscored: true -}); -const Task = sequelize.define('task', { title: Sequelize.STRING }, { - underscored: true -}); -User.hasMany(Task); -Task.belongsTo(User); -``` - -Above we have the models User and Task, both using the `underscored` option. We also have a One-to-Many relationship between them. Also, recall that since `timestamps` is true by default, we should expect the `createdAt` and `updatedAt` fields to be automatically created as well. - -Without the `underscored` option, Sequelize would automatically define: - -* A `createdAt` attribute for each model, pointing to a column named `createdAt` in each table -* An `updatedAt` attribute for each model, pointing to a column named `updatedAt` in each table -* A `userId` attribute in the `Task` model, pointing to a column named `userId` in the task table - -With the `underscored` option enabled, Sequelize will instead define: - -* A `createdAt` attribute for each model, pointing to a column named `created_at` in each table -* An `updatedAt` attribute for each model, pointing to a column named `updated_at` in each table -* A `userId` attribute in the `Task` model, pointing to a column named `user_id` in the task table - -Note that in both cases the fields are still [camelCase](https://en.wikipedia.org/wiki/Camel_case) in the JavaScript side; this option only changes how these fields are mapped to the database itself. The `field` option of every attribute is set to their snake_case version, but the attribute itself remains camelCase. - -This way, calling `sync()` on the above code will generate the following: - -```sql -CREATE TABLE IF NOT EXISTS "users" ( - "id" SERIAL, - "username" VARCHAR(255), - "created_at" TIMESTAMP WITH TIME ZONE NOT NULL, - "updated_at" TIMESTAMP WITH TIME ZONE NOT NULL, - PRIMARY KEY ("id") -); -CREATE TABLE IF NOT EXISTS "tasks" ( - "id" SERIAL, - "title" VARCHAR(255), - "created_at" TIMESTAMP WITH TIME ZONE NOT NULL, - "updated_at" TIMESTAMP WITH TIME ZONE NOT NULL, - "user_id" INTEGER REFERENCES "users" ("id") ON DELETE SET NULL ON UPDATE CASCADE, - PRIMARY KEY ("id") -); -``` - -## Singular vs. Plural - -At a first glance, it can be confusing whether the singular form or plural form of a name shall be used around in Sequelize. This section aims at clarifying that a bit. - -Recall that Sequelize uses a library called [inflection](https://www.npmjs.com/package/inflection) under the hood, so that irregular plurals (such as `person -> people`) are computed correctly. However, if you're working in another language, you may want to define the singular and plural forms of names directly; sequelize allows you to do this with some options. - -### When defining models - -Models should be defined with the singular form of a word. Example: - -```js -sequelize.define('foo', { name: DataTypes.STRING }); -``` - -Above, the model name is `foo` (singular), and the respective table name is `foos`, since Sequelize automatically gets the plural for the table name. - -### When defining a reference key in a model - -```js -sequelize.define('foo', { - name: DataTypes.STRING, - barId: { - type: DataTypes.INTEGER, - allowNull: false, - references: { - model: "bars", - key: "id" - }, - onDelete: "CASCADE" - }, -}); -``` - -In the above example we are manually defining a key that references another model. It's not usual to do this, but if you have to, you should use the table name there. This is because the reference is created upon the referencced table name. In the example above, the plural form was used (`bars`), assuming that the `bar` model was created with the default settings (making its underlying table automatically pluralized). - -### When retrieving data from eager loading - -When you perform an `include` in a query, the included data will be added to an extra field in the returned objects, according to the following rules: - -* When including something from a single association (`hasOne` or `belongsTo`) - the field name will be the singular version of the model name; -* When including something from a multiple association (`hasMany` or `belongsToMany`) - the field name will be the plural form of the model. - -In short, the name of the field will take the most logical form in each situation. - -Examples: - -```js -// Assuming Foo.hasMany(Bar) -const foo = Foo.findOne({ include: Bar }); -// foo.bars will be an array -// foo.bar will not exist since it doens't make sense - -// Assuming Foo.hasOne(Bar) -const foo = Foo.findOne({ include: Bar }); -// foo.bar will be an object (possibly null if there is no associated model) -// foo.bars will not exist since it doens't make sense - -// And so on. -``` - -### Overriding singulars and plurals when defining aliases - -When defining an alias for an association, instead of using simply `{ as: 'myAlias' }`, you can pass an object to specify the singular and plural forms: - -```js -Project.belongsToMany(User, { - as: { - singular: 'líder', - plural: 'líderes' - } -}); -``` - -If you know that a model will always use the same alias in associations, you can provide the singular and plural forms directly to the model itself: - -```js -const User = sequelize.define('user', { /* ... */ }, { - name: { - singular: 'líder', - plural: 'líderes', - } -}); -Project.belongsToMany(User); -``` - -The mixins added to the user instances will use the correct forms. For example, instead of `project.addUser()`, Sequelize will provide `project.getLíder()`. Also, instead of `project.setUsers()`, Sequelize will provide `project.setLíderes()`. - -Note: recall that using `as` to change the name of the association will also change the name of the foreign key. Therefore it is recommended to also specify the foreign key(s) involved directly in this case. - -```js -// Example of possible mistake -Invoice.belongsTo(Subscription, { as: 'TheSubscription' }); -Subscription.hasMany(Invoice); -``` - -The first call above will establish a foreign key called `theSubscriptionId` on `Invoice`. However, the second call will also establish a foreign key on `Invoice` (since as we know, `hasMany` calls places foreign keys in the target model) - however, it will be named `subscriptionId`. This way you will have both `subscriptionId` and `theSubscriptionId` columns. - -The best approach is to choose a name for the foreign key and place it explicitly in both calls. For example, if `subscription_id` was chosen: - -```js -// Fixed example -Invoice.belongsTo(Subscription, { as: 'TheSubscription', foreignKey: 'subscription_id' }); -Subscription.hasMany(Invoice, { foreignKey: 'subscription_id' }); -``` \ No newline at end of file diff --git a/docs/manual/other-topics/optimistic-locking.md b/docs/manual/other-topics/optimistic-locking.md deleted file mode 100644 index 7db529e43319..000000000000 --- a/docs/manual/other-topics/optimistic-locking.md +++ /dev/null @@ -1,7 +0,0 @@ -# Optimistic Locking - -Sequelize has built-in support for optimistic locking through a model instance version count. - -Optimistic locking is disabled by default and can be enabled by setting the `version` property to true in a specific model definition or global model configuration. See [model configuration](models-definition.html#configuration) for more details. - -Optimistic locking allows concurrent access to model records for edits and prevents conflicts from overwriting data. It does this by checking whether another process has made changes to a record since it was read and throws an OptimisticLockError when a conflict is detected. \ No newline at end of file diff --git a/docs/manual/other-topics/other-data-types.md b/docs/manual/other-topics/other-data-types.md deleted file mode 100644 index fa0561385520..000000000000 --- a/docs/manual/other-topics/other-data-types.md +++ /dev/null @@ -1,192 +0,0 @@ -# Other Data Types - -Apart from the most common data types mentioned in the Model Basics guide, Sequelize provides several other data types. - -## Ranges (PostgreSQL only) - -```js -DataTypes.RANGE(DataTypes.INTEGER) // int4range -DataTypes.RANGE(DataTypes.BIGINT) // int8range -DataTypes.RANGE(DataTypes.DATE) // tstzrange -DataTypes.RANGE(DataTypes.DATEONLY) // daterange -DataTypes.RANGE(DataTypes.DECIMAL) // numrange -``` - -Since range types have extra information for their bound inclusion/exclusion it's not very straightforward to just use a tuple to represent them in javascript. - -When supplying ranges as values you can choose from the following APIs: - -```js -// defaults to inclusive lower bound, exclusive upper bound -const range = [ - new Date(Date.UTC(2016, 0, 1)), - new Date(Date.UTC(2016, 1, 1)) -]; -// '["2016-01-01 00:00:00+00:00", "2016-02-01 00:00:00+00:00")' - -// control inclusion -const range = [ - { value: new Date(Date.UTC(2016, 0, 1)), inclusive: false }, - { value: new Date(Date.UTC(2016, 1, 1)), inclusive: true }, -]; -// '("2016-01-01 00:00:00+00:00", "2016-02-01 00:00:00+00:00"]' - -// composite form -const range = [ - { value: new Date(Date.UTC(2016, 0, 1)), inclusive: false }, - new Date(Date.UTC(2016, 1, 1)), -]; -// '("2016-01-01 00:00:00+00:00", "2016-02-01 00:00:00+00:00")' - -const Timeline = sequelize.define('Timeline', { - range: DataTypes.RANGE(DataTypes.DATE) -}); - -await Timeline.create({ range }); -``` - -However, retrieved range values always come in the form of an array of objects. For example, if the stored value is `("2016-01-01 00:00:00+00:00", "2016-02-01 00:00:00+00:00"]`, after a finder query you will get: - -```js -[ - { value: Date, inclusive: false }, - { value: Date, inclusive: true } -] -``` - -You will need to call `reload()` after updating an instance with a range type or use the `returning: true` option. - -### Special Cases - -```js -// empty range: -Timeline.create({ range: [] }); // range = 'empty' - -// Unbounded range: -Timeline.create({ range: [null, null] }); // range = '[,)' -// range = '[,"2016-01-01 00:00:00+00:00")' -Timeline.create({ range: [null, new Date(Date.UTC(2016, 0, 1))] }); - -// Infinite range: -// range = '[-infinity,"2016-01-01 00:00:00+00:00")' -Timeline.create({ range: [-Infinity, new Date(Date.UTC(2016, 0, 1))] }); -``` - -## BLOBs - -```js -DataTypes.BLOB // BLOB (bytea for PostgreSQL) -DataTypes.BLOB('tiny') // TINYBLOB (bytea for PostgreSQL) -DataTypes.BLOB('medium') // MEDIUMBLOB (bytea for PostgreSQL) -DataTypes.BLOB('long') // LONGBLOB (bytea for PostgreSQL) -``` - -The blob datatype allows you to insert data both as strings and as buffers. However, when a blob is retrieved from database with Sequelize, it will always be retrieved as a buffer. - -## ENUMs - -The ENUM is a data type that accepts only a few values, specified as a list. - -```js -DataTypes.ENUM('foo', 'bar') // An ENUM with allowed values 'foo' and 'bar' -``` - -ENUMs can also be specified with the `values` field of the column definition, as follows: - -```js -sequelize.define('foo', { - states: { - type: DataTypes.ENUM, - values: ['active', 'pending', 'deleted'] - } -}); -``` - -## JSON (SQLite, MySQL, MariaDB and PostgreSQL only) - -The `DataTypes.JSON` data type is only supported for SQLite, MySQL, MariaDB and PostgreSQL. However, there is a minimum support for MSSQL (see below). - -### Note for PostgreSQL - -The JSON data type in PostgreSQL stores the value as plain text, as opposed to binary representation. If you simply want to store and retrieve a JSON representation, using JSON will take less disk space and less time to build from its input representation. However, if you want to do any operations on the JSON value, you should prefer the JSONB data type described below. - -### JSONB (PostgreSQL only) - -PostgreSQL also supports a JSONB data type: `DataTypes.JSONB`. It can be queried in three different ways: - -```js -// Nested object -await Foo.findOne({ - where: { - meta: { - video: { - url: { - [Op.ne]: null - } - } - } - } -}); - -// Nested key -await Foo.findOne({ - where: { - "meta.audio.length": { - [Op.gt]: 20 - } - } -}); - -// Containment -await Foo.findOne({ - where: { - meta: { - [Op.contains]: { - site: { - url: 'http://google.com' - } - } - } - } -}); -``` - -### MSSQL - -MSSQL does not have a JSON data type, however it does provide some support for JSON stored as strings through certain functions since SQL Server 2016. Using these functions, you will be able to query the JSON stored in the string, but any returned values will need to be parsed seperately. - -```js -// ISJSON - to test if a string contains valid JSON -await User.findAll({ - where: sequelize.where(sequelize.fn('ISJSON', sequelize.col('userDetails')), 1) -}) - -// JSON_VALUE - extract a scalar value from a JSON string -await User.findAll({ - attributes: [[ sequelize.fn('JSON_VALUE', sequelize.col('userDetails'), '$.address.Line1'), 'address line 1']] -}) - -// JSON_VALUE - query a scalar value from a JSON string -await User.findAll({ - where: sequelize.where(sequelize.fn('JSON_VALUE', sequelize.col('userDetails'), '$.address.Line1'), '14, Foo Street') -}) - -// JSON_QUERY - extract an object or array -await User.findAll({ - attributes: [[ sequelize.fn('JSON_QUERY', sequelize.col('userDetails'), '$.address'), 'full address']] -}) -``` - -## Others - -```js -DataTypes.ARRAY(/* DataTypes.SOMETHING */) // Defines an array of DataTypes.SOMETHING. PostgreSQL only. - -DataTypes.CIDR // CIDR PostgreSQL only -DataTypes.INET // INET PostgreSQL only -DataTypes.MACADDR // MACADDR PostgreSQL only - -DataTypes.GEOMETRY // Spatial column. PostgreSQL (with PostGIS) or MySQL only. -DataTypes.GEOMETRY('POINT') // Spatial column with geometry type. PostgreSQL (with PostGIS) or MySQL only. -DataTypes.GEOMETRY('POINT', 4326) // Spatial column with geometry type and SRID. PostgreSQL (with PostGIS) or MySQL only. -``` \ No newline at end of file diff --git a/docs/manual/other-topics/query-interface.md b/docs/manual/other-topics/query-interface.md deleted file mode 100644 index 5225d0adf1d3..000000000000 --- a/docs/manual/other-topics/query-interface.md +++ /dev/null @@ -1,152 +0,0 @@ -# Query Interface - -An instance of Sequelize uses something called **Query Interface** to communicate to the database in a dialect-agnostic way. Most of the methods you've learned in this manual are implemented with the help of several methods from the query interface. - -The methods from the query interface are therefore lower-level methods; you should use them only if you do not find another way to do it with higher-level APIs from Sequelize. They are, of course, still higher-level than running raw queries directly (i.e., writing SQL by hand). - -This guide shows a few examples, but for the full list of what it can do, and for detailed usage of each method, check the [QueryInterface API](../class/lib/dialects/abstract/query-interface.js~QueryInterface.html). - -## Obtaining the query interface - -From now on, we will call `queryInterface` the singleton instance of the [QueryInterface](../class/lib/dialects/abstract/query-interface.js~QueryInterface.html) class, which is available on your Sequelize instance: - -```js -const { Sequelize, DataTypes } = require('sequelize'); -const sequelize = new Sequelize(/* ... */); -const queryInterface = sequelize.getQueryInterface(); -``` - -## Creating a table - -```js -queryInterface.createTable('Person', { - name: DataTypes.STRING, - isBetaMember: { - type: DataTypes.BOOLEAN, - defaultValue: false, - allowNull: false - } -}); -``` - -Generated SQL (using SQLite): - -```SQL -CREATE TABLE IF NOT EXISTS `Person` ( - `name` VARCHAR(255), - `isBetaMember` TINYINT(1) NOT NULL DEFAULT 0 -); -``` - -**Note:** Consider defining a Model instead and calling `YourModel.sync()` instead, which is a higher-level approach. - -## Adding a column to a table - -```js -queryInterface.addColumn('Person', 'petName', { type: DataTypes.STRING }); -``` - -Generated SQL (using SQLite): - -```sql -ALTER TABLE `Person` ADD `petName` VARCHAR(255); -``` - -## Changing the datatype of a column - -```js -queryInterface.changeColumn('Person', 'foo', { - type: DataTypes.FLOAT, - defaultValue: 3.14, - allowNull: false -}); -``` - -Generated SQL (using MySQL): - -```sql -ALTER TABLE `Person` CHANGE `foo` `foo` FLOAT NOT NULL DEFAULT 3.14; -``` - -## Removing a column - -```js -queryInterface.removeColumn('Person', 'petName', { /* query options */ }); -``` - -Generated SQL (using PostgreSQL): - -```SQL -ALTER TABLE "public"."Person" DROP COLUMN "petName"; -``` - -## Changing and removing columns in SQLite - -SQLite does not support directly altering and removing columns. However, Sequelize will try to work around this by recreating the whole table with the help of a backup table, inspired by [these instructions](https://www.sqlite.org/lang_altertable.html#otheralter). - -For example: - -```js -// Assuming we have a table in SQLite created as follows: -queryInterface.createTable('Person', { - name: DataTypes.STRING, - isBetaMember: { - type: DataTypes.BOOLEAN, - defaultValue: false, - allowNull: false - }, - petName: DataTypes.STRING, - foo: DataTypes.INTEGER -}); - -// And we change a column: -queryInterface.changeColumn('Person', 'foo', { - type: DataTypes.FLOAT, - defaultValue: 3.14, - allowNull: false -}); -``` - -The following SQL calls are generated for SQLite: - -```sql -PRAGMA TABLE_INFO(`Person`); - -CREATE TABLE IF NOT EXISTS `Person_backup` ( - `name` VARCHAR(255), - `isBetaMember` TINYINT(1) NOT NULL DEFAULT 0, - `foo` FLOAT NOT NULL DEFAULT '3.14', - `petName` VARCHAR(255) -); - -INSERT INTO `Person_backup` - SELECT - `name`, - `isBetaMember`, - `foo`, - `petName` - FROM `Person`; - -DROP TABLE `Person`; - -CREATE TABLE IF NOT EXISTS `Person` ( - `name` VARCHAR(255), - `isBetaMember` TINYINT(1) NOT NULL DEFAULT 0, - `foo` FLOAT NOT NULL DEFAULT '3.14', - `petName` VARCHAR(255) -); - -INSERT INTO `Person` - SELECT - `name`, - `isBetaMember`, - `foo`, - `petName` - FROM `Person_backup`; - -DROP TABLE `Person_backup`; -``` - -## Other - -As mentioned in the beginning of this guide, there is a lot more to the Query Interface available in Sequelize! Check the [QueryInterface API](../class/lib/dialects/abstract/query-interface.js~QueryInterface.html) for a full list of what can be done. \ No newline at end of file diff --git a/docs/manual/other-topics/read-replication.md b/docs/manual/other-topics/read-replication.md deleted file mode 100644 index 1c16fef1ad74..000000000000 --- a/docs/manual/other-topics/read-replication.md +++ /dev/null @@ -1,29 +0,0 @@ -# Read Replication - -Sequelize supports [read replication](https://en.wikipedia.org/wiki/Replication_%28computing%29#Database_replication), i.e. having multiple servers that you can connect to when you want to do a SELECT query. When you do read replication, you specify one or more servers to act as read replicas, and one server to act as the main writer, which handles all writes and updates and propagates them to the replicas (note that the actual replication process is **not** handled by Sequelize, but should be set up by database backend). - -```js -const sequelize = new Sequelize('database', null, null, { - dialect: 'mysql', - port: 3306, - replication: { - read: [ - { host: '8.8.8.8', username: 'read-1-username', password: process.env.READ_DB_1_PW }, - { host: '9.9.9.9', username: 'read-2-username', password: process.env.READ_DB_2_PW } - ], - write: { host: '1.1.1.1', username: 'write-username', password: process.env.WRITE_DB_PW } - }, - pool: { // If you want to override the options used for the read/write pool you can do so here - max: 20, - idle: 30000 - }, -}) -``` - -If you have any general settings that apply to all replicas you do not need to provide them for each instance. In the code above, database name and port is propagated to all replicas. The same will happen for user and password, if you leave them out for any of the replicas. Each replica has the following options:`host`,`port`,`username`,`password`,`database`. - -Sequelize uses a pool to manage connections to your replicas. Internally Sequelize will maintain two pools created using `pool` configuration. - -If you want to modify these, you can pass pool as an options when instantiating Sequelize, as shown above. - -Each `write` or `useMaster: true` query will use write pool. For `SELECT` read pool will be used. Read replica are switched using a basic round robin scheduling. diff --git a/docs/manual/other-topics/resources.md b/docs/manual/other-topics/resources.md deleted file mode 100644 index c5ae37d5c28d..000000000000 --- a/docs/manual/other-topics/resources.md +++ /dev/null @@ -1,70 +0,0 @@ -# Resources - -## Addons & Plugins - -### ACL - -* [ssacl](https://github.com/pumpupapp/ssacl) -* [ssacl-attribute-roles](https://github.com/mickhansen/ssacl-attribute-roles) -* [SequelizeGuard](https://github.com/lotivo/sequelize-acl) - Role, Permission based Authorization for Sequelize. - -### Auto Code Generation & Scaffolding - -* [meteor modeler](https://www.datensen.com/) - Desktop tool for visual definition of Sequelize models and asssociations. -* [sequelize-ui](https://github.com/tomjschuster/sequelize-ui) - Online tool for building models, relations and more. -* [sequelizer](https://github.com/andyforever/sequelizer) - A GUI Desktop App for generating Sequelize models. Support for Mysql, Mariadb, Postgres, Sqlite, Mssql. -* [sequelize-auto](https://github.com/sequelize/sequelize-auto) Generating models for SequelizeJS via the command line is another choice. -* [pg-generator](http://www.pg-generator.com/builtin-templates/sequelize/) - Auto generate/scaffold Sequelize models for PostgreSQL database. -* [sequelizejs-decorators](https://www.npmjs.com/package/sequelizejs-decorators) decorators for composing sequelize models - -### Autoloader - -* [sequelize-autoload](https://github.com/boxsnake-nodejs/sequelize-autoload) - An autoloader for Sequelize, inspired by [PSR-0](https://www.php-fig.org/psr/psr-0/) and [PSR-4](https://www.php-fig.org/psr/psr-4/). - -### Bcrypt - -* [sequelize-bcrypt](https://github.com/mattiamalonni/sequelize-bcrypt) - Utility to integrate bcrypt into sequelize models - -### Caching - -* [sequelize-transparent-cache](https://github.com/DanielHreben/sequelize-transparent-cache) - -### Filters - -* [sequelize-transforms](https://www.npmjs.com/package/sequelize-transforms) - Add configurable attribute transforms. - -### Fixtures / mock data - -* [Fixer](https://github.com/olalonde/fixer) -* [Sequelize-fixtures](https://github.com/domasx2/sequelize-fixtures) -* [Sequelize-fixture](https://github.com/xudejian/sequelize-fixture) - -### Hierarchies - -* [sequelize-hierarchy](https://www.npmjs.com/package/sequelize-hierarchy) - Nested hierarchies for Sequelize. - -### Historical records / Time travel - -* [sequelize-temporal](https://github.com/bonaval/sequelize-temporal) - Temporal tables (aka historical records) - -### Joi - -* [sequelize-joi](https://github.com/mattiamalonni/sequelize-joi) - Allows specifying [Joi](https://github.com/sideway/joi) validation schema for model attributes in Sequelize. - -### Migrations - -* [umzug](https://github.com/sequelize/umzug) - -### Slugification - -* [sequelize-slugify](https://www.npmjs.com/package/sequelize-slugify) - Add slugs to sequelize models - -### Tokens - -* [sequelize-tokenify](https://github.com/pipll/sequelize-tokenify) - Add unique tokens to sequelize models - -### Miscellaneous - -* [sequelize-deep-update](https://www.npmjs.com/package/sequelize-deep-update) - Update a sequelize instance and its included associated instances with new properties. -* [sequelize-noupdate-attributes](https://www.npmjs.com/package/sequelize-noupdate-attributes) - Adds no update/readonly attributes support to models. -* [sqlcommenter-sequelize](https://github.com/google/sqlcommenter/tree/master/nodejs/sqlcommenter-nodejs/packages/sqlcommenter-sequelize) A [sqlcommenter](https://google.github.io/sqlcommenter/) plugin with [support for Sequelize](https://google.github.io/sqlcommenter/node/sequelize/) to augment SQL statements with comments that can be used later to correlate application code with SQL statements. diff --git a/docs/manual/other-topics/scopes.md b/docs/manual/other-topics/scopes.md deleted file mode 100644 index 96a531115122..000000000000 --- a/docs/manual/other-topics/scopes.md +++ /dev/null @@ -1,284 +0,0 @@ -# Scopes - -Scopes are used to help you reuse code. You can define commonly used queries, specifying options such as `where`, `include`, `limit`, etc. - -This guide concerns model scopes. You might also be interested in the [guide for association scopes](association-scopes.html), which are similar but not the same thing. - -## Definition - -Scopes are defined in the model definition and can be finder objects, or functions returning finder objects - except for the default scope, which can only be an object: - -```js -class Project extends Model {} -Project.init({ - // Attributes -}, { - defaultScope: { - where: { - active: true - } - }, - scopes: { - deleted: { - where: { - deleted: true - } - }, - activeUsers: { - include: [ - { model: User, where: { active: true } } - ] - }, - random() { - return { - where: { - someNumber: Math.random() - } - } - }, - accessLevel(value) { - return { - where: { - accessLevel: { - [Op.gte]: value - } - } - } - }, - sequelize, - modelName: 'project' - } -}); -``` - -You can also add scopes after a model has been defined by calling [`YourModel.addScope`](../class/lib/model.js~Model.html#static-method-addScope). This is especially useful for scopes with includes, where the model in the include might not be defined at the time the other model is being defined. - -The default scope is always applied. This means, that with the model definition above, `Project.findAll()` will create the following query: - -```sql -SELECT * FROM projects WHERE active = true -``` - -The default scope can be removed by calling `.unscoped()`, `.scope(null)`, or by invoking another scope: - -```js -await Project.scope('deleted').findAll(); // Removes the default scope -``` - -```sql -SELECT * FROM projects WHERE deleted = true -``` - -It is also possible to include scoped models in a scope definition. This allows you to avoid duplicating `include`, `attributes` or `where` definitions. Using the above example, and invoking the `active` scope on the included User model (rather than specifying the condition directly in that include object): - -```js -// The `activeUsers` scope defined in the example above could also have been defined this way: -Project.addScope('activeUsers', { - include: [ - { model: User.scope('active') } - ] -}); -``` - -## Usage - -Scopes are applied by calling `.scope` on the model definition, passing the name of one or more scopes. `.scope` returns a fully functional model instance with all the regular methods: `.findAll`, `.update`, `.count`, `.destroy` etc. You can save this model instance and reuse it later: - -```js -const DeletedProjects = Project.scope('deleted'); -await DeletedProjects.findAll(); - -// The above is equivalent to: -await Project.findAll({ - where: { - deleted: true - } -}); -``` - -Scopes apply to `.find`, `.findAll`, `.count`, `.update`, `.increment` and `.destroy`. - -Scopes which are functions can be invoked in two ways. If the scope does not take any arguments it can be invoked as normally. If the scope takes arguments, pass an object: - -```js -await Project.scope('random', { method: ['accessLevel', 19] }).findAll(); -``` - -Generated SQL: - -```sql -SELECT * FROM projects WHERE someNumber = 42 AND accessLevel >= 19 -``` - -## Merging - -Several scopes can be applied simultaneously by passing an array of scopes to `.scope`, or by passing the scopes as consecutive arguments. - -```js -// These two are equivalent -await Project.scope('deleted', 'activeUsers').findAll(); -await Project.scope(['deleted', 'activeUsers']).findAll(); -``` - -Generated SQL: - -```sql -SELECT * FROM projects -INNER JOIN users ON projects.userId = users.id -WHERE projects.deleted = true -AND users.active = true -``` - -If you want to apply another scope alongside the default scope, pass the key `defaultScope` to `.scope`: - -```js -await Project.scope('defaultScope', 'deleted').findAll(); -``` - -Generated SQL: - -```sql -SELECT * FROM projects WHERE active = true AND deleted = true -``` - -When invoking several scopes, keys from subsequent scopes will overwrite previous ones (similarly to [Object.assign](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign)), except for `where` and `include`, which will be merged. Consider two scopes: - -```js -YourMode.addScope('scope1', { - where: { - firstName: 'bob', - age: { - [Op.gt]: 20 - } - }, - limit: 2 -}); -YourMode.addScope('scope2', { - where: { - age: { - [Op.gt]: 30 - } - }, - limit: 10 -}); -``` - -Using `.scope('scope1', 'scope2')` will yield the following WHERE clause: - -```sql -WHERE firstName = 'bob' AND age > 30 LIMIT 10 -``` - -Note how `limit` and `age` are overwritten by `scope2`, while `firstName` is preserved. The `limit`, `offset`, `order`, `paranoid`, `lock` and `raw` fields are overwritten, while `where` is shallowly merged (meaning that identical keys will be overwritten). The merge strategy for `include` will be discussed later on. - -Note that `attributes` keys of multiple applied scopes are merged in such a way that `attributes.exclude` are always preserved. This allows merging several scopes and never leaking sensitive fields in final scope. - -The same merge logic applies when passing a find object directly to `findAll` (and similar finders) on a scoped model: - -```js -Project.scope('deleted').findAll({ - where: { - firstName: 'john' - } -}) -``` - -Generated where clause: - -```sql -WHERE deleted = true AND firstName = 'john' -``` - -Here the `deleted` scope is merged with the finder. If we were to pass `where: { firstName: 'john', deleted: false }` to the finder, the `deleted` scope would be overwritten. - -### Merging includes - -Includes are merged recursively based on the models being included. This is a very powerful merge, added on v5, and is better understood with an example. - -Consider the models `Foo`, `Bar`, `Baz` and `Qux`, with One-to-Many associations as follows: - -```js -const Foo = sequelize.define('Foo', { name: Sequelize.STRING }); -const Bar = sequelize.define('Bar', { name: Sequelize.STRING }); -const Baz = sequelize.define('Baz', { name: Sequelize.STRING }); -const Qux = sequelize.define('Qux', { name: Sequelize.STRING }); -Foo.hasMany(Bar, { foreignKey: 'fooId' }); -Bar.hasMany(Baz, { foreignKey: 'barId' }); -Baz.hasMany(Qux, { foreignKey: 'bazId' }); -``` - -Now, consider the following four scopes defined on Foo: - -```js -Foo.addScope('includeEverything', { - include: { - model: Bar, - include: [{ - model: Baz, - include: Qux - }] - } -}); - -Foo.addScope('limitedBars', { - include: [{ - model: Bar, - limit: 2 - }] -}); - -Foo.addScope('limitedBazs', { - include: [{ - model: Bar, - include: [{ - model: Baz, - limit: 2 - }] - }] -}); - -Foo.addScope('excludeBazName', { - include: [{ - model: Bar, - include: [{ - model: Baz, - attributes: { - exclude: ['name'] - } - }] - }] -}); -``` - -These four scopes can be deeply merged easily, for example by calling `Foo.scope('includeEverything', 'limitedBars', 'limitedBazs', 'excludeBazName').findAll()`, which would be entirely equivalent to calling the following: - -```js -await Foo.findAll({ - include: { - model: Bar, - limit: 2, - include: [{ - model: Baz, - limit: 2, - attributes: { - exclude: ['name'] - }, - include: Qux - }] - } -}); - -// The above is equivalent to: -await Foo.scope([ - 'includeEverything', - 'limitedBars', - 'limitedBazs', - 'excludeBazName' -]).findAll(); -``` - -Observe how the four scopes were merged into one. The includes of scopes are merged based on the model being included. If one scope includes model A and another includes model B, the merged result will include both models A and B. On the other hand, if both scopes include the same model A, but with different options (such as nested includes or other attributes), those will be merged recursively, as shown above. - -The merge illustrated above works in the exact same way regardless of the order applied to the scopes. The order would only make a difference if a certain option was set by two different scopes - which is not the case of the above example, since each scope does a different thing. - -This merge strategy also works in the exact same way with options passed to `.findAll`, `.findOne` and the like. diff --git a/docs/manual/other-topics/sub-queries.md b/docs/manual/other-topics/sub-queries.md deleted file mode 100644 index 213e4ec3a1ab..000000000000 --- a/docs/manual/other-topics/sub-queries.md +++ /dev/null @@ -1,164 +0,0 @@ -# Sub Queries - -Consider you have two models, `Post` and `Reaction`, with a One-to-Many relationship set up, so that one post has many reactions: - -```js -const Post = sequelize.define('post', { - content: DataTypes.STRING -}, { timestamps: false }); - -const Reaction = sequelize.define('reaction', { - type: DataTypes.STRING -}, { timestamps: false }); - -Post.hasMany(Reaction); -Reaction.belongsTo(Post); -``` - -*Note: we have disabled timestamps just to have shorter queries for the next examples.* - -Let's fill our tables with some data: - -```js -async function makePostWithReactions(content, reactionTypes) { - const post = await Post.create({ content }); - await Reaction.bulkCreate( - reactionTypes.map(type => ({ type, postId: post.id })) - ); - return post; -} - -await makePostWithReactions('Hello World', [ - 'Like', 'Angry', 'Laugh', 'Like', 'Like', 'Angry', 'Sad', 'Like' -]); -await makePostWithReactions('My Second Post', [ - 'Laugh', 'Laugh', 'Like', 'Laugh' -]); -``` - -Now, we are ready for examples of the power of subqueries. - -Let's say we wanted to compute via SQL a `laughReactionsCount` for each post. We can achieve that with a sub-query, such as the following: - -```sql -SELECT - *, - ( - SELECT COUNT(*) - FROM reactions AS reaction - WHERE - reaction.postId = post.id - AND - reaction.type = "Laugh" - ) AS laughReactionsCount -FROM posts AS post -``` - -If we run the above raw SQL query through Sequelize, we get: - -```json -[ - { - "id": 1, - "content": "Hello World", - "laughReactionsCount": 1 - }, - { - "id": 2, - "content": "My Second Post", - "laughReactionsCount": 3 - } -] -``` - -So how can we achieve that with more help from Sequelize, without having to write the whole raw query by hand? - -The answer: by combining the `attributes` option of the finder methods (such as `findAll`) with the `sequelize.literal` utility function, that allows you to directly insert arbitrary content into the query without any automatic escaping. - -This means that Sequelize will help you with the main, larger query, but you will still have to write that sub-query by yourself: - -```js -Post.findAll({ - attributes: { - include: [ - [ - // Note the wrapping parentheses in the call below! - sequelize.literal(`( - SELECT COUNT(*) - FROM reactions AS reaction - WHERE - reaction.postId = post.id - AND - reaction.type = "Laugh" - )`), - 'laughReactionsCount' - ] - ] - } -}); -``` - -*Important Note: Since `sequelize.literal` inserts arbitrary content without escaping to the query, it deserves very special attention since it may be a source of (major) security vulnerabilities. It should not be used on user-generated content.* However, here, we are using `sequelize.literal` with a fixed string, carefully written by us (the coders). This is ok, since we know what we are doing. - -The above gives the following output: - -```json -[ - { - "id": 1, - "content": "Hello World", - "laughReactionsCount": 1 - }, - { - "id": 2, - "content": "My Second Post", - "laughReactionsCount": 3 - } -] -``` - -Success! - -## Using sub-queries for complex ordering - -This idea can be used to enable complex ordering, such as ordering posts by the number of laugh reactions they have: - -```js -Post.findAll({ - attributes: { - include: [ - [ - sequelize.literal(`( - SELECT COUNT(*) - FROM reactions AS reaction - WHERE - reaction.postId = post.id - AND - reaction.type = "Laugh" - )`), - 'laughReactionsCount' - ] - ] - }, - order: [ - [sequelize.literal('laughReactionsCount'), 'DESC'] - ] -}); -``` - -Result: - -```json -[ - { - "id": 2, - "content": "My Second Post", - "laughReactionsCount": 3 - }, - { - "id": 1, - "content": "Hello World", - "laughReactionsCount": 1 - } -] -``` \ No newline at end of file diff --git a/docs/manual/other-topics/transactions.md b/docs/manual/other-topics/transactions.md deleted file mode 100644 index e24f6d216781..000000000000 --- a/docs/manual/other-topics/transactions.md +++ /dev/null @@ -1,311 +0,0 @@ -# Transactions - -Sequelize does not use [transactions](https://en.wikipedia.org/wiki/Database_transaction) by default. However, for production-ready usage of Sequelize, you should definitely configure Sequelize to use transactions. - -Sequelize supports two ways of using transactions: - -1. **Unmanaged transactions:** Committing and rolling back the transaction should be done manually by the user (by calling the appropriate Sequelize methods). - -2. **Managed transactions**: Sequelize will automatically rollback the transaction if any error is thrown, or commit the transaction otherwise. Also, if CLS (Continuation Local Storage) is enabled, all queries within the transaction callback will automatically receive the transaction object. - -## Unmanaged transactions - -Let's start with an example: - -```js -// First, we start a transaction and save it into a variable -const t = await sequelize.transaction(); - -try { - - // Then, we do some calls passing this transaction as an option: - - const user = await User.create({ - firstName: 'Bart', - lastName: 'Simpson' - }, { transaction: t }); - - await user.addSibling({ - firstName: 'Lisa', - lastName: 'Simpson' - }, { transaction: t }); - - // If the execution reaches this line, no errors were thrown. - // We commit the transaction. - await t.commit(); - -} catch (error) { - - // If the execution reaches this line, an error was thrown. - // We rollback the transaction. - await t.rollback(); - -} -``` - -As shown above, the *unmanaged transaction* approach requires that you commit and rollback the transaction manually, when necessary. - -## Managed transactions - -Managed transactions handle committing or rolling back the transaction automatically. You start a managed transaction by passing a callback to `sequelize.transaction`. This callback can be `async` (and usually is). - -The following will happen in this case: - -* Sequelize will automatically start a transaction and obtain a transaction object `t` -* Then, Sequelize will execute the callback you provided, passing `t` into it -* If your callback throws, Sequelize will automatically rollback the transaction -* If your callback succeeds, Sequelize will automatically commit the transaction -* Only then the `sequelize.transaction` call will settle: - * Either resolving with the resolution of your callback - * Or, if your callback throws, rejecting with the thrown error - -Example code: - -```js -try { - - const result = await sequelize.transaction(async (t) => { - - const user = await User.create({ - firstName: 'Abraham', - lastName: 'Lincoln' - }, { transaction: t }); - - await user.setShooter({ - firstName: 'John', - lastName: 'Boothe' - }, { transaction: t }); - - return user; - - }); - - // If the execution reaches this line, the transaction has been committed successfully - // `result` is whatever was returned from the transaction callback (the `user`, in this case) - -} catch (error) { - - // If the execution reaches this line, an error occurred. - // The transaction has already been rolled back automatically by Sequelize! - -} -``` - -Note that `t.commit()` and `t.rollback()` were not called directly (which is correct). - -### Throw errors to rollback - -When using the managed transaction you should *never* commit or rollback the transaction manually. If all queries are successful (in the sense of not throwing any error), but you still want to rollback the transaction, you should throw an error yourself: - -```js -await sequelize.transaction(async t => { - const user = await User.create({ - firstName: 'Abraham', - lastName: 'Lincoln' - }, { transaction: t }); - - // Woops, the query was successful but we still want to roll back! - // We throw an error manually, so that Sequelize handles everything automatically. - throw new Error(); -}); -``` - -### Automatically pass transactions to all queries - -In the examples above, the transaction is still manually passed, by passing `{ transaction: t }` as the second argument. To automatically pass the transaction to all queries you must install the [cls-hooked](https://github.com/Jeff-Lewis/cls-hooked) (CLS) module and instantiate a namespace in your own code: - -```js -const cls = require('cls-hooked'); -const namespace = cls.createNamespace('my-very-own-namespace'); -``` - -To enable CLS you must tell sequelize which namespace to use by using a static method of the sequelize constructor: - -```js -const Sequelize = require('sequelize'); -Sequelize.useCLS(namespace); - -new Sequelize(....); -``` - -Notice, that the `useCLS()` method is on the *constructor*, not on an instance of sequelize. This means that all instances will share the same namespace, and that CLS is all-or-nothing - you cannot enable it only for some instances. - -CLS works like a thread-local storage for callbacks. What this means in practice is that different callback chains can access local variables by using the CLS namespace. When CLS is enabled sequelize will set the `transaction` property on the namespace when a new transaction is created. Since variables set within a callback chain are private to that chain several concurrent transactions can exist at the same time: - -```js -sequelize.transaction((t1) => { - namespace.get('transaction') === t1; // true -}); - -sequelize.transaction((t2) => { - namespace.get('transaction') === t2; // true -}); -``` - -In most case you won't need to access `namespace.get('transaction')` directly, since all queries will automatically look for a transaction on the namespace: - -```js -sequelize.transaction((t1) => { - // With CLS enabled, the user will be created inside the transaction - return User.create({ name: 'Alice' }); -}); -``` - -## Concurrent/Partial transactions - -You can have concurrent transactions within a sequence of queries or have some of them excluded from any transactions. Use the `transaction` option to control which transaction a query belongs to: - -**Note:** *SQLite does not support more than one transaction at the same time.* - -### With CLS enabled - -```js -sequelize.transaction((t1) => { - return sequelize.transaction((t2) => { - // With CLS enabled, queries here will by default use t2. - // Pass in the `transaction` option to define/alter the transaction they belong to. - return Promise.all([ - User.create({ name: 'Bob' }, { transaction: null }), - User.create({ name: 'Mallory' }, { transaction: t1 }), - User.create({ name: 'John' }) // this would default to t2 - ]); - }); -}); -``` - -## Passing options - -The `sequelize.transaction` method accepts options. - -For unmanaged transactions, just use `sequelize.transaction(options)`. - -For managed transactions, use `sequelize.transaction(options, callback)`. - -## Isolation levels - -The possible isolations levels to use when starting a transaction: - -```js -const { Transaction } = require('sequelize'); - -// The following are valid isolation levels: -Transaction.ISOLATION_LEVELS.READ_UNCOMMITTED // "READ UNCOMMITTED" -Transaction.ISOLATION_LEVELS.READ_COMMITTED // "READ COMMITTED" -Transaction.ISOLATION_LEVELS.REPEATABLE_READ // "REPEATABLE READ" -Transaction.ISOLATION_LEVELS.SERIALIZABLE // "SERIALIZABLE" -``` - -By default, sequelize uses the isolation level of the database. If you want to use a different isolation level, pass in the desired level as the first argument: - -```js -const { Transaction } = require('sequelize'); - -await sequelize.transaction({ - isolationLevel: Transaction.ISOLATION_LEVELS.SERIALIZABLE -}, async (t) => { - // Your code -}); -``` - -You can also overwrite the `isolationLevel` setting globally with an option in the Sequelize constructor: - -```js -const { Sequelize, Transaction } = require('sequelize'); - -const sequelize = new Sequelize('sqlite::memory:', { - isolationLevel: Transaction.ISOLATION_LEVELS.SERIALIZABLE -}); -``` - -**Note for MSSQL:** _The `SET ISOLATION LEVEL` queries are not logged since the specified `isolationLevel` is passed directly to `tedious`._ - -## Usage with other sequelize methods - -The `transaction` option goes with most other options, which are usually the first argument of a method. - -For methods that take values, like `.create`, `.update()`, etc. `transaction` should be passed to the option in the second argument. - -If unsure, refer to the API documentation for the method you are using to be sure of the signature. - -Examples: - -```js -await User.create({ name: 'Foo Bar' }, { transaction: t }); - -await User.findAll({ - where: { - name: 'Foo Bar' - }, - transaction: t -}); -``` - -## The `afterCommit` hook - -A `transaction` object allows tracking if and when it is committed. - -An `afterCommit` hook can be added to both managed and unmanaged transaction objects: - -```js -// Managed transaction: -await sequelize.transaction(async (t) => { - t.afterCommit(() => { - // Your logic - }); -}); - -// Unmanaged transaction: -const t = await sequelize.transaction(); -t.afterCommit(() => { - // Your logic -}); -await t.commit(); -``` - -The callback passed to `afterCommit` can be `async`. In this case: - -* For a managed transaction: the `sequelize.transaction` call will wait for it before settling; -* For an unmanaged transaction: the `t.commit` call will wait for it before settling. - -Notes: - -* The `afterCommit` hook is not raised if the transaction is rolled back; -* The `afterCommit` hook does not modify the return value of the transaction (unlike most hooks) - -You can use the `afterCommit` hook in conjunction with model hooks to know when a instance is saved and available outside of a transaction - -```js -User.afterSave((instance, options) => { - if (options.transaction) { - // Save done within a transaction, wait until transaction is committed to - // notify listeners the instance has been saved - options.transaction.afterCommit(() => /* Notify */) - return; - } - // Save done outside a transaction, safe for callers to fetch the updated model - // Notify -}); -``` - -## Locks - -Queries within a `transaction` can be performed with locks: - -```js -return User.findAll({ - limit: 1, - lock: true, - transaction: t1 -}); -``` - -Queries within a transaction can skip locked rows: - -```js -return User.findAll({ - limit: 1, - lock: true, - skipLocked: true, - transaction: t2 -}); -``` diff --git a/docs/manual/other-topics/typescript.md b/docs/manual/other-topics/typescript.md deleted file mode 100644 index cde929b3dee2..000000000000 --- a/docs/manual/other-topics/typescript.md +++ /dev/null @@ -1,529 +0,0 @@ -# TypeScript - -Sequelize provides its own TypeScript definitions. - -Please note that only **TypeScript >= 4.1** is supported. -Our TypeScript support does not follow SemVer. We will support TypeScript releases for at least one year, after which they may be dropped in a SemVer MINOR release. - -As Sequelize heavily relies on runtime property assignments, TypeScript won't be very useful out of the box. -A decent amount of manual type declarations are needed to make models workable. - -## Installation - -In order to avoid installation bloat for non TS users, you must install the following typing packages manually: - -- `@types/node` (this is universally required in node projects) -- `@types/validator` - -## Usage - -**Important**: You must use `declare` on your class properties typings to ensure TypeScript does not emit those class properties. -See [Caveat with Public Class Fields](./model-basics.html#caveat-with-public-class-fields) - -Sequelize Models accept two generic types to define what the model's Attributes & Creation Attributes are like: - -```typescript -import { Model, Optional } from 'sequelize'; - -// We don't recommend doing this. Read on for the new way of declaring Model typings. - -type UserAttributes = { - id: number, - name: string, - // other attributes... -}; - -// we're telling the Model that 'id' is optional -// when creating an instance of the model (such as using Model.create()). -type UserCreationAttributes = Optional; - -class User extends Model { - declare id: number; - declare string: number; - // other attributes... -} -``` - -This solution is verbose. Sequelize >=6.14.0 provides new utility types that will drastically reduce the amount -of boilerplate necessary: `InferAttributes`, and `InferCreationAttributes`. They will extract Attribute typings -directly from the Model: - -```typescript -import { Model, InferAttributes, InferCreationAttributes, CreationOptional } from 'sequelize'; - -// order of InferAttributes & InferCreationAttributes is important. -class User extends Model, InferCreationAttributes> { - // 'CreationOptional' is a special type that marks the field as optional - // when creating an instance of the model (such as using Model.create()). - declare id: CreationOptional; - declare string: number; - // other attributes... -} -``` - -Important things to know about `InferAttributes` & `InferCreationAttributes` work: They will select all declared properties of the class except: - -- Static fields and methods. -- Methods (anything whose type is a function). -- Those whose type uses the branded type `NonAttribute`. -- Those excluded by using AttributesOf like this: `InferAttributes`. -- Those declared by the Model superclass (but not intermediary classes!). - If one of your attributes shares the same name as one of the properties of `Model`, change its name. - Doing this is likely to cause issues anyway. -- Getter & setters are not automatically excluded. Set their return / parameter type to `NonAttribute`, - or add them to `omit` to exclude them. - -`InferCreationAttributes` works the same way as `AttributesOf` with one exception: Properties typed using the `CreationOptional` type -will be marked as optional. - -You only need to use `CreationOptional` & `NonAttribute` on class instance fields or getters. - -Example of a minimal TypeScript project with strict type-checking for attributes: - -[//]: # (NOTE for maintainers: Keep the following code in sync with `/types/test/typescriptDocs/ModelInit.ts` to ensure it typechecks correctly.) - -```typescript -import { - Association, DataTypes, HasManyAddAssociationMixin, HasManyCountAssociationsMixin, - HasManyCreateAssociationMixin, HasManyGetAssociationsMixin, HasManyHasAssociationMixin, - HasManySetAssociationsMixin, HasManyAddAssociationsMixin, HasManyHasAssociationsMixin, - HasManyRemoveAssociationMixin, HasManyRemoveAssociationsMixin, Model, ModelDefined, Optional, - Sequelize, InferAttributes, InferCreationAttributes, CreationOptional, NonAttribute -} from 'sequelize'; - -const sequelize = new Sequelize('mysql://root:asd123@localhost:3306/mydb'); - -// 'projects' is excluded as it's not an attribute, it's an association. -class User extends Model, InferCreationAttributes> { - // id can be undefined during creation when using `autoIncrement` - declare id: CreationOptional; - declare name: string; - declare preferredName: string | null; // for nullable fields - - // timestamps! - // createdAt can be undefined during creation - declare createdAt: CreationOptional; - // updatedAt can be undefined during creation - declare updatedAt: CreationOptional; - - // Since TS cannot determine model association at compile time - // we have to declare them here purely virtually - // these will not exist until `Model.init` was called. - declare getProjects: HasManyGetAssociationsMixin; // Note the null assertions! - declare addProject: HasManyAddAssociationMixin; - declare addProjects: HasManyAddAssociationsMixin; - declare setProjects: HasManySetAssociationsMixin; - declare removeProject: HasManyRemoveAssociationMixin; - declare removeProjects: HasManyRemoveAssociationsMixin; - declare hasProject: HasManyHasAssociationMixin; - declare hasProjects: HasManyHasAssociationsMixin; - declare countProjects: HasManyCountAssociationsMixin; - declare createProject: HasManyCreateAssociationMixin; - - // You can also pre-declare possible inclusions, these will only be populated if you - // actively include a relation. - declare projects?: NonAttribute; // Note this is optional since it's only populated when explicitly requested in code - - // getters that are not attributes should be tagged using NonAttribute - // to remove them from the model's Attribute Typings. - get fullName(): NonAttribute { - return this.name; - } - - declare static associations: { - projects: Association; - }; -} - -class Project extends Model< - InferAttributes, - InferCreationAttributes -> { - // id can be undefined during creation when using `autoIncrement` - declare id: CreationOptional; - declare ownerId: number; - declare name: string; - - // `owner` is an eagerly-loaded association. - // We tag it as `NonAttribute` - declare owner?: NonAttribute; - - // createdAt can be undefined during creation - declare createdAt: CreationOptional; - // updatedAt can be undefined during creation - declare updatedAt: CreationOptional; -} - -class Address extends Model< - InferAttributes
, - InferCreationAttributes
-> { - declare userId: number; - declare address: string; - - // createdAt can be undefined during creation - declare createdAt: CreationOptional; - // updatedAt can be undefined during creation - declare updatedAt: CreationOptional; -} - -Project.init( - { - id: { - type: DataTypes.INTEGER.UNSIGNED, - autoIncrement: true, - primaryKey: true - }, - ownerId: { - type: DataTypes.INTEGER.UNSIGNED, - allowNull: false - }, - name: { - type: new DataTypes.STRING(128), - allowNull: false - }, - createdAt: DataTypes.DATE, - updatedAt: DataTypes.DATE, - }, - { - sequelize, - tableName: 'projects' - } -); - -User.init( - { - id: { - type: DataTypes.INTEGER.UNSIGNED, - autoIncrement: true, - primaryKey: true - }, - name: { - type: new DataTypes.STRING(128), - allowNull: false - }, - preferredName: { - type: new DataTypes.STRING(128), - allowNull: true - }, - createdAt: DataTypes.DATE, - updatedAt: DataTypes.DATE, - }, - { - tableName: 'users', - sequelize // passing the `sequelize` instance is required - } -); - -Address.init( - { - userId: { - type: DataTypes.INTEGER.UNSIGNED - }, - address: { - type: new DataTypes.STRING(128), - allowNull: false - }, - createdAt: DataTypes.DATE, - updatedAt: DataTypes.DATE, - }, - { - tableName: 'address', - sequelize // passing the `sequelize` instance is required - } -); - -// You can also define modules in a functional way -interface NoteAttributes { - id: number; - title: string; - content: string; -} - -// You can also set multiple attributes optional at once -type NoteCreationAttributes = Optional; - -// And with a functional approach defining a module looks like this -const Note: ModelDefined< - NoteAttributes, - NoteCreationAttributes -> = sequelize.define( - 'Note', - { - id: { - type: DataTypes.INTEGER.UNSIGNED, - autoIncrement: true, - primaryKey: true - }, - title: { - type: new DataTypes.STRING(64), - defaultValue: 'Unnamed Note' - }, - content: { - type: new DataTypes.STRING(4096), - allowNull: false - } - }, - { - tableName: 'notes' - } -); - -// Here we associate which actually populates out pre-declared `association` static and other methods. -User.hasMany(Project, { - sourceKey: 'id', - foreignKey: 'ownerId', - as: 'projects' // this determines the name in `associations`! -}); - -Address.belongsTo(User, { targetKey: 'id' }); -User.hasOne(Address, { sourceKey: 'id' }); - -async function doStuffWithUser() { - const newUser = await User.create({ - name: 'Johnny', - preferredName: 'John', - }); - console.log(newUser.id, newUser.name, newUser.preferredName); - - const project = await newUser.createProject({ - name: 'first!' - }); - - const ourUser = await User.findByPk(1, { - include: [User.associations.projects], - rejectOnEmpty: true // Specifying true here removes `null` from the return type! - }); - - // Note the `!` null assertion since TS can't know if we included - // the model or not - console.log(ourUser.projects![0].name); -} - -(async () => { - await sequelize.sync(); - await doStuffWithUser(); -})(); -``` - -### Usage without strict types for attributes - -The typings for Sequelize v5 allowed you to define models without specifying types for the attributes. This is still possible for backwards compatibility and for cases where you feel strict typing for attributes isn't worth it. - -[//]: # (NOTE for maintainers: Keep the following code in sync with `typescriptDocs/ModelInitNoAttributes.ts` to ensure it typechecks correctly.) - -```ts -import { Sequelize, Model, DataTypes } from "sequelize"; - -const sequelize = new Sequelize("mysql://root:asd123@localhost:3306/mydb"); - -class User extends Model { - declare id: number; - declare name: string; - declare preferredName: string | null; -} - -User.init( - { - id: { - type: DataTypes.INTEGER.UNSIGNED, - autoIncrement: true, - primaryKey: true, - }, - name: { - type: new DataTypes.STRING(128), - allowNull: false, - }, - preferredName: { - type: new DataTypes.STRING(128), - allowNull: true, - }, - }, - { - tableName: "users", - sequelize, // passing the `sequelize` instance is required - } -); - -async function doStuffWithUserModel() { - const newUser = await User.create({ - name: "Johnny", - preferredName: "John", - }); - console.log(newUser.id, newUser.name, newUser.preferredName); - - const foundUser = await User.findOne({ where: { name: "Johnny" } }); - if (foundUser === null) return; - console.log(foundUser.name); -} -``` - -## Usage of `sequelize.define` - -In Sequelize versions before v5, the default way of defining a model involved using `sequelize.define`. It's still possible to define models with that, and you can also add typings to these models using interfaces. - -[//]: # (NOTE for maintainers: Keep the following code in sync with `typescriptDocs/Define.ts` to ensure it typechecks correctly.) - -```ts -import { Sequelize, Model, DataTypes, Optional } from "sequelize"; - -const sequelize = new Sequelize("mysql://root:asd123@localhost:3306/mydb"); - -// We recommend you declare an interface for the attributes, for stricter typechecking -interface UserAttributes { - id: number; - name: string; -} - -// Some fields are optional when calling UserModel.create() or UserModel.build() -interface UserCreationAttributes extends Optional {} - -// We need to declare an interface for our model that is basically what our class would be -interface UserInstance - extends Model, - UserAttributes {} - -const UserModel = sequelize.define("User", { - id: { - primaryKey: true, - type: DataTypes.INTEGER.UNSIGNED, - }, - name: { - type: DataTypes.STRING, - }, -}); - -async function doStuff() { - const instance = await UserModel.findByPk(1, { - rejectOnEmpty: true, - }); - console.log(instance.id); -} -``` - -If you're comfortable with somewhat less strict typing for the attributes on a model, you can save some code by defining the Instance to just extend `Model` without any attributes in the generic types. - -[//]: # (NOTE for maintainers: Keep the following code in sync with `typescriptDocs/DefineNoAttributes.ts` to ensure it typechecks correctly.) - -```ts -import { Sequelize, Model, DataTypes } from "sequelize"; - -const sequelize = new Sequelize("mysql://root:asd123@localhost:3306/mydb"); - -// We need to declare an interface for our model that is basically what our class would be -interface UserInstance extends Model { - id: number; - name: string; -} - -const UserModel = sequelize.define("User", { - id: { - primaryKey: true, - type: DataTypes.INTEGER.UNSIGNED, - }, - name: { - type: DataTypes.STRING, - }, -}); - -async function doStuff() { - const instance = await UserModel.findByPk(1, { - rejectOnEmpty: true, - }); - console.log(instance.id); -} -``` - -## Utility Types - -### Requesting a Model Class - -`ModelStatic` is designed to be used to type a Model *class*. - -Here is an example of a utility method that requests a Model Class, and returns the list of primary keys defined in that class: - -```typescript -import { ModelStatic, ModelAttributeColumnOptions, Model, InferAttributes, InferCreationAttributes, CreationOptional } from 'sequelize'; - -/** - * Returns the list of attributes that are part of the model's primary key. - */ -export function getPrimaryKeyAttributes(model: ModelStatic): ModelAttributeColumnOptions[] { - const attributes: ModelAttributeColumnOptions[] = []; - - for (const attribute of Object.values(model.rawAttributes)) { - if (attribute.primaryKey) { - attributes.push(attribute); - } - } - - return attributes; -} - -class User extends Model, InferCreationAttributes> { - id: CreationOptional; -} - -User.init({ - id: { - type: DataTypes.INTEGER.UNSIGNED, - autoIncrement: true, - primaryKey: true - }, -}, { sequelize }); - -const primaryAttributes = getPrimaryKeyAttributes(User); -``` - -### Getting a Model's attributes - -If you need to access the list of attributes of a given model, `Attributes` and `CreationAttributes` -are what you need to use. - -They will return the Attributes (and Creation Attributes) of the Model passed as a parameter. - -Don't confuse them with `InferAttributes` and `InferCreationAttributes`. These two utility types should only every be used -in the definition of a Model to automatically create the list of attributes from the model's public class fields. They only work -with class-based model definitions (When using `Model.init`). - -`Attributes` and `CreationAttributes` will return the list of attributes of any model, no matter how they were created (be it `Model.init` or `Sequelize#define`). - -Here is an example of a utility function that requests a Model Class, and the name of an attribute ; and returns the corresponding attribute metadata. - -```typescript -import { - ModelStatic, - ModelAttributeColumnOptions, - Model, - InferAttributes, - InferCreationAttributes, - CreationOptional, - Attributes -} from 'sequelize'; - -export function getAttributeMetadata(model: ModelStatic, attributeName: keyof Attributes): ModelAttributeColumnOptions { - const attribute = model.rawAttributes[attributeName]; - if (attribute == null) { - throw new Error(`Attribute ${attributeName} does not exist on model ${model.name}`); - } - - return attribute; -} - -class User extends Model, InferCreationAttributes> { - id: CreationOptional; -} - -User.init({ - id: { - type: DataTypes.INTEGER.UNSIGNED, - autoIncrement: true, - primaryKey: true - }, -}, { sequelize }); - -const idAttributeMeta = getAttributeMetadata(User, 'id'); // works! - -// @ts-expect-error -const nameAttributeMeta = getAttributeMetadata(User, 'name'); // fails because 'name' is not an attribute of User -``` diff --git a/docs/manual/other-topics/upgrade-to-v6.md b/docs/manual/other-topics/upgrade-to-v6.md deleted file mode 100644 index fd047d5cd694..000000000000 --- a/docs/manual/other-topics/upgrade-to-v6.md +++ /dev/null @@ -1,236 +0,0 @@ -# Upgrade to v6 - -Sequelize v6 is the next major release after v5. Below is a list of breaking changes to help you upgrade. - -## Breaking Changes - -### Support for Node 10 and up - -Sequelize v6 will only support Node 10 and up [#10821](https://github.com/sequelize/sequelize/issues/10821). - -### CLS - -You should now use [cls-hooked](https://github.com/Jeff-Lewis/cls-hooked) package for CLS support. - -```js -const cls = require("cls-hooked"); -const namespace = cls.createNamespace("...."); -const Sequelize = require("sequelize"); - -Sequelize.useCLS(namespace); -``` - -### Database Engine Support - -We have updated our minimum supported database engine versions. Using older database engine will show `SEQUELIZE0006` deprecation warning. Please check [ENGINE.md](https://github.com/sequelize/sequelize/blob/main/ENGINE.md) for version table. - -### Sequelize - -- Bluebird has been removed. Internally all methods are now using async/await. Public API now returns native promises. Thanks to [Andy Edwards](https://github.com/jedwards1211) for this refactor work. -- `Sequelize.Promise` is no longer available. -- `sequelize.import` method has been removed. CLI users should update to `sequelize-cli@6`. -- All instances of QueryInterface and QueryGenerator have been renamed to their lowerCamelCase variants eg. queryInterface and queryGenerator when used as property names on Model and Dialect, the class names remain the same. - -### Model - -#### `options.returning` - -Option `returning: true` will no longer return attributes that are not defined in the model. Old behavior can be achieved by using `returning: ['*']` instead. - -#### `Model.changed()` - -This method now tests for equality with [`_.isEqual`](https://lodash.com/docs/4.17.15#isEqual) and is now deep aware for JSON objects. Modifying a nested value for a JSON object won't mark it as changed (since it is still the same object). - -```js -const instance = await MyModel.findOne(); - -instance.myJsonField.someProperty = 12345; // Changed from something else to 12345 -console.log(instance.changed()); // false - -await instance.save(); // this will not save anything - -instance.changed("myJsonField", true); -console.log(instance.changed()); // ['myJsonField'] - -await instance.save(); // will save -``` - -#### `Model.bulkCreate()` - -This method now throws `Sequelize.AggregateError` instead of `Bluebird.AggregateError`. All errors are now exposed as `errors` key. - -#### `Model.upsert()` - -Native upsert is now supported for all dialects. - -```js -const [instance, created] = await MyModel.upsert({}); -``` - -Signature for this method has been changed to `Promise`. First index contains upserted `instance`, second index contains a boolean (or `null`) indicating if record was created or updated. For SQLite/Postgres, `created` value will always be `null`. - -- MySQL - Implemented with ON DUPLICATE KEY UPDATE -- PostgreSQL - Implemented with ON CONFLICT DO UPDATE -- SQLite - Implemented with ON CONFLICT DO UPDATE -- MSSQL - Implemented with MERGE statement - -_Note for Postgres users:_ If upsert payload contains PK field, then PK will be used as the conflict target. Otherwise first unique constraint will be selected as the conflict key. - -### QueryInterface - -#### `addConstraint` - -This method now only takes 2 parameters, `tableName` and `options`. Previously the second parameter could be a list of column names to apply the constraint to, this list must now be passed as `options.fields` property. - -## Changelog - -### 6.0.0-beta.7 - -- docs(associations): belongs to many create with through table -- docs(query-interface): fix broken links [#12272](https://github.com/sequelize/sequelize/pull/12272) -- docs(sequelize): omitNull only works for CREATE/UPDATE queries -- docs: asyncify [#12297](https://github.com/sequelize/sequelize/pull/12297) -- docs: responsive [#12308](https://github.com/sequelize/sequelize/pull/12308) -- docs: update feature request template -- feat(postgres): native upsert [#12301](https://github.com/sequelize/sequelize/pull/12301) -- feat(sequelize): allow passing dialectOptions.options from url [#12404](https://github.com/sequelize/sequelize/pull/12404) -- fix(include): check if attributes specified for included through model [#12316](https://github.com/sequelize/sequelize/pull/12316) -- fix(model.destroy): return 0 with truncate [#12281](https://github.com/sequelize/sequelize/pull/12281) -- fix(mssql): empty order array generates invalid FETCH statement [#12261](https://github.com/sequelize/sequelize/pull/12261) -- fix(postgres): parse enums correctly when describing a table [#12409](https://github.com/sequelize/sequelize/pull/12409) -- fix(query): ensure correct return signature for QueryTypes.RAW [#12305](https://github.com/sequelize/sequelize/pull/12305) -- fix(query): preserve cls context for logger [#12328](https://github.com/sequelize/sequelize/pull/12328) -- fix(query-generator): do not generate GROUP BY clause if options.group is empty [#12343](https://github.com/sequelize/sequelize/pull/12343) -- fix(reload): include default scope [#12399](https://github.com/sequelize/sequelize/pull/12399) -- fix(types): add Association into OrderItem type [#12332](https://github.com/sequelize/sequelize/pull/12332) -- fix(types): add clientMinMessages to Options interface [#12375](https://github.com/sequelize/sequelize/pull/12375) -- fix(types): transactionType in Options [#12377](https://github.com/sequelize/sequelize/pull/12377) -- fix(types): add support for optional values in "where" clauses [#12337](https://github.com/sequelize/sequelize/pull/12337) -- fix(types): add missing fields to 'FindOrCreateType' [#12338](https://github.com/sequelize/sequelize/pull/12338) -- fix: add missing sql and parameters properties to some query errors [#12299](https://github.com/sequelize/sequelize/pull/12299) -- fix: remove custom inspect [#12262](https://github.com/sequelize/sequelize/pull/12262) -- refactor: cleanup query generators [#12304](https://github.com/sequelize/sequelize/pull/12304) - -### 6.0.0-beta.6 - -- docs(add-constraint): options.fields support -- docs(association): document uniqueKey for belongs to many [#12166](https://github.com/sequelize/sequelize/pull/12166) -- docs(association): options.through.where support -- docs(association): use and instead of 'a nd' [#12191](https://github.com/sequelize/sequelize/pull/12191) -- docs(association): use correct scope name [#12204](https://github.com/sequelize/sequelize/pull/12204) -- docs(manuals): avoid duplicate header ids [#12201](https://github.com/sequelize/sequelize/pull/12201) -- docs(model): correct syntax error in example code [#12137](https://github.com/sequelize/sequelize/pull/12137) -- docs(query-interface): removeIndex indexNameOrAttributes [#11947](https://github.com/sequelize/sequelize/pull/11947) -- docs(resources): add sequelize-guard library [#12235](https://github.com/sequelize/sequelize/pull/12235) -- docs(typescript): fix confusing comments [#12226](https://github.com/sequelize/sequelize/pull/12226) -- docs(v6-guide): bluebird removal API changes -- docs: database version support info [#12168](https://github.com/sequelize/sequelize/pull/12168) -- docs: remove remaining bluebird references [#12167](https://github.com/sequelize/sequelize/pull/12167) -- feat(belongs-to-many): allow creation of paranoid join tables [#12088](https://github.com/sequelize/sequelize/pull/12088) -- feat(belongs-to-many): get/has/count for paranoid join table [#12256](https://github.com/sequelize/sequelize/pull/12256) -- feat(pool): expose maxUses pool config option [#12101](https://github.com/sequelize/sequelize/pull/12101) -- feat(postgres): minify include aliases over limit [#11940](https://github.com/sequelize/sequelize/pull/11940) -- feat(sequelize): handle query string host value [#12041](https://github.com/sequelize/sequelize/pull/12041) -- fix(associations): ensure correct schema on all generated attributes [#12258](https://github.com/sequelize/sequelize/pull/12258) -- fix(docs/instances): use correct variable for increment [#12087](https://github.com/sequelize/sequelize/pull/12087) -- fix(include): separate queries are not sub-queries [#12144](https://github.com/sequelize/sequelize/pull/12144) -- fix(model): fix unchained promise in association logic in bulkCreate [#12163](https://github.com/sequelize/sequelize/pull/12163) -- fix(model): updateOnDuplicate handles composite keys [#11984](https://github.com/sequelize/sequelize/pull/11984) -- fix(model.count): distinct without any column generates invalid SQL [#11946](https://github.com/sequelize/sequelize/pull/11946) -- fix(model.reload): ignore options.where and always use this.where() [#12211](https://github.com/sequelize/sequelize/pull/12211) -- fix(mssql) insert record failure because of BOOLEAN column type [#12090](https://github.com/sequelize/sequelize/pull/12090) -- fix(mssql): cast sql_variant in query generator [#11994](https://github.com/sequelize/sequelize/pull/11994) -- fix(mssql): dont use OUTPUT INSERTED for update without returning [#12260](https://github.com/sequelize/sequelize/pull/12260) -- fix(mssql): duplicate order in FETCH/NEXT queries [#12257](https://github.com/sequelize/sequelize/pull/12257) -- fix(mssql): set correct scale for float [#11962](https://github.com/sequelize/sequelize/pull/11962) -- fix(mssql): tedious v9 requires connect call [#12182](https://github.com/sequelize/sequelize/pull/12182) -- fix(mssql): use uppercase for engine table and columns [#12212](https://github.com/sequelize/sequelize/pull/12212) -- fix(pool): show deprecation when engine is not supported [#12218](https://github.com/sequelize/sequelize/pull/12218) -- fix(postgres): addColumn support ARRAY(ENUM) [#12259](https://github.com/sequelize/sequelize/pull/12259) -- fix(query): do not bind \$ used within a whole-word [#12250](https://github.com/sequelize/sequelize/pull/12250) -- fix(query-generator): handle literal for substring based operators [#12210](https://github.com/sequelize/sequelize/pull/12210) -- fix(query-interface): allow passing null for query interface insert [#11931](https://github.com/sequelize/sequelize/pull/11931) -- fix(query-interface): allow sequelize.fn and sequelize.literal in fields of IndexesOptions [#12224](https://github.com/sequelize/sequelize/pull/12224) -- fix(scope): don't modify original scope definition [#12207](https://github.com/sequelize/sequelize/pull/12207) -- fix(sqlite): multiple primary keys results in syntax error [#12237](https://github.com/sequelize/sequelize/pull/12237) -- fix(sync): pass options to all query methods [#12208](https://github.com/sequelize/sequelize/pull/12208) -- fix(typings): add type_helpers to file list [#12000](https://github.com/sequelize/sequelize/pull/12000) -- fix(typings): correct Model.init return type [#12148](https://github.com/sequelize/sequelize/pull/12148) -- fix(typings): fn is assignable to where [#12040](https://github.com/sequelize/sequelize/pull/12040) -- fix(typings): getForeignKeysForTables argument definition [#12084](https://github.com/sequelize/sequelize/pull/12084) -- fix(typings): make between operator accept date ranges [#12162](https://github.com/sequelize/sequelize/pull/12162) -- refactor(ci): improve database wait script [#12132](https://github.com/sequelize/sequelize/pull/12132) -- refactor(tsd-test-setup): add & setup dtslint [#11879](https://github.com/sequelize/sequelize/pull/11879) -- refactor: move all dialect conditional logic into subclass [#12217](https://github.com/sequelize/sequelize/pull/12217) -- refactor: remove sequelize.import helper [#12175](https://github.com/sequelize/sequelize/pull/12175) -- refactor: use native versions [#12159](https://github.com/sequelize/sequelize/pull/12159) -- refactor: use object spread instead of Object.assign [#12213](https://github.com/sequelize/sequelize/pull/12213) - -### 6.0.0-beta.5 - -- fix(find-all): throw on empty attributes [#11867](https://github.com/sequelize/sequelize/pull/11867) -- fix(types): `queryInterface.addIndex` [#11844](https://github.com/sequelize/sequelize/pull/11844) -- fix(types): `plain` option in `sequelize.query` [#11596](https://github.com/sequelize/sequelize/pull/11596) -- fix(types): correct overloaded method order [#11727](https://github.com/sequelize/sequelize/pull/11727) -- fix(types): `comparator` arg of `Sequelize.where` [#11843](https://github.com/sequelize/sequelize/pull/11843) -- fix(types): fix BelongsToManyGetAssociationsMixinOptions [#11818](https://github.com/sequelize/sequelize/pull/11818) -- fix(types): adds `hooks` to `CreateOptions` [#11736](https://github.com/sequelize/sequelize/pull/11736) -- fix(increment): broken queries [#11852](https://github.com/sequelize/sequelize/pull/11852) -- fix(associations): gets on many-to-many with non-primary target key [#11778](https://github.com/sequelize/sequelize11778/pull/) -- fix: properly select SRID if present [#11763](https://github.com/sequelize/sequelize/pull/11763) -- feat(sqlite): automatic path provision for `options.storage` [#11853](https://github.com/sequelize/sequelize/pull/11853) -- feat(postgres): `idle_in_transaction_session_timeout` connection option [#11775](https://github.com/sequelize/sequelize11775/pull/) -- feat(index): improve to support multiple fields with operator [#11934](https://github.com/sequelize/sequelize/pull/11934) -- docs(transactions): fix addIndex example and grammar [#11759](https://github.com/sequelize/sequelize/pull/11759) -- docs(raw-queries): remove outdated info [#11833](https://github.com/sequelize/sequelize/pull/11833) -- docs(optimistic-locking): fix missing manual [#11850](https://github.com/sequelize/sequelize/pull/11850) -- docs(model): findOne return value for empty result [#11762](https://github.com/sequelize/sequelize/pull/11762) -- docs(model-querying-basics.md): add some commas [#11891](https://github.com/sequelize/sequelize/pull/11891) -- docs(manuals): fix missing models-definition page [#11838](https://github.com/sequelize/sequelize/pull/11838) -- docs(manuals): extensive rewrite [#11825](https://github.com/sequelize/sequelize/pull/11825) -- docs(dialect-specific): add MSSQL domain auth example [#11799](https://github.com/sequelize/sequelize/pull/11799) -- docs(associations): fix typos in assocs manual [#11888](https://github.com/sequelize/sequelize/pull/11888) -- docs(associations): fix typo [#11869](https://github.com/sequelize/sequelize/pull/11869) - -### 6.0.0-beta.4 - -- feat(sync): allow to bypass drop statements when sync with alter enabled [#11708](https://github.com/sequelize/sequelize/pull/11708) -- fix(model): injectDependentVirtualAttrs on included models [#11713](https://github.com/sequelize/sequelize/pull/11713) -- fix(model): generate ON CONFLICT ... DO UPDATE correctly [#11666](https://github.com/sequelize/sequelize/pull/11666) -- fix(mssql): optimize formatError RegEx [#11725](https://github.com/sequelize/sequelize/pull/11725) -- fix(types): add getForeignKeyReferencesForTable type [#11738](https://github.com/sequelize/sequelize/pull/11738) -- fix(types): add 'restore' hooks to types [#11730](https://github.com/sequelize/sequelize/pull/11730) -- fix(types): added 'fieldMaps' to QueryOptions typings [#11702](https://github.com/sequelize/sequelize/pull/11702) -- fix(types): add isSoftDeleted to Model [#11628](https://github.com/sequelize/sequelize/pull/11628) -- fix(types): fix upsert typing [#11674](https://github.com/sequelize/sequelize/pull/11674) -- fix(types): specified 'this' for getters and setters in fields [#11648](https://github.com/sequelize/sequelize/pull/11648) -- fix(types): add paranoid to UpdateOptions interface [#11647](https://github.com/sequelize/sequelize/pull/11647) -- fix(types): include 'as' in IncludeThroughOptions definition [#11624](https://github.com/sequelize/sequelize/pull/11624) -- fix(types): add Includeable to IncludeOptions.include type [#11622](https://github.com/sequelize/sequelize/pull/11622) -- fix(types): transaction lock [#11620](https://github.com/sequelize/sequelize/pull/11620) -- fix(sequelize.fn): escape dollarsign (#11533) [#11606](https://github.com/sequelize/sequelize/pull/11606) -- fix(types): add nested to Includeable [#11354](https://github.com/sequelize/sequelize/pull/11354) -- fix(types): add date to where [#11612](https://github.com/sequelize/sequelize/pull/11612) -- fix(types): add getDatabaseName (#11431) [#11614](https://github.com/sequelize/sequelize/pull/11614) -- fix(types): beforeDestroy [#11618](https://github.com/sequelize/sequelize/pull/11618) -- fix(types): query-interface table schema [#11582](https://github.com/sequelize/sequelize/pull/11582) -- docs: README.md [#11698](https://github.com/sequelize/sequelize/pull/11698) -- docs(sequelize): detail options.retry usage [#11643](https://github.com/sequelize/sequelize/pull/11643) -- docs: clarify logging option in Sequelize constructor [#11653](https://github.com/sequelize/sequelize/pull/11653) -- docs(migrations): fix syntax error in example [#11626](https://github.com/sequelize/sequelize/pull/11626) -- docs: describe logging option [#11654](https://github.com/sequelize/sequelize/pull/11654) -- docs(transaction): fix typo [#11659](https://github.com/sequelize/sequelize/pull/11659) -- docs(hooks): add info about belongs-to-many [#11601](https://github.com/sequelize/sequelize/pull/11601) -- docs(associations): fix typo [#11592](https://github.com/sequelize/sequelize/pull/11592) - -### 6.0.0-beta.3 - -- feat: support cls-hooked / tests [#11584](https://github.com/sequelize/sequelize/pull/11584) - -### 6.0.0-beta.2 - -- feat(postgres): change returning option to only return model attributes [#11526](https://github.com/sequelize/sequelize/pull/11526) -- fix(associations): allow binary key for belongs-to-many [#11578](https://github.com/sequelize/sequelize/pull/11578) -- fix(postgres): always replace returning statement for upsertQuery -- fix(model): make .changed() deep aware [#10851](https://github.com/sequelize/sequelize/pull/10851) -- change: use node 10 [#11580](https://github.com/sequelize/sequelize/pull/11580) diff --git a/docs/manual/other-topics/whos-using.md b/docs/manual/other-topics/whos-using.md deleted file mode 100644 index b872943a7bac..000000000000 --- a/docs/manual/other-topics/whos-using.md +++ /dev/null @@ -1,27 +0,0 @@ -# Who's using sequelize? - -[![Walmart labs logo](asset/walmart-labs-logo.png)](http://www.walmartlabs.com/) - -> ... we are avid users of sequelize (and have been for the past 18 months) (Feb 2017) - -
- -[![Snaplytics logo](asset/logo-snaplytics-green.png)](https://snaplytics.io) - -> We've been using sequelize since we started in the beginning of 2015. We use it for our graphql servers (in connection with [graphql-sequelize](http://github.com/mickhansen/graphql-sequelize)), and for all our background workers. - -
- -[![Connected Cars logo](asset/connected-cars.png)](https://connectedcars.io/) - -
- -[![Bitovi Logo](asset/bitovi-logo.png)](https://bitovi.com) - -> We have used Sequelize in enterprise projects for some of our Fortune 100 and Fortune 500 clients. It is used in deployments that are depended on by hundreds of millions of devices every year. - -
- -[![ErmesHotels Logo](asset/ermeshotels-logo.png)](https://www.ermeshotels.com) - -> Using Sequelize in production for two different apps with 30k+ daily users by 2 years. I doubt there is something better at this moment in terms of productivity and features. diff --git a/docs/transforms/group-data-types.js b/docs/transforms/group-data-types.js index 2aebe09b5c2e..b5fdd4411555 100644 --- a/docs/transforms/group-data-types.js +++ b/docs/transforms/group-data-types.js @@ -4,7 +4,7 @@ function groupDataTypes($, path) { let firstLi; $('nav a').each(function() { /* eslint-disable no-invalid-this */ - if ($(this).attr('href').startsWith('class/lib/data-types.js~')) { + if ($(this).attr('href').startsWith('class/src/data-types.js~')) { const li = $(this).closest('li'); if (!firstLi) { firstLi = li; @@ -19,7 +19,7 @@ function groupDataTypes($, path) { if (path.endsWith('identifiers.html')) { const rowsToDelete = []; $('table.summary td a').each(function() { - if ($(this).attr('href').startsWith('class/lib/data-types.js~')) { + if ($(this).attr('href').startsWith('class/src/data-types.js~')) { rowsToDelete.push($(this).closest('tr')); } }); @@ -32,4 +32,4 @@ function groupDataTypes($, path) { module.exports = function transform($, path) { groupDataTypes($, path); $('nav li[data-ice=doc]:first-child').css('margin-top', '15px'); -}; \ No newline at end of file +}; diff --git a/docs/transforms/header-customization.js b/docs/transforms/header-customization.js index 4f9dfcf1477b..26c320489ed8 100644 --- a/docs/transforms/header-customization.js +++ b/docs/transforms/header-customization.js @@ -5,19 +5,11 @@ module.exports = function transform($) { const githubLogoImage = $('header a img[src="./image/github.png"]'); apiReferenceLink - .text('API Reference') + .attr('href', '/docs/v6/intro/') + .text('Guides') .addClass('api-reference-link'); githubLogoImage .css('width', '30px') .attr('width', '30px'); - - githubLogoImage.closest('a') - .css('position', '') - .css('top', '') - .after(` - - - - `); }; diff --git a/index.js b/index.js index 942290085172..c41e6e3916a0 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,7 @@ 'use strict'; +// TODO [>=7]: remove me. I've been moved to 'exports' in package.json + /** * A Sequelize module that contains the sequelize entry point. * @@ -7,4 +9,4 @@ */ /** Exports the sequelize entry point. */ -module.exports = require('./lib/sequelize'); +module.exports = require('./lib'); diff --git a/lib/sql-string.js b/lib/sql-string.js deleted file mode 100644 index d56c0468b300..000000000000 --- a/lib/sql-string.js +++ /dev/null @@ -1,125 +0,0 @@ -'use strict'; - -const dataTypes = require('./data-types'); -const { logger } = require('./utils/logger'); - -function arrayToList(array, timeZone, dialect, format) { - return array.reduce((sql, val, i) => { - if (i !== 0) { - sql += ', '; - } - if (Array.isArray(val)) { - sql += `(${arrayToList(val, timeZone, dialect, format)})`; - } else { - sql += escape(val, timeZone, dialect, format); - } - return sql; - }, ''); -} -exports.arrayToList = arrayToList; - -function escape(val, timeZone, dialect, format) { - let prependN = false; - if (val === undefined || val === null) { - return 'NULL'; - } - switch (typeof val) { - case 'boolean': - // SQLite doesn't have true/false support. MySQL aliases true/false to 1/0 - // for us. Postgres actually has a boolean type with true/false literals, - // but sequelize doesn't use it yet. - if (['sqlite', 'mssql'].includes(dialect)) { - return +!!val; - } - return (!!val).toString(); - case 'number': - return val.toString(); - case 'string': - // In mssql, prepend N to all quoted vals which are originally a string (for - // unicode compatibility) - prependN = dialect === 'mssql'; - break; - } - - if (val instanceof Date) { - val = dataTypes[dialect].DATE.prototype.stringify(val, { timezone: timeZone }); - } - - if (Buffer.isBuffer(val)) { - if (dataTypes[dialect].BLOB) { - return dataTypes[dialect].BLOB.prototype.stringify(val); - } - - return dataTypes.BLOB.prototype.stringify(val); - } - - if (Array.isArray(val)) { - const partialEscape = escVal => escape(escVal, timeZone, dialect, format); - if (dialect === 'postgres' && !format) { - return dataTypes.ARRAY.prototype.stringify(val, { escape: partialEscape }); - } - return arrayToList(val, timeZone, dialect, format); - } - - if (!val.replace) { - throw new Error(`Invalid value ${logger.inspect(val)}`); - } - - if (['postgres', 'sqlite', 'mssql', 'snowflake', 'db2'].includes(dialect)) { - // http://www.postgresql.org/docs/8.2/static/sql-syntax-lexical.html#SQL-SYNTAX-STRINGS - // http://stackoverflow.com/q/603572/130598 - val = val.replace(/'/g, "''"); - - if (dialect === 'postgres') { - // null character is not allowed in Postgres - val = val.replace(/\0/g, '\\0'); - } - } else { - - // eslint-disable-next-line no-control-regex - val = val.replace(/[\0\n\r\b\t\\'"\x1a]/g, s => { - switch (s) { - case '\0': return '\\0'; - case '\n': return '\\n'; - case '\r': return '\\r'; - case '\b': return '\\b'; - case '\t': return '\\t'; - case '\x1a': return '\\Z'; - default: return `\\${s}`; - } - }); - } - return `${(prependN ? "N'" : "'") + val}'`; -} -exports.escape = escape; - -function format(sql, values, timeZone, dialect) { - values = [].concat(values); - - if (typeof sql !== 'string') { - throw new Error(`Invalid SQL string provided: ${sql}`); - } - - return sql.replace(/\?/g, match => { - if (!values.length) { - return match; - } - - return escape(values.shift(), timeZone, dialect, true); - }); -} -exports.format = format; - -function formatNamedParameters(sql, values, timeZone, dialect) { - return sql.replace(/:+(?!\d)(\w+)/g, (value, key) => { - if ('postgres' === dialect && '::' === value.slice(0, 2)) { - return value; - } - - if (values[key] !== undefined) { - return escape(values[key], timeZone, dialect, true); - } - throw new Error(`Named parameter "${value}" has no value in the given object.`); - }); -} -exports.formatNamedParameters = formatNamedParameters; diff --git a/logo.svg b/logo.svg new file mode 100644 index 000000000000..0ee676a33cc8 --- /dev/null +++ b/logo.svg @@ -0,0 +1,41 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/package.json b/package.json index 3e592d09ebe4..bc69e634ae69 100644 --- a/package.json +++ b/package.json @@ -16,45 +16,53 @@ "url": "https://github.com/sequelize/sequelize/issues" }, "homepage": "https://sequelize.org/", - "main": "./dist/index.js", - "types": "./dist", + "main": "./lib/index.js", + "types": "./types/index.d.ts", "type": "commonjs", "exports": { ".": { - "import": "./dist/index.mjs", - "require": "./dist/index.js" + "types": "./types/index.d.ts", + "import": "./lib/index.mjs", + "require": "./lib/index.js" }, - "./lib/*": "./dist/lib/*.js", - "./lib/errors": "./dist/lib/errors/index.js", - "./*": "./*" + "./lib/*": { + "types": "./types/*.d.ts", + "default": "./lib/*.js" + }, + "./lib/errors": { + "types": "./types/errors/index.d.ts", + "default": "./lib/errors/index.js" + }, + "./package.json": "./package.json", + "./types/*": { + "types": "./types/*.d.ts" + } }, "engines": { "node": ">=10.0.0" }, "files": [ - "dist", "lib", - "index.js", - "types/index.d.ts", - "types/lib", - "types/type-helpers" + "types", + "index.js" ], "license": "MIT", "dependencies": { - "@types/debug": "^4.1.7", - "debug": "^4.3.3", - "dottie": "^2.0.2", - "inflection": "^1.13.1", + "@types/debug": "^4.1.8", + "@types/validator": "^13.7.17", + "debug": "^4.3.4", + "dottie": "^2.0.6", + "inflection": "^1.13.4", "lodash": "^4.17.21", - "moment": "^2.29.1", - "moment-timezone": "^0.5.34", - "pg-connection-string": "^2.5.0", - "retry-as-promised": "^5.0.0", - "semver": "^7.3.5", + "moment": "^2.29.4", + "moment-timezone": "^0.5.43", + "pg-connection-string": "^2.6.1", + "retry-as-promised": "^7.0.4", + "semver": "^7.5.4", "sequelize-pool": "^7.1.0", "toposort-class": "^1.0.1", "uuid": "^8.3.2", - "validator": "^13.7.0", + "validator": "^13.9.0", "wkx": "^0.5.0" }, "devDependencies": { @@ -63,14 +71,14 @@ "@octokit/rest": "^18.12.0", "@octokit/types": "^6.34.0", "@types/chai": "^4.3.0", + "@types/lodash": "4.14.197", "@types/mocha": "^9.0.0", "@types/node": "^16.11.17", "@types/sinon": "^10.0.6", - "@types/validator": "^13.7.1", "@typescript-eslint/eslint-plugin": "^5.8.1", "@typescript-eslint/parser": "^5.8.1", "acorn": "^8.7.0", - "chai": "^4.3.4", + "chai": "^4.3.7", "chai-as-promised": "^7.1.1", "chai-datetime": "^1.8.0", "cheerio": "^1.0.0-rc.10", @@ -101,6 +109,7 @@ "mysql2": "^2.3.3", "node-hook": "^1.0.0", "nyc": "^15.1.0", + "oracledb": "^5.5.0", "p-map": "^4.0.0", "p-props": "^4.0.0", "p-settle": "^4.1.1", @@ -114,7 +123,7 @@ "sinon-chai": "^3.7.0", "snowflake-sdk": "^1.6.6", "source-map-support": "^0.5.21", - "sqlite3": "npm:@vscode/sqlite3@^5.0.7", + "sqlite3": "^5.1.6", "tedious": "8.3.0", "typescript": "^4.5.4" }, @@ -142,6 +151,9 @@ }, "tedious": { "optional": true + }, + "oracledb": { + "optional": true } }, "keywords": [ @@ -155,6 +167,7 @@ "db2", "ibm_db", "sql", + "oracledb", "sqlserver", "snowflake", "orm", @@ -211,11 +224,11 @@ }, "scripts": { "----------------------------------------- static analysis -----------------------------------------": "", - "lint": "eslint lib test --quiet --fix", + "lint": "eslint src test --quiet --fix", "lint-docs": "markdownlint docs", - "test-typings": "tsc -b types/tsconfig.json && tsc -b types/test/tsconfig.json && tsc --noEmit --emitDeclarationOnly false && tsc -b test/tsconfig.json", + "test-typings": "tsc --noEmit --emitDeclarationOnly false && tsc -b test/tsconfig.json", "----------------------------------------- documentation -------------------------------------------": "", - "docs": "rimraf esdoc && esdoc -c docs/esdoc-config.js && cp docs/favicon.ico esdoc/favicon.ico && cp docs/ROUTER.txt esdoc/ROUTER && node docs/run-docs-transforms.js && node docs/redirects/create-redirects.js && rimraf esdoc/file esdoc/source.html", + "docs": "sh docs.sh", "----------------------------------------- tests ---------------------------------------------------": "", "mocha": "mocha -r ./test/registerEsbuild", "test-unit": "yarn mocha \"test/unit/**/*.test.[tj]s\"", @@ -234,17 +247,23 @@ "start-postgres": "bash dev/postgres/10/start.sh", "start-mssql": "bash dev/mssql/2019/start.sh", "start-db2": "bash dev/db2/11.5/start.sh", + "start-oracle-oldest": "bash dev/oracle/18-slim/start.sh", + "start-oracle-latest": "bash dev/oracle/23-slim/start.sh", "stop-mariadb": "bash dev/mariadb/10.3/stop.sh", "stop-mysql": "bash dev/mysql/5.7/stop.sh", "stop-mysql-8": "bash dev/mysql/8.0/stop.sh", "stop-postgres": "bash dev/postgres/10/stop.sh", "stop-mssql": "bash dev/mssql/2019/stop.sh", "stop-db2": "bash dev/db2/11.5/stop.sh", + "stop-oracle-oldest": "bash dev/oracle/18-slim/stop.sh", + "stop-oracle-latest": "bash dev/oracle/23-slim/stop.sh", "restart-mariadb": "npm run start-mariadb", "restart-mysql": "npm run start-mysql", "restart-postgres": "npm run start-postgres", "restart-mssql": "npm run start-mssql", "restart-db2": "npm run start-db2", + "restart-oracle-oldest": "npm run start-oracle-oldest", + "restart-oracle-latest": "npm run start-oracle-latest", "----------------------------------------- local tests ---------------------------------------------": "", "test-unit-mariadb": "cross-env DIALECT=mariadb npm run test-unit", "test-unit-mysql": "cross-env DIALECT=mysql npm run test-unit", @@ -254,7 +273,8 @@ "test-unit-mssql": "cross-env DIALECT=mssql npm run test-unit", "test-unit-db2": "cross-env DIALECT=db2 npm run test-unit", "test-unit-snowflake": "cross-env DIALECT=snowflake npm run test-unit", - "test-unit-all": "npm run test-unit-mariadb && npm run test-unit-mysql && npm run test-unit-postgres && npm run test-unit-postgres-native && npm run test-unit-mssql && npm run test-unit-sqlite && npm run test-unit-snowflake && npm run test-unit-db2", + "test-unit-oracle": "cross-env DIALECT=oracle npm run test-unit", + "test-unit-all": "npm run test-unit-mariadb && npm run test-unit-mysql && npm run test-unit-postgres && npm run test-unit-postgres-native && npm run test-unit-mssql && npm run test-unit-sqlite && npm run test-unit-snowflake && npm run test-unit-db2 && npm run test-unit-oracle", "test-integration-mariadb": "cross-env DIALECT=mariadb npm run test-integration", "test-integration-mysql": "cross-env DIALECT=mysql npm run test-integration", "test-integration-postgres": "cross-env DIALECT=postgres npm run test-integration", @@ -263,6 +283,7 @@ "test-integration-mssql": "cross-env DIALECT=mssql npm run test-integration", "test-integration-db2": "cross-env DIALECT=db2 npm run test-integration", "test-integration-snowflake": "cross-env DIALECT=snowflake npm run test-integration", + "test-integration-oracle": "cross-env LD_LIBRARY_PATH=\"$PWD/.oracle/instantclient/\" DIALECT=oracle UV_THREADPOOL_SIZE=128 npm run test-integration", "test-mariadb": "cross-env DIALECT=mariadb npm test", "test-mysql": "cross-env DIALECT=mysql npm test", "test-sqlite": "cross-env DIALECT=sqlite npm test", @@ -270,6 +291,7 @@ "test-postgres-native": "cross-env DIALECT=postgres-native npm test", "test-mssql": "cross-env DIALECT=mssql npm test", "test-db2": "cross-env DIALECT=db2 npm test", + "test-oracle": "cross-env LD_LIBRARY_PATH=\"$PWD/.oracle/instantclient/\" DIALECT=oracle UV_THREADPOOL_SIZE=128 npm test", "----------------------------------------- development ---------------------------------------------": "", "sscce": "node sscce.js", "sscce-mariadb": "cross-env DIALECT=mariadb node sscce.js", @@ -279,6 +301,7 @@ "sscce-sqlite": "cross-env DIALECT=sqlite node sscce.js", "sscce-mssql": "cross-env DIALECT=mssql node sscce.js", "sscce-db2": "cross-env DIALECT=db2 node sscce.js", + "sscce-oracle": "cross-env LD_LIBRARY_PATH=\"$PWD/.oracle/instantclient/\" DIALECT=oracle UV_THREADPOOL_SIZE=128 node sscce.js", "prepare": "npm run build && husky install", "build": "node ./build.js", "---------------------------------------------------------------------------------------------------": "" diff --git a/types/lib/associations/base.d.ts b/src/associations/base.d.ts similarity index 100% rename from types/lib/associations/base.d.ts rename to src/associations/base.d.ts diff --git a/lib/associations/base.js b/src/associations/base.js similarity index 100% rename from lib/associations/base.js rename to src/associations/base.js diff --git a/types/lib/associations/belongs-to-many.d.ts b/src/associations/belongs-to-many.d.ts similarity index 100% rename from types/lib/associations/belongs-to-many.d.ts rename to src/associations/belongs-to-many.d.ts diff --git a/lib/associations/belongs-to-many.js b/src/associations/belongs-to-many.js similarity index 100% rename from lib/associations/belongs-to-many.js rename to src/associations/belongs-to-many.js diff --git a/types/lib/associations/belongs-to.d.ts b/src/associations/belongs-to.d.ts similarity index 100% rename from types/lib/associations/belongs-to.d.ts rename to src/associations/belongs-to.d.ts diff --git a/lib/associations/belongs-to.js b/src/associations/belongs-to.js similarity index 100% rename from lib/associations/belongs-to.js rename to src/associations/belongs-to.js diff --git a/types/lib/associations/has-many.d.ts b/src/associations/has-many.d.ts similarity index 100% rename from types/lib/associations/has-many.d.ts rename to src/associations/has-many.d.ts diff --git a/lib/associations/has-many.js b/src/associations/has-many.js similarity index 100% rename from lib/associations/has-many.js rename to src/associations/has-many.js diff --git a/types/lib/associations/has-one.d.ts b/src/associations/has-one.d.ts similarity index 100% rename from types/lib/associations/has-one.d.ts rename to src/associations/has-one.d.ts diff --git a/lib/associations/has-one.js b/src/associations/has-one.js similarity index 100% rename from lib/associations/has-one.js rename to src/associations/has-one.js diff --git a/lib/associations/helpers.js b/src/associations/helpers.js similarity index 100% rename from lib/associations/helpers.js rename to src/associations/helpers.js diff --git a/types/lib/associations/index.d.ts b/src/associations/index.d.ts similarity index 100% rename from types/lib/associations/index.d.ts rename to src/associations/index.d.ts diff --git a/lib/associations/index.js b/src/associations/index.js similarity index 100% rename from lib/associations/index.js rename to src/associations/index.js diff --git a/lib/associations/mixin.js b/src/associations/mixin.js similarity index 100% rename from lib/associations/mixin.js rename to src/associations/mixin.js diff --git a/types/lib/data-types.d.ts b/src/data-types.d.ts similarity index 100% rename from types/lib/data-types.d.ts rename to src/data-types.d.ts diff --git a/lib/data-types.js b/src/data-types.js similarity index 99% rename from lib/data-types.js rename to src/data-types.js index 371652be60f9..f75ee2124ba7 100644 --- a/lib/data-types.js +++ b/src/data-types.js @@ -211,7 +211,7 @@ class NUMBER extends ABSTRACT { return true; } _stringify(number) { - if (typeof number === 'number' || typeof number === 'boolean' || number === null || number === undefined) { + if (typeof number === 'number' || typeof number === 'bigint' || typeof number === 'boolean' || number === null || number === undefined) { return number; } if (typeof number.toString === 'function') { @@ -1060,6 +1060,7 @@ dialectMap.sqlite = require('./dialects/sqlite/data-types')(DataTypes); dialectMap.mssql = require('./dialects/mssql/data-types')(DataTypes); dialectMap.db2 = require('./dialects/db2/data-types')(DataTypes); dialectMap.snowflake = require('./dialects/snowflake/data-types')(DataTypes); +dialectMap.oracle = require('./dialects/oracle/data-types')(DataTypes); const dialectList = Object.values(dialectMap); diff --git a/types/lib/deferrable.d.ts b/src/deferrable.d.ts similarity index 100% rename from types/lib/deferrable.d.ts rename to src/deferrable.d.ts diff --git a/lib/deferrable.js b/src/deferrable.js similarity index 100% rename from lib/deferrable.js rename to src/deferrable.js diff --git a/types/lib/connection-manager.d.ts b/src/dialects/abstract/connection-manager.d.ts similarity index 76% rename from types/lib/connection-manager.d.ts rename to src/dialects/abstract/connection-manager.d.ts index 8bb7674918b9..b3b0907a033d 100644 --- a/types/lib/connection-manager.d.ts +++ b/src/dialects/abstract/connection-manager.d.ts @@ -28,7 +28,12 @@ export interface ConnectionManager { */ getConnection(opts: GetConnectionOptions): Promise; /** - * Release a pooled connection so it can be utilized by other connection requests + * Release a pooled connection, so it can be utilized by other connection requests */ - releaseConnection(conn: Connection): Promise; + releaseConnection(conn: Connection): void; + + /** + * Destroys a pooled connection and removes it from the pool. + */ + destroyConnection(conn: Connection): Promise; } diff --git a/lib/dialects/abstract/connection-manager.js b/src/dialects/abstract/connection-manager.js similarity index 96% rename from lib/dialects/abstract/connection-manager.js rename to src/dialects/abstract/connection-manager.js index 8f6ee9f44f99..5d58ea134938 100644 --- a/lib/dialects/abstract/connection-manager.js +++ b/src/dialects/abstract/connection-manager.js @@ -283,7 +283,13 @@ class ConnectionManager { let result; try { + + await this.sequelize.runHooks('beforePoolAcquire', options); + result = await this.pool.acquire(options.type, options.useMaster); + + await this.sequelize.runHooks('afterPoolAcquire', result, options); + } catch (error) { if (error instanceof TimeoutError) throw new errors.ConnectionAcquireTimeoutError(error); throw error; @@ -298,14 +304,22 @@ class ConnectionManager { * Release a pooled connection so it can be utilized by other connection requests * * @param {Connection} connection - * - * @returns {Promise} */ - async releaseConnection(connection) { + releaseConnection(connection) { this.pool.release(connection); debug('connection released'); } + /** + * Destroys a pooled connection and removes it from the pool. + * + * @param {Connection} connection + */ + async destroyConnection(connection) { + await this.pool.destroy(connection); + debug(`connection ${connection.uuid} destroyed`); + } + /** * Call dialect library to get connection * diff --git a/src/dialects/abstract/index.d.ts b/src/dialects/abstract/index.d.ts new file mode 100644 index 000000000000..878efebb83d3 --- /dev/null +++ b/src/dialects/abstract/index.d.ts @@ -0,0 +1,109 @@ +import type { Dialect } from '../../sequelize.js'; +import type { AbstractQuery } from './query.js'; + +export declare type DialectSupports = { + 'DEFAULT': boolean; + 'DEFAULT VALUES': boolean; + 'VALUES ()': boolean; + 'LIMIT ON UPDATE': boolean; + 'ON DUPLICATE KEY': boolean; + 'ORDER NULLS': boolean; + 'UNION': boolean; + 'UNION ALL': boolean; + 'RIGHT JOIN': boolean; + EXCEPTION: boolean; + forShare?: 'LOCK IN SHARE MODE' | 'FOR SHARE' | undefined; + lock: boolean; + lockOf: boolean; + lockKey: boolean; + lockOuterJoinFailure: boolean; + skipLocked: boolean; + finalTable: boolean; + returnValues: false | { + output: boolean; + returning: boolean; + }; + autoIncrement: { + identityInsert: boolean; + defaultValue: boolean; + update: boolean; + }; + bulkDefault: boolean; + schemas: boolean; + transactions: boolean; + settingIsolationLevelDuringTransaction: boolean; + transactionOptions: { + type: boolean; + }; + migrations: boolean; + upserts: boolean; + inserts: { + ignoreDuplicates: string; + updateOnDuplicate: boolean | string; + onConflictDoNothing: string; + onConflictWhere: boolean, + conflictFields: boolean; + }; + constraints: { + restrict: boolean; + addConstraint: boolean; + dropConstraint: boolean; + unique: boolean; + default: boolean; + check: boolean; + foreignKey: boolean; + primaryKey: boolean; + onUpdate: boolean; + }; + index: { + collate: boolean; + length: boolean; + parser: boolean; + concurrently: boolean; + type: boolean; + using: boolean | number; + functionBased: boolean; + operator: boolean; + where: boolean; + }; + groupedLimit: boolean; + indexViaAlter: boolean; + JSON: boolean; + JSONB: boolean; + ARRAY: boolean; + RANGE: boolean; + NUMERIC: boolean; + GEOMETRY: boolean; + GEOGRAPHY: boolean; + REGEXP: boolean; + /** + * Case-insensitive regexp operator support ('~*' in postgres). + */ + IREGEXP: boolean; + HSTORE: boolean; + TSVECTOR: boolean; + deferrableConstraints: boolean; + tmpTableTrigger: boolean; + indexHints: boolean; + searchPath: boolean; + escapeStringConstants: boolean; +}; + +export declare abstract class AbstractDialect { + /** + * List of features this dialect supports. + * + * Important: Dialect implementations inherit these values. + * When changing a default, ensure the implementations still properly declare which feature they support. + */ + static readonly supports: DialectSupports; + readonly defaultVersion: string; + readonly Query: typeof AbstractQuery; + readonly name: Dialect; + readonly TICK_CHAR: string; + readonly TICK_CHAR_LEFT: string; + readonly TICK_CHAR_RIGHT: string; + readonly queryGenerator: unknown; + get supports(): DialectSupports; + canBackslashEscape(): boolean; +} diff --git a/lib/dialects/abstract/index.js b/src/dialects/abstract/index.js similarity index 80% rename from lib/dialects/abstract/index.js rename to src/dialects/abstract/index.js index 5d2c13808166..e2d715695de0 100644 --- a/lib/dialects/abstract/index.js +++ b/src/dialects/abstract/index.js @@ -1,6 +1,15 @@ 'use strict'; -class AbstractDialect {} +class AbstractDialect { + /** + * Whether this dialect can use \ in strings to escape string delimiters. + * + * @returns {boolean} + */ + canBackslashEscape() { + return false; + } +} AbstractDialect.prototype.supports = { 'DEFAULT': true, @@ -41,6 +50,7 @@ AbstractDialect.prototype.supports = { ignoreDuplicates: '', /* dialect specific words for INSERT IGNORE or DO NOTHING */ updateOnDuplicate: false, /* whether dialect supports ON DUPLICATE KEY UPDATE */ onConflictDoNothing: '', /* dialect specific words for ON CONFLICT DO NOTHING */ + onConflictWhere: false, /* whether dialect supports ON CONFLICT WHERE */ conflictFields: false /* whether the dialect supports specifying conflict fields or not */ }, constraints: { @@ -66,7 +76,12 @@ AbstractDialect.prototype.supports = { groupedLimit: true, indexViaAlter: false, JSON: false, - deferrableConstraints: false + /** + * This dialect supports marking a column's constraints as deferrable. + * e.g. 'DEFERRABLE' and 'INITIALLY DEFERRED' + */ + deferrableConstraints: false, + escapeStringConstants: false }; module.exports = AbstractDialect; diff --git a/lib/dialects/abstract/query-generator.js b/src/dialects/abstract/query-generator.js similarity index 91% rename from lib/dialects/abstract/query-generator.js rename to src/dialects/abstract/query-generator.js index 98773e213584..56f777090018 100644 --- a/lib/dialects/abstract/query-generator.js +++ b/src/dialects/abstract/query-generator.js @@ -17,6 +17,35 @@ const Op = require('../../operators'); const sequelizeError = require('../../errors'); const IndexHints = require('../../index-hints'); +/** + * Whitelist of SQL data types allowed in JSON key cast notation (e.g. "key::integer"). + * This prevents SQL injection via user-controlled cast types in _traverseJSON. + * Includes types produced by _getJsonCast() and types transformed by dialect overrides. + */ +const ALLOWED_CAST_TYPES = new Set([ + 'integer', + 'int', + 'smallint', + 'bigint', + 'float', + 'real', + 'double precision', + 'decimal', + 'numeric', + 'boolean', + 'text', + 'char', + 'varchar', + 'nvarchar', + 'date', + 'timestamp', + 'timestamptz', + 'datetime', + 'json', + 'jsonb', + 'signed', + 'unsigned' +]); /** * Abstract Query Generator @@ -43,7 +72,7 @@ class QueryGenerator { options = options || {}; tableName = tableName || {}; return { - schema: tableName.schema || options.schema || 'public', + schema: tableName.schema || options.schema || this.options.schema || 'public', tableName: _.isPlainObject(tableName) ? tableName.tableName : tableName, delimiter: tableName.delimiter || options.delimiter || '.' }; @@ -88,6 +117,16 @@ class QueryGenerator { return `ALTER TABLE ${this.quoteTable(before)} RENAME TO ${this.quoteTable(after)};`; } + /** + * Helper method for populating the returning into bind information + * that is needed by some dialects (currently Oracle) + * + * @private + */ + populateInsertQueryReturnIntoBinds() { + // noop by default + } + /** * Returns an insert into command * @@ -103,12 +142,14 @@ class QueryGenerator { _.defaults(options, this.options); const modelAttributeMap = {}; - const bind = []; + const bind = options.bind || []; const fields = []; const returningModelAttributes = []; + const returnTypes = []; const values = []; const quotedTable = this.quoteTable(table); const bindParam = options.bindParam === undefined ? this.bindParam(bind) : options.bindParam; + const returnAttributes = []; let query; let valueQuery = ''; let emptyQuery = ''; @@ -132,10 +173,14 @@ class QueryGenerator { emptyQuery += ' VALUES ()'; } - if (this._dialect.supports.returnValues && options.returning) { + if ((this._dialect.supports.returnValues || this._dialect.supports.returnIntoValues) && options.returning) { const returnValues = this.generateReturnValues(modelAttributes, options); returningModelAttributes.push(...returnValues.returnFields); + // Storing the returnTypes for dialects that need to have returning into bind information for outbinds + if (this._dialect.supports.returnIntoValues) { + returnTypes.push(...returnValues.returnTypes); + } returningFragment = returnValues.returningFragment; tmpTable = returnValues.tmpTable || ''; outputFragment = returnValues.outputFragment || ''; @@ -182,6 +227,13 @@ class QueryGenerator { let onDuplicateKeyUpdate = ''; + if ( + !_.isEmpty(options.conflictWhere) + && !this._dialect.supports.inserts.onConflictWhere + ) { + throw new Error('missing dialect support for conflictWhere option'); + } + // `options.updateOnDuplicate` is the list of field names to update if a duplicate key is hit during the insert. It // contains just the field names. This option is _usually_ explicitly set by the corresponding query-interface // upsert function. @@ -190,10 +242,28 @@ class QueryGenerator { // If no conflict target columns were specified, use the primary key names from options.upsertKeys const conflictKeys = options.upsertKeys.map(attr => this.quoteIdentifier(attr)); const updateKeys = options.updateOnDuplicate.map(attr => `${this.quoteIdentifier(attr)}=EXCLUDED.${this.quoteIdentifier(attr)}`); - onDuplicateKeyUpdate = ` ON CONFLICT (${conflictKeys.join(',')})`; + + const fragments = [ + 'ON CONFLICT', + '(', + conflictKeys.join(','), + ')' + ]; + + if (!_.isEmpty(options.conflictWhere)) { + fragments.push(this.whereQuery(options.conflictWhere, options)); + } + // if update keys are provided, then apply them here. if there are no updateKeys provided, then do not try to // do an update. Instead, fall back to DO NOTHING. - onDuplicateKeyUpdate += _.isEmpty(updateKeys) ? ' DO NOTHING ' : ` DO UPDATE SET ${updateKeys.join(',')}`; + if (_.isEmpty(updateKeys)) { + fragments.push('DO NOTHING'); + } else { + fragments.push('DO UPDATE SET', updateKeys.join(',')); + } + + onDuplicateKeyUpdate = ` ${Utils.joinSQLFragments(fragments)}`; + } else { const valueKeys = options.updateOnDuplicate.map(attr => `${this.quoteIdentifier(attr)}=VALUES(${this.quoteIdentifier(attr)})`); // the rough equivalent to ON CONFLICT DO NOTHING in mysql, etc is ON DUPLICATE KEY UPDATE id = id @@ -244,7 +314,12 @@ class QueryGenerator { emptyQuery += returningFragment; } - query = `${replacements.attributes.length ? valueQuery : emptyQuery};`; + if (this._dialect.supports.returnIntoValues && options.returning) { + // Populating the returnAttributes array and performing operations needed for output binds of insertQuery + this.populateInsertQueryReturnIntoBinds(returningModelAttributes, returnTypes, bind.length, returnAttributes, options); + } + + query = `${replacements.attributes.length ? valueQuery : emptyQuery}${returnAttributes.join(',')};`; if (this._dialect.supports.finalTable) { query = `SELECT * FROM FINAL TABLE(${ replacements.attributes.length ? valueQuery : emptyQuery });`; } @@ -318,8 +393,31 @@ class QueryGenerator { // If no conflict target columns were specified, use the primary key names from options.upsertKeys const conflictKeys = options.upsertKeys.map(attr => this.quoteIdentifier(attr)); const updateKeys = options.updateOnDuplicate.map(attr => `${this.quoteIdentifier(attr)}=EXCLUDED.${this.quoteIdentifier(attr)}`); - onDuplicateKeyUpdate = ` ON CONFLICT (${conflictKeys.join(',')}) DO UPDATE SET ${updateKeys.join(',')}`; + + let whereClause = false; + if (options.conflictWhere) { + if (!this._dialect.supports.inserts.onConflictWhere) { + throw new Error(`conflictWhere not supported for dialect ${this._dialect.name}`); + } + + whereClause = this.whereQuery(options.conflictWhere, options); + } + + // The Utils.joinSQLFragments later on will join this as it handles nested arrays. + onDuplicateKeyUpdate = [ + 'ON CONFLICT', + '(', + conflictKeys.join(','), + ')', + whereClause, + 'DO UPDATE SET', + updateKeys.join(',') + ]; } else { // mysql / maria + if (options.conflictWhere) { + throw new Error(`conflictWhere not supported for dialect ${this._dialect.name}`); + } + const valueKeys = options.updateOnDuplicate.map(attr => `${this.quoteIdentifier(attr)}=VALUES(${this.quoteIdentifier(attr)})`); onDuplicateKeyUpdate = `${this._dialect.supports.inserts.updateOnDuplicate} ${valueKeys.join(',')}`; } @@ -383,8 +481,18 @@ class QueryGenerator { const bindParam = options.bindParam === undefined ? this.bindParam(bind) : options.bindParam; if (this._dialect.supports['LIMIT ON UPDATE'] && options.limit) { - if (this.dialect !== 'mssql' && this.dialect !== 'db2') { + if (!['mssql', 'db2', 'oracle'].includes(this.dialect)) { suffix = ` LIMIT ${this.escape(options.limit)} `; + } else if (this.dialect === 'oracle') { + // This cannot be setted in where because rownum will be quoted + if (where && (where.length && where.length > 0 || Object.keys(where).length > 0)) { + // If we have a where clause, we add AND + suffix += ' AND '; + } else { + // No where clause, we add where + suffix += ' WHERE '; + } + suffix += `rownum <= ${this.escape(options.limit)} `; } } @@ -676,7 +784,7 @@ class QueryGenerator { break; case 'DEFAULT': if (options.defaultValue === undefined) { - throw new Error('Default value must be specifed for DEFAULT CONSTRAINT'); + throw new Error('Default value must be specified for DEFAULT CONSTRAINT'); } if (this._dialect.name !== 'mssql') { @@ -939,8 +1047,8 @@ class QueryGenerator { /** * Split a list of identifiers by "." and quote each part. * - * @param {string} identifiers - * + * @param {string} identifiers + * * @returns {string} */ quoteIdentifiers(identifiers) { @@ -963,6 +1071,15 @@ class QueryGenerator { return this.quoteIdentifiers(attribute); } + /** + * Returns the alias token + * + * @returns {string} + */ + getAliasToken() { + return 'AS'; + } + /** * Quote table name with optional alias and schema attribution * @@ -998,7 +1115,7 @@ class QueryGenerator { } if (alias) { - table += ` AS ${this.quoteIdentifier(alias)}`; + table += ` ${this.getAliasToken()} ${this.quoteIdentifier(alias)}`; } return table; @@ -1016,6 +1133,12 @@ class QueryGenerator { return this.handleSequelizeMethod(value); } if (field && field.type) { + if (field.type instanceof DataTypes.STRING + && ['mysql', 'mariadb'].includes(this.dialect) + && ['number', 'boolean'].includes(typeof value)) { + value = String(Number(value)); + } + this.validate(value, field, options); if (field.type.stringify) { @@ -1312,7 +1435,12 @@ class QueryGenerator { } else { // Ordering is handled by the subqueries, so ordering the UNION'ed result is not needed groupedLimitOrder = options.order; - delete options.order; + + // For the Oracle dialect, the result of a select is a set, not a sequence, and so is the result of UNION. + // So the top level ORDER BY is required + if (!this._dialect.supports.topLevelOrderByRequired) { + delete options.order; + } where[Op.placeholder] = true; } @@ -1332,7 +1460,7 @@ class QueryGenerator { model }, model - ).replace(/;$/, '')}) AS sub`; // Every derived table must have its own alias + ).replace(/;$/, '')}) ${this.getAliasToken()} sub`; // Every derived table must have its own alias const placeHolder = this.whereItemQuery(Op.placeholder, true, { model }); const splicePos = baseQuery.indexOf(placeHolder); @@ -1426,7 +1554,7 @@ class QueryGenerator { if (subQuery) { this._throwOnEmptyAttributes(attributes.main, { modelName: model && model.name, as: mainTable.as }); - query = `SELECT ${attributes.main.join(', ')} FROM (${subQueryItems.join('')}) AS ${mainTable.as}${mainJoinQueries.join('')}${mainQueryItems.join('')}`; + query = `SELECT ${attributes.main.join(', ')} FROM (${subQueryItems.join('')}) ${this.getAliasToken()} ${mainTable.as}${mainJoinQueries.join('')}${mainQueryItems.join('')}`; } else { query = mainQueryItems.join(''); } @@ -1476,11 +1604,24 @@ class QueryGenerator { if (attr[0] instanceof Utils.SequelizeMethod) { attr[0] = this.handleSequelizeMethod(attr[0]); addTable = false; - } else if (!attr[0].includes('(') && !attr[0].includes(')')) { + } else if (this.options.attributeBehavior === 'escape' || !attr[0].includes('(') && !attr[0].includes(')')) { attr[0] = this.quoteIdentifier(attr[0]); - } else { - deprecations.noRawAttributes(); + } else if (this.options.attributeBehavior !== 'unsafe-legacy') { + throw new Error(`Attributes cannot include parentheses in Sequelize 6: +In order to fix the vulnerability CVE-2023-22578, we had to remove support for treating attributes as raw SQL if they included parentheses. +Sequelize 7 escapes all attributes, even if they include parentheses. +For Sequelize 6, because we're introducing this change in a minor release, we've opted for throwing an error instead of silently escaping the attribute as a way to warn you about this change. + +Here is what you can do to fix this error: +- Wrap the attribute in a literal() call. This will make Sequelize treat it as raw SQL. +- Set the "attributeBehavior" sequelize option to "escape" to make Sequelize escape the attribute, like in Sequelize v7. We highly recommend this option. +- Set the "attributeBehavior" sequelize option to "unsafe-legacy" to make Sequelize escape the attribute, like in Sequelize v5. + +We sincerely apologize for the inconvenience this may cause you. You can find more information on the following threads: +https://github.com/sequelize/sequelize/security/advisories/GHSA-f598-mfpv-gmfx +https://github.com/sequelize/sequelize/discussions/15694`); } + let alias = attr[1]; if (this.options.minifyAliases) { @@ -1566,6 +1707,8 @@ class QueryGenerator { prefix = `(${this.quoteIdentifier(includeAs.internalAs)}.${attr.replace(/\(|\)/g, '')})`; } else if (/json_extract\(/.test(attr)) { prefix = attr.replace(/json_extract\(/i, `json_extract(${this.quoteIdentifier(includeAs.internalAs)}.`); + } else if (/json_value\(/.test(attr)) { + prefix = attr.replace(/json_value\(/i, `json_value(${this.quoteIdentifier(includeAs.internalAs)}.`); } else { prefix = `${this.quoteIdentifier(includeAs.internalAs)}.${this.quoteIdentifier(attr)}`; } @@ -1773,11 +1916,7 @@ class QueryGenerator { } } - if (this.options.minifyAliases && asRight.length > 63) { - const alias = `%${topLevelInfo.options.includeAliases.size}`; - - topLevelInfo.options.includeAliases.set(alias, asRight); - } + this.aliasAs(asRight, topLevelInfo); return { join: include.required ? 'INNER JOIN' : include.right && this._dialect.supports['RIGHT JOIN'] ? 'RIGHT OUTER JOIN' : 'LEFT OUTER JOIN', @@ -1822,6 +1961,8 @@ class QueryGenerator { if (this._dialect.supports.returnValues.returning) { returningFragment = ` RETURNING ${returnFields.join(',')}`; + } else if (this._dialect.supports.returnIntoValues) { + returningFragment = ` RETURNING ${returnFields.join(',')} INTO `; } else if (this._dialect.supports.returnValues.output) { outputFragment = ` OUTPUT ${returnFields.map(field => `INSERTED.${field}`).join(',')}`; @@ -1835,7 +1976,7 @@ class QueryGenerator { } } - return { outputFragment, returnFields, returningFragment, tmpTable }; + return { outputFragment, returnFields, returnTypes, returningFragment, tmpTable }; } generateThroughJoin(include, includeAs, parentTableName, topLevelInfo) { @@ -1917,6 +2058,8 @@ class QueryGenerator { throughWhere = this.getWhereConditions(through.where, this.sequelize.literal(this.quoteIdentifier(throughAs)), through.model); } + this.aliasAs(includeAs.internalAs, topLevelInfo); + // Generate a wrapped join so that the through table join can be dependent on the target join joinBody = `( ${this.quoteTable(throughTable, throughAs)} INNER JOIN ${this.quoteTable(include.model.getTableName(), includeAs.internalAs)} ON ${targetJoinOn}`; if (throughWhere) { @@ -1944,6 +2087,18 @@ class QueryGenerator { }; } + /* + * Appends to the alias cache if the alias 64+ characters long and minifyAliases is true. + * This helps to avoid character limits in PostgreSQL. + */ + aliasAs(as, topLevelInfo) { + if (this.options.minifyAliases && as.length >= 64) { + const alias = `%${topLevelInfo.options.includeAliases.size}`; + + topLevelInfo.options.includeAliases.set(alias, as); + } + } + /* * Generates subQueryFilter - a select nested in the where clause of the subQuery. * For a given include a query is generated that contains all the way from the subQuery @@ -2083,17 +2238,39 @@ class QueryGenerator { && !(typeof order[0].model === 'function' && order[0].model.prototype instanceof Model) && !(typeof order[0] === 'string' && model && model.associations !== undefined && model.associations[order[0]]) ) { - subQueryOrder.push(this.quote(order, model, '->')); + const field = model.rawAttributes[order[0]] ? model.rawAttributes[order[0]].field : order[0]; + const subQueryAlias = this._getAliasForField(this.quoteIdentifier(model.name), field, options); + + let parent = null; + let orderToQuote = []; + + // we need to ensure that the parent is null if we use the subquery alias, else we'll get an exception since + // "model_name"."alias" doesn't exist - only "alias" does. we also need to ensure that we preserve order direction + // by pushing order[1] to the subQueryOrder as well - in case it doesn't exist, we want to push "ASC" + if (subQueryAlias === null) { + orderToQuote = order; + parent = model; + } else { + orderToQuote = [subQueryAlias, order.length > 1 ? order[1] : 'ASC']; + parent = null; + } + + subQueryOrder.push(this.quote(orderToQuote, parent, '->')); } - if (subQuery) { - // Handle case where sub-query renames attribute we want to order by, - // see https://github.com/sequelize/sequelize/issues/8739 - const subQueryAttribute = options.attributes.find(a => Array.isArray(a) && a[0] === order[0] && a[1]); - if (subQueryAttribute) { + // Handle case where renamed attributes are used to order by, + // see https://github.com/sequelize/sequelize/issues/8739 + // need to check if either of the attribute options match the order + if (options.attributes && model) { + const aliasedAttribute = options.attributes.find(attr => Array.isArray(attr) + && attr[1] + && (attr[0] === order[0] || attr[1] === order[0])); + + if (aliasedAttribute) { const modelName = this.quoteIdentifier(model.name); + const alias = this._getAliasForField(modelName, aliasedAttribute[1], options); - order[0] = new Utils.Col(this._getAliasForField(modelName, subQueryAttribute[1], options) || subQueryAttribute[1]); + order[0] = new Utils.Col(alias || aliasedAttribute[1]); } } @@ -2126,7 +2303,7 @@ class QueryGenerator { let fragment = `SELECT ${attributes.join(', ')} FROM ${tables}`; if (mainTableAs) { - fragment += ` AS ${mainTableAs}`; + fragment += ` ${this.getAliasToken()} ${mainTableAs}`; } if (options.indexHints && this._dialect.supports.indexHints) { @@ -2243,7 +2420,7 @@ class QueryGenerator { if (_.isPlainObject(arg)) { return this.whereItemsQuery(arg); } - return this.escape(typeof arg === 'string' ? arg.replace('$', '$$$') : arg); + return this.escape(typeof arg === 'string' ? arg.replace(/\$/g, '$$$') : arg); }).join(', ') })`; } @@ -2491,6 +2668,8 @@ class QueryGenerator { const tmp = path[path.length - 1].split('::'); cast = tmp[1]; path[path.length - 1] = tmp[0]; + + this._validateCastType(cast); } let pathKey = this.jsonPathExtractionQuery(baseKey, path); @@ -2547,6 +2726,12 @@ class QueryGenerator { return; } + _validateCastType(cast) { + if (!ALLOWED_CAST_TYPES.has(cast.toLowerCase())) { + throw new Error(`Invalid cast type: ${cast}`); + } + } + _joinKeyValue(key, value, comparator, prefix) { if (!key) { return value; @@ -2721,7 +2906,7 @@ class QueryGenerator { type: options.type }); } - if (typeof smth === 'number') { + if (typeof smth === 'number' || typeof smth === 'bigint') { let primaryKeys = factory ? Object.keys(factory.primaryKeys) : []; if (primaryKeys.length > 0) { @@ -2755,14 +2940,14 @@ class QueryGenerator { } throw new Error('Support for literal replacements in the `where` object has been removed.'); } - if (smth === null) { + if (smth == null) { return this.whereItemsQuery(smth, { model: factory, prefix: prepend && tableName }); } - return '1=1'; + throw new Error(`Unsupported where option value: ${util.inspect(smth)}. Please refer to the Sequelize documentation to learn more about which values are accepted as part of the where option.`); } // A recursive parser for nested where conditions @@ -2780,6 +2965,13 @@ class QueryGenerator { booleanValue(value) { return value; } + + /** + * Returns the authenticate test query string + */ + authTestQuery() { + return 'SELECT 1+1 AS result'; + } } Object.assign(QueryGenerator.prototype, require('./query-generator/operators')); diff --git a/lib/dialects/abstract/query-generator/operators.js b/src/dialects/abstract/query-generator/operators.js similarity index 100% rename from lib/dialects/abstract/query-generator/operators.js rename to src/dialects/abstract/query-generator/operators.js diff --git a/lib/dialects/abstract/query-generator/transaction.js b/src/dialects/abstract/query-generator/transaction.js similarity index 100% rename from lib/dialects/abstract/query-generator/transaction.js rename to src/dialects/abstract/query-generator/transaction.js diff --git a/types/lib/query-interface.d.ts b/src/dialects/abstract/query-interface.d.ts similarity index 95% rename from types/lib/query-interface.d.ts rename to src/dialects/abstract/query-interface.d.ts index e35ec5b8cf82..dafa19cac579 100644 --- a/types/lib/query-interface.d.ts +++ b/src/dialects/abstract/query-interface.d.ts @@ -1,4 +1,4 @@ -import { DataType } from './data-types'; +import { DataType } from '../../data-types'; import { Logging, Model, @@ -12,14 +12,14 @@ import { ModelStatic, ModelType, CreationAttributes, - Attributes, -} from './model'; -import QueryTypes = require('./query-types'); -import { Sequelize, RetryOptions } from './sequelize'; -import { Transaction } from './transaction'; -import { SetRequired } from './../type-helpers/set-required'; -import { Fn, Literal } from './utils'; -import { Deferrable } from './deferrable'; + Attributes +} from '../../model'; +import QueryTypes = require('../../query-types'); +import { Sequelize, RetryOptions } from '../../sequelize'; +import { Transaction } from '../../transaction'; +import { SetRequired } from '../../utils/set-required'; +import { Fn, Literal } from '../../utils'; +import { Deferrable } from '../../deferrable'; type BindOrReplacements = { [key: string]: unknown } | unknown[]; type FieldMap = { [key: string]: string }; @@ -377,6 +377,14 @@ export class QueryInterface { */ public showAllTables(options?: QueryOptions): Promise; + /** + * Returns a promise that resolves to true if the table exists in the database, false otherwise. + * + * @param tableName The name of the table + * @param options Options passed to {@link Sequelize#query} + */ + public tableExists(tableName: TableName, options?: QueryOptions): Promise; + /** * Describe a table */ @@ -486,13 +494,12 @@ export class QueryInterface { /** * Inserts or Updates a record in the database */ - public upsert( + public upsert( tableName: TableName, insertValues: object, updateValues: object, where: object, - model: ModelType, - options?: QueryOptions + options?: QueryOptionsWithModel ): Promise; /** @@ -649,11 +656,6 @@ export class QueryInterface { */ public quoteIdentifiers(identifiers: string): string; - /** - * Escape a value (e.g. a string, number or date) - */ - public escape(value?: string | number | Date): string; - /** * Set option for autocommit of a transaction */ diff --git a/lib/dialects/abstract/query-interface.js b/src/dialects/abstract/query-interface.js similarity index 98% rename from lib/dialects/abstract/query-interface.js rename to src/dialects/abstract/query-interface.js index 890d79826d17..ac5926bc8b22 100644 --- a/lib/dialects/abstract/query-interface.js +++ b/src/dialects/abstract/query-interface.js @@ -219,12 +219,34 @@ class QueryInterface { }); } - attributes = this.queryGenerator.attributesToSQL(attributes, { table: tableName, context: 'createTable' }); + attributes = this.queryGenerator.attributesToSQL(attributes, { + table: tableName, + context: 'createTable', + withoutForeignKeyConstraints: options.withoutForeignKeyConstraints + }); sql = this.queryGenerator.createTableQuery(tableName, attributes, options); return await this.sequelize.query(sql, options); } + /** + * Returns a promise that will resolve to true if the table exists in the database, false otherwise. + * + * @param {TableName} tableName - The name of the table + * @param {QueryOptions} options - Query options + * @returns {Promise} + */ + async tableExists(tableName, options) { + const sql = this.queryGenerator.tableExistsQuery(tableName); + + const out = await this.sequelize.query(sql, { + ...options, + type: QueryTypes.SHOWTABLES + }); + + return out.length === 1; + } + /** * Drop a table from database * @@ -901,7 +923,7 @@ class QueryInterface { const sql = this.queryGenerator.updateQuery(tableName, values, identifier, options, attributes); const table = _.isObject(tableName) ? tableName : { tableName }; - const model = _.find(this.sequelize.modelManager.models, { tableName: table.tableName }); + const model = options.model ? options.model : _.find(this.sequelize.modelManager.models, { tableName: table.tableName }); options.type = QueryTypes.BULKUPDATE; options.model = model; diff --git a/types/lib/query.d.ts b/src/dialects/abstract/query.d.ts similarity index 96% rename from types/lib/query.d.ts rename to src/dialects/abstract/query.d.ts index b051d71bd54f..67fb645186a2 100644 --- a/types/lib/query.d.ts +++ b/src/dialects/abstract/query.d.ts @@ -1,10 +1,7 @@ -import { IncludeOptions } from '..'; import { Connection } from './connection-manager'; -import { - Model, ModelType -} from './model'; -import { Sequelize } from './sequelize'; -import QueryTypes = require('./query-types'); +import { Model, ModelType, IncludeOptions } from '../../model'; +import { Sequelize } from '../../sequelize'; +import QueryTypes = require('../../query-types'); type BindOrReplacements = { [key: string]: unknown } | unknown[]; type FieldMap = { [key: string]: string }; @@ -161,24 +158,28 @@ export class AbstractQuery { /** * Checks if the query type is RAW + * * @returns {boolean} */ public isRawQuery(): boolean; /** * Checks if the query type is VERSION + * * @returns {boolean} */ public isVersionQuery(): boolean; /** * Checks if the query type is UPSERT + * * @returns {boolean} */ public isUpsertQuery(): boolean; /** * Checks if the query type is INSERT + * * @returns {boolean} */ public isInsertQuery(results?: unknown[], metaData?: unknown): boolean; @@ -194,6 +195,7 @@ export class AbstractQuery { /** * Checks if the query type is SHOWTABLES + * * @returns {boolean} */ public isShowTablesQuery(): boolean; @@ -208,48 +210,56 @@ export class AbstractQuery { /** * Checks if the query type is SHOWINDEXES + * * @returns {boolean} */ public isShowIndexesQuery(): boolean; /** * Checks if the query type is SHOWCONSTRAINTS + * * @returns {boolean} */ public isShowConstraintsQuery(): boolean; /** * Checks if the query type is DESCRIBE + * * @returns {boolean} */ public isDescribeQuery(): boolean; /** * Checks if the query type is SELECT + * * @returns {boolean} */ public isSelectQuery(): boolean; /** * Checks if the query type is BULKUPDATE + * * @returns {boolean} */ public isBulkUpdateQuery(): boolean; /** * Checks if the query type is BULKDELETE + * * @returns {boolean} */ public isBulkDeleteQuery(): boolean; /** * Checks if the query type is FOREIGNKEYS + * * @returns {boolean} */ public isForeignKeysQuery(): boolean; /** * Checks if the query type is UPDATE + * * @returns {boolean} */ public isUpdateQuery(): boolean; @@ -264,12 +274,14 @@ export class AbstractQuery { /** * Checks if the query starts with 'show' or 'describe' + * * @returns {boolean} */ public isShowOrDescribeQuery(): boolean; /** * Checks if the query starts with 'call' + * * @returns {boolean} */ public isCallQuery(): boolean; diff --git a/lib/dialects/abstract/query.js b/src/dialects/abstract/query.js similarity index 96% rename from lib/dialects/abstract/query.js rename to src/dialects/abstract/query.js index 2404a48fe0f8..8f8b2d598850 100644 --- a/lib/dialects/abstract/query.js +++ b/src/dialects/abstract/query.js @@ -24,6 +24,14 @@ class AbstractQuery { ...options }; this.checkLoggingOption(); + + if (options.rawErrors) { + // The default implementation in AbstractQuery just returns the same + // error object. By overidding this.formatError, this saves every dialect + // having to check for options.rawErrors in their own formatError + // implementations. + this.formatError = AbstractQuery.prototype.formatError; + } } /** @@ -107,6 +115,21 @@ class AbstractQuery { return [sql, []]; } + /** + * Formats a raw database error from the database library into a common Sequelize exception. + * + * @param {Error} error The exception object. + * @param {object} errStack The stack trace that started the database query. + * @returns {BaseError} the new formatted error object. + */ + formatError(error, errStack) { + // Default implementation, no formatting. + // Each dialect overrides this method to parse errors from their respective the database engines. + error.stack = errStack; + + return error; + } + /** * Execute the passed sql query. * @@ -527,7 +550,7 @@ class AbstractQuery { // Keys are the same for all rows, so only need to compute them on the first row if (rowsI === 0) { - keys = Object.keys(row); + keys = _.sortBy(Object.keys(row), item => [item.split('.').length]); keyLength = keys.length; } diff --git a/lib/dialects/db2/connection-manager.js b/src/dialects/db2/connection-manager.js similarity index 100% rename from lib/dialects/db2/connection-manager.js rename to src/dialects/db2/connection-manager.js diff --git a/lib/dialects/db2/data-types.js b/src/dialects/db2/data-types.js similarity index 100% rename from lib/dialects/db2/data-types.js rename to src/dialects/db2/data-types.js diff --git a/lib/dialects/db2/index.js b/src/dialects/db2/index.js similarity index 100% rename from lib/dialects/db2/index.js rename to src/dialects/db2/index.js diff --git a/lib/dialects/db2/query-generator.js b/src/dialects/db2/query-generator.js similarity index 97% rename from lib/dialects/db2/query-generator.js rename to src/dialects/db2/query-generator.js index a43f48acb599..4ac3735d33ce 100644 --- a/lib/dialects/db2/query-generator.js +++ b/src/dialects/db2/query-generator.js @@ -175,6 +175,16 @@ class Db2QueryGenerator extends AbstractQueryGenerator { return "SELECT TABNAME AS \"tableName\", TRIM(TABSCHEMA) AS \"tableSchema\" FROM SYSCAT.TABLES WHERE TABSCHEMA = USER AND TYPE = 'T' ORDER BY TABSCHEMA, TABNAME"; } + tableExistsQuery(table) { + const tableName = table.tableName || table; + // The default schema is the authorization ID of the owner of the plan or package. + // https://www.ibm.com/docs/en/db2-for-zos/12?topic=concepts-db2-schemas-schema-qualifiers + const schemaName = table.schema || this.sequelize.config.username.toUpperCase(); + + // https://www.ibm.com/docs/en/db2-for-zos/11?topic=tables-systables + return `SELECT name FROM sysibm.systables WHERE NAME = ${wrapSingleQuote(tableName)} AND CREATOR = ${wrapSingleQuote(schemaName)}`; + } + dropTableQuery(tableName) { const query = 'DROP TABLE <%= table %>'; const values = { @@ -621,7 +631,7 @@ class Db2QueryGenerator extends AbstractQueryGenerator { template += ' PRIMARY KEY'; } - if (attribute.references) { + if ((!options || !options.withoutForeignKeyConstraints) && attribute.references) { if (options && options.context === 'addColumn' && options.foreignKey) { const attrName = this.quoteIdentifier(options.foreignKey); const fkName = `${options.tableName }_${ attrName }_fidx`; diff --git a/lib/dialects/db2/query-interface.js b/src/dialects/db2/query-interface.js similarity index 97% rename from lib/dialects/db2/query-interface.js rename to src/dialects/db2/query-interface.js index f310ccc9bed0..535bc4bec27c 100644 --- a/lib/dialects/db2/query-interface.js +++ b/src/dialects/db2/query-interface.js @@ -133,7 +133,7 @@ class Db2QueryInterface extends QueryInterface { }); } - attributes = this.queryGenerator.attributesToSQL(attributes, { table: tableName, context: 'createTable' }); + attributes = this.queryGenerator.attributesToSQL(attributes, { table: tableName, context: 'createTable', withoutForeignKeyConstraints: options.withoutForeignKeyConstraints }); sql = this.queryGenerator.createTableQuery(tableName, attributes, options); return await this.sequelize.query(sql, options); diff --git a/lib/dialects/db2/query.js b/src/dialects/db2/query.js similarity index 92% rename from lib/dialects/db2/query.js rename to src/dialects/db2/query.js index 1e9383aab1d2..831419238aaf 100644 --- a/lib/dialects/db2/query.js +++ b/src/dialects/db2/query.js @@ -1,5 +1,7 @@ 'use strict'; +const util = require('util'); + const AbstractQuery = require('../abstract/query'); const sequelizeErrors = require('../../errors'); const parserStore = require('../parserStore')('db2'); @@ -14,15 +16,19 @@ class Query extends AbstractQuery { } getSQLTypeFromJsType(value) { - const param = { ParamType: 'INPUT', Data: value }; if (Buffer.isBuffer(value)) { - param.DataType = 'BLOB'; - return param; + return { ParamType: 'INPUT', DataType: 'BLOB', Data: value }; + } + + if (typeof value === 'bigint') { + // The ibm_db module does not handle bigint, send as a string instead: + return value.toString(); } + return value; } - async _run(connection, sql, parameters) { + async _run(connection, sql, parameters) { this.sql = sql; const benchmark = this.sequelize.options.benchmark || this.options.benchmark; let queryBegin; @@ -31,12 +37,15 @@ class Query extends AbstractQuery { } else { this.sequelize.log(`Executing (${ this.connection.uuid || 'default' }): ${ this.sql}`, this.options); } + + const errStack = new Error().stack; + return new Promise((resolve, reject) => { // TRANSACTION SUPPORT if (_.startsWith(this.sql, 'BEGIN TRANSACTION')) { connection.beginTransaction(err => { if (err) { - reject(this.formatError(err)); + reject(this.formatError(err, errStack)); } else { resolve(this.formatResults()); } @@ -44,7 +53,7 @@ class Query extends AbstractQuery { } else if (_.startsWith(this.sql, 'COMMIT TRANSACTION')) { connection.commitTransaction(err => { if (err) { - reject(this.formatError(err)); + reject(this.formatError(err, errStack)); } else { resolve(this.formatResults()); } @@ -52,7 +61,7 @@ class Query extends AbstractQuery { } else if (_.startsWith(this.sql, 'ROLLBACK TRANSACTION')) { connection.rollbackTransaction(err => { if (err) { - reject(this.formatError(err)); + reject(this.formatError(err, errStack)); } else { resolve(this.formatResults()); } @@ -60,11 +69,11 @@ class Query extends AbstractQuery { } else if (_.startsWith(this.sql, 'SAVE TRANSACTION')) { connection.commitTransaction(err => { if (err) { - reject(this.formatError(err)); + reject(this.formatError(err, errStack)); } else { connection.beginTransaction(err => { if (err) { - reject(this.formatError(err)); + reject(this.formatError(err, errStack)); } else { resolve(this.formatResults()); } @@ -90,12 +99,15 @@ class Query extends AbstractQuery { } connection.prepare(newSql, (err, stmt) => { - if (err) { reject(this.formatError(err)); } + if (err) { + reject(this.formatError(err, errStack)); + } + stmt.execute(params, (err, result, outparams) => { - debug(`executed(${this.connection.uuid || 'default'}):${newSql} ${parameters ? JSON.stringify(parameters) : ''}`); + debug(`executed(${this.connection.uuid || 'default'}):${newSql} ${parameters ? util.inspect(parameters, { compact: true, breakLength: Infinity }) : ''}`); if (benchmark) { - this.sequelize.log(`Executed (${ this.connection.uuid || 'default' }): ${ newSql} ${parameters ? JSON.stringify(parameters) : ''}`, Date.now() - queryBegin, this.options); + this.sequelize.log(`Executed (${this.connection.uuid || 'default'}): ${newSql} ${parameters ? util.inspect(parameters, { compact: true, breakLength: Infinity }) : ''}`, Date.now() - queryBegin, this.options); } if (err && err.message) { @@ -108,7 +120,7 @@ class Query extends AbstractQuery { if (err) { err.sql = sql; stmt.closeSync(); - reject(this.formatError(err, connection, parameters)); + reject(this.formatError(err, errStack, connection, parameters)); } else { let data = []; let metadata = []; @@ -333,7 +345,7 @@ class Query extends AbstractQuery { }); } - formatError(err, conn, parameters) { + formatError(err, errStack, conn, parameters) { let match; if (!(err && err.message)) { @@ -389,7 +401,7 @@ class Query extends AbstractQuery { )); }); - return new sequelizeErrors.UniqueConstraintError({ message, errors, parent: err, fields }); + return new sequelizeErrors.UniqueConstraintError({ message, errors, parent: err, fields, stack: errStack }); } match = err.message.match(/SQL0532N {2}A parent row cannot be deleted because the relationship "(.*)" restricts the deletion/) || @@ -399,7 +411,8 @@ class Query extends AbstractQuery { return new sequelizeErrors.ForeignKeyConstraintError({ fields: null, index: match[1], - parent: err + parent: err, + stack: errStack }); } @@ -413,11 +426,12 @@ class Query extends AbstractQuery { message: match[0], constraint, table, - parent: err + parent: err, + stack: errStack }); } - return new sequelizeErrors.DatabaseError(err); + return new sequelizeErrors.DatabaseError(err, { stack: errStack }); } @@ -446,7 +460,7 @@ class Query extends AbstractQuery { result = result || this.sql.startsWith('SELECT NAME AS "name", TBNAME AS "tableName", UNIQUERULE AS "keyType", COLNAMES, INDEXTYPE AS "type" FROM SYSIBM.SYSINDEXES'); return result; } - + handleShowIndexesQuery(data) { let currItem; const result = []; @@ -460,7 +474,7 @@ class Query extends AbstractQuery { unique: item.keyType === 'U', type: item.type }; - + _.forEach(item.COLNAMES.replace(/\+|-/g, x => { return ` ${ x}`; }).split(' '), column => { let columnName = column.trim(); if ( columnName ) { @@ -476,7 +490,7 @@ class Query extends AbstractQuery { result.push(currItem); } }); - return result; + return result; } handleInsertQuery(results, metaData) { diff --git a/lib/dialects/mariadb/connection-manager.js b/src/dialects/mariadb/connection-manager.js similarity index 100% rename from lib/dialects/mariadb/connection-manager.js rename to src/dialects/mariadb/connection-manager.js diff --git a/lib/dialects/mariadb/data-types.js b/src/dialects/mariadb/data-types.js similarity index 100% rename from lib/dialects/mariadb/data-types.js rename to src/dialects/mariadb/data-types.js diff --git a/lib/dialects/mariadb/index.js b/src/dialects/mariadb/index.js similarity index 97% rename from lib/dialects/mariadb/index.js rename to src/dialects/mariadb/index.js index e1ff8dfb3224..855c1106cbd4 100644 --- a/lib/dialects/mariadb/index.js +++ b/src/dialects/mariadb/index.js @@ -22,6 +22,10 @@ class MariadbDialect extends AbstractDialect { this.queryGenerator ); } + + canBackslashEscape() { + return true; + } } MariadbDialect.prototype.supports = _.merge( diff --git a/lib/dialects/mariadb/query-generator.js b/src/dialects/mariadb/query-generator.js similarity index 100% rename from lib/dialects/mariadb/query-generator.js rename to src/dialects/mariadb/query-generator.js diff --git a/lib/dialects/mariadb/query.js b/src/dialects/mariadb/query.js similarity index 96% rename from lib/dialects/mariadb/query.js rename to src/dialects/mariadb/query.js index 12d8f9c9d5b3..2f05d444f563 100644 --- a/lib/dialects/mariadb/query.js +++ b/src/dialects/mariadb/query.js @@ -129,6 +129,7 @@ class Query extends AbstractQuery { if (this.isSelectQuery()) { this.handleJsonSelectQuery(data); + return this.handleSelectQuery(data); } if (this.isInsertQuery() || this.isUpdateQuery()) { @@ -184,7 +185,9 @@ class Query extends AbstractQuery { if (modelField.type instanceof DataTypes.JSON) { // Value is returned as String, not JSON rows = rows.map(row => { - if (row[modelField.fieldName] && typeof row[modelField.fieldName] === 'string') { + // JSON fields for MariaDB server 10.5.2+ already results in JSON format, skip JSON.parse + // this is due to this https://jira.mariadb.org/browse/MDEV-17832 and how mysql2 connector interacts with MariaDB and JSON fields + if (row[modelField.fieldName] && typeof row[modelField.fieldName] === 'string' && !this.connection.info.hasMinVersion(10, 5, 2)) { row[modelField.fieldName] = JSON.parse(row[modelField.fieldName]); } if (DataTypes.JSON.parse) { diff --git a/lib/dialects/mssql/async-queue.ts b/src/dialects/mssql/async-queue.ts similarity index 100% rename from lib/dialects/mssql/async-queue.ts rename to src/dialects/mssql/async-queue.ts diff --git a/lib/dialects/mssql/connection-manager.js b/src/dialects/mssql/connection-manager.js similarity index 97% rename from lib/dialects/mssql/connection-manager.js rename to src/dialects/mssql/connection-manager.js index 9d929370c12e..76c2f9f1b63b 100644 --- a/lib/dialects/mssql/connection-manager.js +++ b/src/dialects/mssql/connection-manager.js @@ -129,6 +129,9 @@ class ConnectionManager extends AbstractConnectionManager { if (error.message.includes('connect EADDRNOTAVAIL')) { throw new sequelizeErrors.HostNotReachableError(error); } + if (error.message.includes('connect EAFNOSUPPORT')) { + throw new sequelizeErrors.HostNotReachableError(error); + } if (error.message.includes('getaddrinfo ENOTFOUND')) { throw new sequelizeErrors.HostNotFoundError(error); } diff --git a/lib/dialects/mssql/data-types.js b/src/dialects/mssql/data-types.js similarity index 100% rename from lib/dialects/mssql/data-types.js rename to src/dialects/mssql/data-types.js diff --git a/lib/dialects/mssql/index.js b/src/dialects/mssql/index.js similarity index 100% rename from lib/dialects/mssql/index.js rename to src/dialects/mssql/index.js diff --git a/lib/dialects/mssql/query-generator.js b/src/dialects/mssql/query-generator.js similarity index 94% rename from lib/dialects/mssql/query-generator.js rename to src/dialects/mssql/query-generator.js index 0920e015a3f3..edc0a86d557f 100644 --- a/lib/dialects/mssql/query-generator.js +++ b/src/dialects/mssql/query-generator.js @@ -192,7 +192,7 @@ class MSSQLQueryGenerator extends AbstractQueryGenerator { "c.IS_NULLABLE as 'IsNull',", "COLUMN_DEFAULT AS 'Default',", "pk.CONSTRAINT_TYPE AS 'Constraint',", - "COLUMNPROPERTY(OBJECT_ID(c.TABLE_SCHEMA+'.'+c.TABLE_NAME), c.COLUMN_NAME, 'IsIdentity') as 'IsIdentity',", + "COLUMNPROPERTY(OBJECT_ID('[' + c.TABLE_SCHEMA + '].[' + c.TABLE_NAME + ']'), c.COLUMN_NAME, 'IsIdentity') as 'IsIdentity',", "CAST(prop.value AS NVARCHAR) AS 'Comment'", 'FROM', 'INFORMATION_SCHEMA.TABLES t', @@ -209,7 +209,7 @@ class MSSQLQueryGenerator extends AbstractQueryGenerator { 'AND pk.table_name=c.table_name ', 'AND pk.column_name=c.column_name ', 'INNER JOIN sys.columns AS sc', - "ON sc.object_id = object_id(t.table_schema + '.' + t.table_name) AND sc.name = c.column_name", + "ON sc.object_id = OBJECT_ID('[' + t.TABLE_SCHEMA + '].[' + t.TABLE_NAME + ']') AND sc.name = c.column_name", 'LEFT JOIN sys.extended_properties prop ON prop.major_id = sc.object_id', 'AND prop.minor_id = sc.column_id', "AND prop.name = 'MS_Description'", @@ -231,6 +231,13 @@ class MSSQLQueryGenerator extends AbstractQueryGenerator { return "SELECT TABLE_NAME, TABLE_SCHEMA FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE';"; } + tableExistsQuery(table) { + const tableName = table.tableName || table; + const schemaName = table.schema || 'dbo'; + + return `SELECT TABLE_NAME, TABLE_SCHEMA FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_NAME = ${this.escape(tableName)} AND TABLE_SCHEMA = ${this.escape(schemaName)}`; + } + dropTableQuery(tableName) { const quoteTbl = this.quoteTable(tableName); return Utils.joinSQLFragments([ @@ -557,7 +564,7 @@ class MSSQLQueryGenerator extends AbstractQueryGenerator { return `DROP INDEX ${this.quoteIdentifiers(indexName)} ON ${this.quoteIdentifiers(tableName)}`; } - attributeToSQL(attribute) { + attributeToSQL(attribute, options) { if (!_.isPlainObject(attribute)) { attribute = { type: attribute @@ -613,7 +620,7 @@ class MSSQLQueryGenerator extends AbstractQueryGenerator { template += ' PRIMARY KEY'; } - if (attribute.references) { + if ((!options || !options.withoutForeignKeyConstraints) && attribute.references) { template += ` REFERENCES ${this.quoteTable(attribute.references.model)}`; if (attribute.references.key) { @@ -966,13 +973,42 @@ class MSSQLQueryGenerator extends AbstractQueryGenerator { } if (options.limit || options.offset) { - if (!options.order || !options.order.length || options.include && !orders.subQueryOrder.length) { - const tablePkFragment = `${this.quoteTable(options.tableAs || model.name)}.${this.quoteIdentifier(model.primaryKeyField)}`; + // TODO: document why this is adding the primary key of the model in ORDER BY + // if options.include is set + if (!options.order || options.order.length === 0 || options.include && orders.subQueryOrder.length === 0) { + let primaryKey = model.primaryKeyField; + + const tablePkFragment = `${this.quoteTable(options.tableAs || model.name)}.${this.quoteIdentifier(primaryKey)}`; + const aliasedAttribute = (options.attributes || []).find(attr => Array.isArray(attr) + && attr[1] + && (attr[0] === primaryKey || attr[1] === primaryKey)); + + if (aliasedAttribute) { + const modelName = this.quoteIdentifier(options.tableAs || model.name); + const alias = this._getAliasForField(modelName, aliasedAttribute[1], options); + + primaryKey = new Utils.Col(alias || aliasedAttribute[1]); + } + if (!options.order || !options.order.length) { fragment += ` ORDER BY ${tablePkFragment}`; } else { - const orderFieldNames = _.map(options.order, order => order[0]); - const primaryKeyFieldAlreadyPresent = _.includes(orderFieldNames, model.primaryKeyField); + const orderFieldNames = (options.order || []).map(order => { + const value = Array.isArray(order) ? order[0] : order; + + if (value instanceof Utils.Col) { + return value.col; + } + + if (value instanceof Utils.Literal) { + return value.val; + } + + return value; + }); + const primaryKeyFieldAlreadyPresent = orderFieldNames.some( + fieldName => fieldName === (primaryKey.col || primaryKey) + ); if (!primaryKeyFieldAlreadyPresent) { fragment += options.order && !isSubQuery ? ', ' : ' ORDER BY '; diff --git a/lib/dialects/mssql/query-interface.js b/src/dialects/mssql/query-interface.js similarity index 100% rename from lib/dialects/mssql/query-interface.js rename to src/dialects/mssql/query-interface.js diff --git a/lib/dialects/mssql/query.js b/src/dialects/mssql/query.js similarity index 96% rename from lib/dialects/mssql/query.js rename to src/dialects/mssql/query.js index f35c43d948e7..8145368dc54a 100644 --- a/lib/dialects/mssql/query.js +++ b/src/dialects/mssql/query.js @@ -8,6 +8,9 @@ const { logger } = require('../../utils/logger'); const debug = logger.debugContext('sql:mssql'); +const minSafeIntegerAsBigInt = BigInt(Number.MIN_SAFE_INTEGER); +const maxSafeIntegerAsBigInt = BigInt(Number.MAX_SAFE_INTEGER); + function getScale(aNum) { if (!Number.isFinite(aNum)) return 0; let e = 1; @@ -21,8 +24,7 @@ class Query extends AbstractQuery { } getSQLTypeFromJsType(value, TYPES) { - const paramType = { type: TYPES.VarChar, typeOptions: {} }; - paramType.type = TYPES.NVarChar; + const paramType = { type: TYPES.NVarChar, typeOptions: {}, value }; if (typeof value === 'number') { if (Number.isInteger(value)) { if (value >= -2147483648 && value <= 2147483647) { @@ -35,6 +37,13 @@ class Query extends AbstractQuery { //Default to a reasonable numeric precision/scale pending more sophisticated logic paramType.typeOptions = { precision: 30, scale: getScale(value) }; } + } else if (typeof value === 'bigint') { + if (value < minSafeIntegerAsBigInt || value > maxSafeIntegerAsBigInt) { + paramType.type = TYPES.VarChar; + paramType.value = value.toString(); + } else { + return this.getSQLTypeFromJsType(Number(value), TYPES); + } } else if (typeof value === 'boolean') { paramType.type = TYPES.Bit; } diff --git a/lib/dialects/mysql/connection-manager.js b/src/dialects/mysql/connection-manager.js similarity index 100% rename from lib/dialects/mysql/connection-manager.js rename to src/dialects/mysql/connection-manager.js diff --git a/lib/dialects/mysql/data-types.js b/src/dialects/mysql/data-types.js similarity index 100% rename from lib/dialects/mysql/data-types.js rename to src/dialects/mysql/data-types.js diff --git a/lib/dialects/mysql/index.js b/src/dialects/mysql/index.js similarity index 97% rename from lib/dialects/mysql/index.js rename to src/dialects/mysql/index.js index a9850b11e83b..797706092849 100644 --- a/lib/dialects/mysql/index.js +++ b/src/dialects/mysql/index.js @@ -22,6 +22,10 @@ class MysqlDialect extends AbstractDialect { this.queryGenerator ); } + + canBackslashEscape() { + return true; + } } MysqlDialect.prototype.supports = _.merge( diff --git a/lib/dialects/mysql/query-generator.js b/src/dialects/mysql/query-generator.js similarity index 96% rename from lib/dialects/mysql/query-generator.js rename to src/dialects/mysql/query-generator.js index 9653d076f78e..13c549b5d79f 100644 --- a/lib/dialects/mysql/query-generator.js +++ b/src/dialects/mysql/query-generator.js @@ -164,11 +164,18 @@ class MySQLQueryGenerator extends AbstractQueryGenerator { if (database) { query += ` AND TABLE_SCHEMA = ${this.escape(database)}`; } else { - query += ' AND TABLE_SCHEMA NOT IN (\'MYSQL\', \'INFORMATION_SCHEMA\', \'PERFORMANCE_SCHEMA\', \'SYS\')'; + query += ' AND TABLE_SCHEMA NOT IN (\'MYSQL\', \'INFORMATION_SCHEMA\', \'PERFORMANCE_SCHEMA\', \'SYS\', \'mysql\', \'information_schema\', \'performance_schema\', \'sys\')'; } return `${query};`; } + tableExistsQuery(table) { + // remove first & last `, then escape as SQL string + const tableName = this.escape(this.quoteTable(table).slice(1, -1)); + + return `SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_NAME = ${tableName} AND TABLE_SCHEMA = ${this.escape(this.sequelize.config.database)}`; + } + addColumnQuery(table, key, dataType) { return Utils.joinSQLFragments([ 'ALTER TABLE', @@ -398,7 +405,7 @@ class MySQLQueryGenerator extends AbstractQueryGenerator { template += ` AFTER ${this.quoteIdentifier(attribute.after)}`; } - if (attribute.references) { + if ((!options || !options.withoutForeignKeyConstraints) && attribute.references) { if (options && options.context === 'addColumn' && options.foreignKey) { const attrName = this.quoteIdentifier(options.foreignKey); const fkName = this.quoteIdentifier(`${options.tableName}_${attrName}_foreign_idx`); diff --git a/lib/dialects/mysql/query-interface.js b/src/dialects/mysql/query-interface.js similarity index 100% rename from lib/dialects/mysql/query-interface.js rename to src/dialects/mysql/query-interface.js diff --git a/lib/dialects/mysql/query.js b/src/dialects/mysql/query.js similarity index 100% rename from lib/dialects/mysql/query.js rename to src/dialects/mysql/query.js diff --git a/src/dialects/oracle/connection-manager.js b/src/dialects/oracle/connection-manager.js new file mode 100644 index 000000000000..44e791236304 --- /dev/null +++ b/src/dialects/oracle/connection-manager.js @@ -0,0 +1,179 @@ +// Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved + +'use strict'; + +const AbstractConnectionManager = require('../abstract/connection-manager'); +const SequelizeErrors = require('../../errors'); +const parserStore = require('../parserStore')('oracle'); +const { logger } = require('../../utils/logger'); +const semver = require('semver'); +const debug = logger.debugContext('connection:oracle'); +const DataTypes = require('../../data-types').oracle; +const { promisify } = require('util'); +/** + * Oracle Connection Manager + * + * Get connections, validate and disconnect them. + * AbstractConnectionManager pooling use it to handle Oracle specific connections + * Use github.com/oracle/node-oracledb to connect with Oracle server + * + * @private + */ +export class OracleConnectionManager extends AbstractConnectionManager { + constructor(dialect, sequelize) { + super(dialect, sequelize); + + this.sequelize = sequelize; + this.sequelize.config.port = this.sequelize.config.port || 1521; + this.lib = this._loadDialectModule('oracledb'); + this.extendLib(); + this.refreshTypeParser(DataTypes); + } + + /** + * Method for initializing the lib + * + */ + extendLib() { + if (this.sequelize.config && 'dialectOptions' in this.sequelize.config) { + const dialectOptions = this.sequelize.config.dialectOptions; + if (dialectOptions && 'maxRows' in dialectOptions) { + this.lib.maxRows = this.sequelize.config.dialectOptions.maxRows; + } + if (dialectOptions && 'fetchAsString' in dialectOptions) { + this.lib.fetchAsString = this.sequelize.config.dialectOptions.fetchAsString; + } else { + this.lib.fetchAsString = [this.lib.CLOB]; + } + } + // Retrieve BLOB always as Buffer. + this.lib.fetchAsBuffer = [this.lib.BLOB]; + } + + /** + * Method for checking the config object passed and generate the full database if not fully passed + * With dbName, host and port, it generates a string like this : 'host:port/dbname' + * + * @param {object} config + * @returns {Promise} + * @private + */ + buildConnectString(config) { + if (!config.host || config.host.length === 0) + return config.database; + let connectString = config.host; + if (config.port && config.port > 0) { + connectString += `:${config.port}`; + } else { + connectString += ':1521'; + } + if (config.database && config.database.length > 0) { + connectString += `/${config.database}`; + } + return connectString; + } + + // Expose this as a method so that the parsing may be updated when the user has added additional, custom types + _refreshTypeParser(dataType) { + parserStore.refresh(dataType); + } + + _clearTypeParser() { + parserStore.clear(); + } + + /** + * Connect with Oracle database based on config, Handle any errors in connection + * Set the pool handlers on connection.error + * Also set proper timezone once connection is connected. + * + * @param {object} config + * @returns {Promise} + * @private + */ + async connect(config) { + const connectionConfig = { + user: config.username, + password: config.password, + externalAuth: config.externalAuth, + stmtCacheSize: 0, + connectString: this.buildConnectString(config), + ...config.dialectOptions + }; + + try { + const connection = await this.lib.getConnection(connectionConfig); + // Setting the sequelize database version to Oracle DB server version to remove the roundtrip for DB version query + this.sequelize.options.databaseVersion = semver.coerce(connection.oracleServerVersionString).version; + + debug('connection acquired'); + connection.on('error', error => { + switch (error.code) { + case 'ESOCKET': + case 'ECONNRESET': + case 'EPIPE': + case 'PROTOCOL_CONNECTION_LOST': + this.pool.destroy(connection); + } + }); + + return connection; + } catch (err) { + // We split to get the error number; it comes as ORA-XXXXX: + let errorCode = err.message.split(':'); + errorCode = errorCode[0]; + + switch (errorCode) { + case 'ORA-12560': // ORA-12560: TNS: Protocol Adapter Error + case 'ORA-12154': // ORA-12154: TNS: Could not resolve the connect identifier specified + case 'ORA-12505': // ORA-12505: TNS: Listener does not currently know of SID given in connect descriptor + case 'ORA-12514': // ORA-12514: TNS: Listener does not currently know of service requested in connect descriptor + case 'NJS-511': // NJS-511: connection refused + case 'NJS-516': // NJS-516: No Config Dir + case 'NJS-517': // NJS-517: TNS Entry not found + case 'NJS-520': // NJS-520: TNS Names File missing + throw new SequelizeErrors.ConnectionRefusedError(err); + case 'ORA-28000': // ORA-28000: Account locked + case 'ORA-28040': // ORA-28040: No matching authentication protocol + case 'ORA-01017': // ORA-01017: invalid username/password; logon denied + case 'NJS-506': // NJS-506: TLS Auth Failure + throw new SequelizeErrors.AccessDeniedError(err); + case 'ORA-12541': // ORA-12541: TNS: No listener + case 'NJS-503': // NJS-503: Connection Incomplete + case 'NJS-508': // NJS-508: TLS HOST MATCH Failure + case 'NJS-507': // NJS-507: TLS DN MATCH Failure + throw new SequelizeErrors.HostNotReachableError(err); + case 'NJS-512': // NJS-512: Invalid Connect String Parameters + case 'NJS-515': // NJS-515: Invalid EZCONNECT Syntax + case 'NJS-518': // NJS-518: Invald ServiceName + case 'NJS-519': // NJS-519: Invald SID + throw new SequelizeErrors.InvalidConnectionError(err); + case 'ORA-12170': // ORA-12170: TNS: Connect Timeout occurred + case 'NJS-510': // NJS-510: Connect Timeout occurred + + throw new SequelizeErrors.ConnectionTimedOutError(err); + default: + throw new SequelizeErrors.ConnectionError(err); + } + } + } + + async disconnect(connection) { + if (!connection.isHealthy()) { + debug('connection tried to disconnect but was already at CLOSED state'); + return; + } + + return await promisify(callback => connection.close(callback))(); + } + + /** + * Checking if the connection object is valid and the connection is healthy + * + * @param {object} connection + * @private + */ + validate(connection) { + return connection && connection.isHealthy(); + } +} diff --git a/src/dialects/oracle/data-types.js b/src/dialects/oracle/data-types.js new file mode 100644 index 000000000000..2bb99a00debc --- /dev/null +++ b/src/dialects/oracle/data-types.js @@ -0,0 +1,486 @@ +// Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved + +'use strict'; + +const moment = require('moment'); +const momentTz = require('moment-timezone'); + +module.exports = BaseTypes => { + const warn = BaseTypes.ABSTRACT.warn.bind( + undefined, + 'https://www.oracle.com/pls/topic/lookup?ctx=dblatest&id=GUID-D424D23B-0933-425F-BC69-9C0E6724693C' + ); + + BaseTypes.DATE.types.oracle = ['TIMESTAMP', 'TIMESTAMP WITH LOCAL TIME ZONE']; + BaseTypes.STRING.types.oracle = ['VARCHAR2', 'NVARCHAR2']; + BaseTypes.CHAR.types.oracle = ['CHAR', 'RAW']; + BaseTypes.TEXT.types.oracle = ['CLOB']; + BaseTypes.TINYINT.types.oracle = ['NUMBER']; + BaseTypes.SMALLINT.types.oracle = ['NUMBER']; + BaseTypes.MEDIUMINT.types.oracle = ['NUMBER']; + BaseTypes.INTEGER.types.oracle = ['INTEGER']; + BaseTypes.BIGINT.types.oracle = ['NUMBER']; + BaseTypes.FLOAT.types.oracle = ['BINARY_FLOAT']; + BaseTypes.DATEONLY.types.oracle = ['DATE']; + BaseTypes.BOOLEAN.types.oracle = ['CHAR(1)']; + BaseTypes.BLOB.types.oracle = ['BLOB']; + BaseTypes.DECIMAL.types.oracle = ['NUMBER']; + BaseTypes.UUID.types.oracle = ['VARCHAR2']; + BaseTypes.ENUM.types.oracle = ['VARCHAR2']; + BaseTypes.REAL.types.oracle = ['BINARY_DOUBLE']; + BaseTypes.DOUBLE.types.oracle = ['BINARY_DOUBLE']; + BaseTypes.JSON.types.oracle = ['BLOB']; + BaseTypes.GEOMETRY.types.oracle = false; + + class STRING extends BaseTypes.STRING { + toSql() { + if (this.length > 4000 || this._binary && this._length > 2000) { + warn( + 'Oracle supports length up to 32764 bytes or characters; Be sure that your administrator has extended the MAX_STRING_SIZE parameter. Check https://docs.oracle.com/pls/topic/lookup?ctx=dblatest&id=GUID-7B72E154-677A-4342-A1EA-C74C1EA928E6' + ); + } + if (!this._binary) { + return `NVARCHAR2(${this._length})`; + } + return `RAW(${this._length})`; + } + + _stringify(value, options) { + if (this._binary) { + // For Binary numbers we're converting a buffer to hex then + // sending it over the wire as a string, + // We pass it through escape function to remove un-necessary quotes + // this.format in insert/bulkinsert query calls stringify hence we need to convert binary buffer + // to hex string. Since this block is used by both bind (insert/bulkinsert) and + // non-bind (select query where clause) hence we need to + // have an operation that supports both + return options.escape(value.toString('hex')); + } + return options.escape(value); + } + + _getBindDef(oracledb) { + if (this._binary) { + return { type: oracledb.DB_TYPE_RAW, maxSize: this._length }; + } + return { type: oracledb.DB_TYPE_VARCHAR, maxSize: this._length }; + } + + _bindParam(value, options) { + return options.bindParam(value); + } + } + + STRING.prototype.escape = false; + + class BOOLEAN extends BaseTypes.BOOLEAN { + toSql() { + return 'CHAR(1)'; + } + + _getBindDef(oracledb) { + return { type: oracledb.DB_TYPE_CHAR, maxSize: 1 }; + } + + _stringify(value) { + // If value is true we return '1' + // If value is false we return '0' + // Else we return it as is + // Converting number to char since in bindDef + // the type would be oracledb.DB_TYPE_CHAR + return value === true ? '1' : value === false ? '0' : value; + } + + _sanitize(value) { + if (typeof value === 'string') { + // If value is a string we return true if among '1' and 'true' + // We return false if among '0' and 'false' + // Else return the value as is and let the DB raise error for invalid values + return value === '1' || value === 'true' ? true : value === '0' || value === 'false' ? false : value; + } + return super._sanitize(value); + } + } + + class UUID extends BaseTypes.UUID { + toSql() { + return 'VARCHAR2(36)'; + } + + _getBindDef(oracledb) { + return { type: oracledb.DB_TYPE_VARCHAR, maxSize: 36 }; + } + } + + class NOW extends BaseTypes.NOW { + toSql() { + return 'SYSDATE'; + } + + _stringify() { + return 'SYSDATE'; + } + } + + class ENUM extends BaseTypes.ENUM { + toSql() { + return 'VARCHAR2(512)'; + } + + _getBindDef(oracledb) { + return { type: oracledb.DB_TYPE_VARCHAR, maxSize: 512 }; + } + } + + class TEXT extends BaseTypes.TEXT { + toSql() { + return 'CLOB'; + } + + _getBindDef(oracledb) { + return { type: oracledb.DB_TYPE_CLOB }; + } + } + + class CHAR extends BaseTypes.CHAR { + toSql() { + if (this._binary) { + warn('Oracle CHAR.BINARY datatype is not of Fixed Length.'); + return `RAW(${this._length})`; + } + return super.toSql(); + } + + _getBindDef(oracledb) { + if (this._binary) { + return { type: oracledb.DB_TYPE_RAW, maxSize: this._length }; + } + return { type: oracledb.DB_TYPE_CHAR, maxSize: this._length }; + } + + _bindParam(value, options) { + return options.bindParam(value); + } + } + + class DATE extends BaseTypes.DATE { + toSql() { + return 'TIMESTAMP WITH LOCAL TIME ZONE'; + } + + _getBindDef(oracledb) { + return { type: oracledb.DB_TYPE_TIMESTAMP_LTZ }; + } + + _stringify(date, options) { + const format = 'YYYY-MM-DD HH24:MI:SS.FFTZH:TZM'; + + date = this._applyTimezone(date, options); + + const formatedDate = date.format('YYYY-MM-DD HH:mm:ss.SSS Z'); + + return `TO_TIMESTAMP_TZ('${formatedDate}','${format}')`; + } + + _applyTimezone(date, options) { + if (options.timezone) { + if (momentTz.tz.zone(options.timezone)) { + date = momentTz(date).tz(options.timezone); + } else { + date = moment(date).utcOffset(options.timezone); + } + } else { + date = momentTz(date); + } + return date; + } + + static parse(value, options) { + if (value === null) { + return value; + } + if (options && moment.tz.zone(options.timezone)) { + value = moment.tz(value.toString(), options.timezone).toDate(); + } + return value; + } + + /** + * avoids appending TO_TIMESTAMP_TZ in _stringify + * + * @override + */ + _bindParam(value, options) { + return options.bindParam(value); + } + } + + DATE.prototype.escape = false; + + class DECIMAL extends BaseTypes.DECIMAL { + toSql() { + let result = ''; + if (this._length) { + result += `(${this._length}`; + if (typeof this._decimals === 'number') { + result += `,${this._decimals}`; + } + result += ')'; + } + + if (!this._length && this._precision) { + result += `(${this._precision}`; + if (typeof this._scale === 'number') { + result += `,${this._scale}`; + } + result += ')'; + } + + return `NUMBER${result}`; + } + + _getBindDef(oracledb) { + return { type: oracledb.DB_TYPE_NUMBER }; + } + } + + class TINYINT extends BaseTypes.TINYINT { + toSql() { + return 'NUMBER(3)'; + } + + _getBindDef(oracledb) { + return { type: oracledb.DB_TYPE_NUMBER }; + } + } + + class SMALLINT extends BaseTypes.SMALLINT { + toSql() { + if (this._length) { + return `NUMBER(${this._length},0)`; + } + return 'SMALLINT'; + } + + _getBindDef(oracledb) { + return { type: oracledb.DB_TYPE_NUMBER }; + } + } + + class MEDIUMINT extends BaseTypes.MEDIUMINT { + toSql() { + return 'NUMBER(8)'; + } + + _getBindDef(oracledb) { + return { type: oracledb.DB_TYPE_NUMBER }; + } + } + + class BIGINT extends BaseTypes.BIGINT { + constructor(length) { + super(length); + if (!(this instanceof BIGINT)) return new BIGINT(length); + BaseTypes.BIGINT.apply(this, arguments); + + // ORACLE does not support any options for bigint + if (this._length || this.options.length || this._unsigned || this._zerofill) { + warn('Oracle does not support BIGINT with options'); + this._length = undefined; + this.options.length = undefined; + this._unsigned = undefined; + this._zerofill = undefined; + } + } + + toSql() { + return 'NUMBER(19)'; + } + + _getBindDef(oracledb) { + return { type: oracledb.DB_TYPE_NUMBER }; + } + + _sanitize(value) { + if (typeof value === 'bigint' || typeof value === 'number') { + return value.toString(); + } + return value; + } + + } + + class NUMBER extends BaseTypes.NUMBER { + _getBindDef(oracledb) { + return { type: oracledb.DB_TYPE_NUMBER }; + } + } + + class INTEGER extends BaseTypes.INTEGER { + toSql() { + if (this._length) { + return `NUMBER(${this._length},0)`; + } + return 'INTEGER'; + } + + _getBindDef(oracledb) { + return { type: oracledb.DB_TYPE_NUMBER }; + } + } + + class FLOAT extends BaseTypes.FLOAT { + toSql() { + return 'BINARY_FLOAT'; + } + + _getBindDef(oracledb) { + return { type: oracledb.DB_TYPE_BINARY_FLOAT }; + } + } + + class REAL extends BaseTypes.REAL { + toSql() { + return 'BINARY_DOUBLE'; + } + + // https://www.oracle.com/pls/topic/lookup?ctx=dblatest&id=GUID-0BA2E065-8006-426C-A3CB-1F6B0C8F283C + _stringify(value) { + if (value === Number.POSITIVE_INFINITY) { + return 'inf'; + } + if (value === Number.NEGATIVE_INFINITY) { + return '-inf'; + } + return value; + } + + _getBindDef(oracledb) { + return { type: oracledb.DB_TYPE_BINARY_DOUBLE }; + } + } + + class BLOB extends BaseTypes.BLOB { + // Generic hexify returns X'${hex}' but Oracle expects '${hex}' for BLOB datatype + _hexify(hex) { + return `'${hex}'`; + } + + toSql() { + return 'BLOB'; + } + + _getBindDef(oracledb) { + return { type: oracledb.DB_TYPE_BLOB }; + } + } + + class JSONTYPE extends BaseTypes.JSON { + toSql() { + return 'BLOB'; + } + + _getBindDef(oracledb) { + return { type: oracledb.DB_TYPE_BLOB }; + } + + _stringify(value, options) { + return options.operation === 'where' && typeof value === 'string' ? value : JSON.stringify(value); + } + + _bindParam(value, options) { + return options.bindParam(Buffer.from(JSON.stringify(value))); + } + } + + class DOUBLE extends BaseTypes.DOUBLE { + constructor(length, decimals) { + super(length, decimals); + if (!(this instanceof DOUBLE)) return new BaseTypes.DOUBLE(length, decimals); + BaseTypes.DOUBLE.apply(this, arguments); + + if (this._length || this._unsigned || this._zerofill) { + warn('Oracle does not support DOUBLE with options.'); + this._length = undefined; + this.options.length = undefined; + this._unsigned = undefined; + this._zerofill = undefined; + } + + this.key = 'DOUBLE PRECISION'; + } + + _getBindDef(oracledb) { + return { type: oracledb.DB_TYPE_BINARY_DOUBLE }; + } + + toSql() { + return 'BINARY_DOUBLE'; + } + } + class DATEONLY extends BaseTypes.DATEONLY { + parse(value) { + return moment(value).format('YYYY-MM-DD'); + } + + _sanitize(value) { + if (value) { + return moment(value).format('YYYY-MM-DD'); + } + return value; + } + + _stringify(date, options) { + // If date is not null only then we format the date + if (date) { + const format = 'YYYY/MM/DD'; + return options.escape(`TO_DATE('${date}','${format}')`); + } + return options.escape(date); + } + + _getBindDef(oracledb) { + return { type: oracledb.DB_TYPE_DATE }; + } + + /** + * avoids appending TO_DATE in _stringify + * + * @override + */ + _bindParam(value, options) { + if (typeof value === 'string') { + return options.bindParam(new Date(value)); + } + return options.bindParam(value); + + } + } + + DATEONLY.prototype.escape = false; + + return { + BOOLEAN, + 'DOUBLE PRECISION': DOUBLE, + DOUBLE, + STRING, + TINYINT, + SMALLINT, + MEDIUMINT, + BIGINT, + NUMBER, + INTEGER, + FLOAT, + UUID, + DATEONLY, + DATE, + NOW, + BLOB, + ENUM, + TEXT, + CHAR, + JSON: JSONTYPE, + REAL, + DECIMAL + }; +}; diff --git a/src/dialects/oracle/index.js b/src/dialects/oracle/index.js new file mode 100644 index 000000000000..2e03d9f1585b --- /dev/null +++ b/src/dialects/oracle/index.js @@ -0,0 +1,68 @@ +// Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved + +'use strict'; + +const _ = require('lodash'); +const { AbstractDialect } = require('../abstract'); +const { OracleConnectionManager } = require('./connection-manager'); +const { OracleQuery } = require('./query'); +const { OracleQueryGenerator } = require('./query-generator'); +const DataTypes = require('../../data-types').oracle; +const { OracleQueryInterface } = require('./query-interface'); + +class OracleDialect extends AbstractDialect { + constructor(sequelize) { + super(); + this.sequelize = sequelize; + this.connectionManager = new OracleConnectionManager(this, sequelize); + this.connectionManager.initPools(); + this.queryGenerator = new OracleQueryGenerator({ + _dialect: this, + sequelize + }); + this.queryInterface = new OracleQueryInterface(sequelize, this.queryGenerator); + } +} + +OracleDialect.prototype.supports = _.merge(_.cloneDeep(AbstractDialect.prototype.supports), { + 'VALUES ()': true, + 'LIMIT ON UPDATE': true, + IGNORE: ' IGNORE', + lock: true, + lockOuterJoinFailure: true, + forShare: 'FOR UPDATE', + skipLocked: true, + index: { + collate: false, + length: false, + parser: false, + type: false, + using: false + }, + constraints: { + restrict: false + }, + returnValues: false, + returnIntoValues: true, + 'ORDER NULLS': true, + schemas: true, + updateOnDuplicate: false, + indexViaAlter: false, + NUMERIC: true, + JSON: true, + upserts: true, + bulkDefault: true, + topLevelOrderByRequired: true, + GEOMETRY: false +}); + +OracleDialect.prototype.defaultVersion = '18.0.0'; +OracleDialect.prototype.Query = OracleQuery; +OracleDialect.prototype.queryGenerator = OracleQueryGenerator; +OracleDialect.prototype.DataTypes = DataTypes; +OracleDialect.prototype.name = 'oracle'; +OracleDialect.prototype.TICK_CHAR = '"'; +OracleDialect.prototype.TICK_CHAR_LEFT = OracleDialect.prototype.TICK_CHAR; +OracleDialect.prototype.TICK_CHAR_RIGHT = OracleDialect.prototype.TICK_CHAR; + +module.exports = OracleDialect; diff --git a/src/dialects/oracle/query-generator.js b/src/dialects/oracle/query-generator.js new file mode 100644 index 000000000000..5a2a56449357 --- /dev/null +++ b/src/dialects/oracle/query-generator.js @@ -0,0 +1,1292 @@ +// Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved + +'use strict'; + +const Utils = require('../../utils'); +const DataTypes = require('../../data-types'); +const AbstractQueryGenerator = require('../abstract/query-generator'); +const _ = require('lodash'); +const util = require('util'); +const Transaction = require('../../transaction'); + +/** + * list of reserved words in Oracle DB 21c + * source: https://www.oracle.com/pls/topic/lookup?ctx=dblatest&id=GUID-7B72E154-677A-4342-A1EA-C74C1EA928E6 + * + * @private + */ +const ORACLE_RESERVED_WORDS = ['ACCESS', 'ADD', 'ALL', 'ALTER', 'AND', 'ANY', 'ARRAYLEN', 'AS', 'ASC', 'AUDIT', 'BETWEEN', 'BY', 'CHAR', 'CHECK', 'CLUSTER', 'COLUMN', 'COMMENT', 'COMPRESS', 'CONNECT', 'CREATE', 'CURRENT', 'DATE', 'DECIMAL', 'DEFAULT', 'DELETE', 'DESC', 'DISTINCT', 'DROP', 'ELSE', 'EXCLUSIVE', 'EXISTS', 'FILE', 'FLOAT', 'FOR', 'FROM', 'GRANT', 'GROUP', 'HAVING', 'IDENTIFIED', 'IMMEDIATE', 'IN', 'INCREMENT', 'INDEX', 'INITIAL', 'INSERT', 'INTEGER', 'INTERSECT', 'INTO', 'IS', 'LEVEL', 'LIKE', 'LOCK', 'LONG', 'MAXEXTENTS', 'MINUS', 'MODE', 'MODIFY', 'NOAUDIT', 'NOCOMPRESS', 'NOT', 'NOTFOUND', 'NOWAIT', 'NULL', 'NUMBER', 'OF', 'OFFLINE', 'ON', 'ONLINE', 'OPTION', 'OR', 'ORDER', 'PCTFREE', 'PRIOR', 'PRIVILEGES', 'PUBLIC', 'RAW', 'RENAME', 'RESOURCE', 'REVOKE', 'ROW', 'ROWID', 'ROWLABEL', 'ROWNUM', 'ROWS', 'SELECT', 'SESSION', 'SET', 'SHARE', 'SIZE', 'SMALLINT', 'SQLBUF', 'START', 'SUCCESSFUL', 'SYNONYM', 'SYSDATE', 'TABLE', 'THEN', 'TO', 'TRIGGER', 'UID', 'UNION', 'UNIQUE', 'UPDATE', 'USER', 'VALIDATE', 'VALUES', 'VARCHAR', 'VARCHAR2', 'VIEW', 'WHENEVER', 'WHERE', 'WITH']; +const JSON_FUNCTION_REGEX = /^\s*((?:[a-z]+_){0,2}jsonb?(?:_[a-z]+){0,2})\([^)]*\)/i; +const JSON_OPERATOR_REGEX = /^\s*(->>?|@>|<@|\?[|&]?|\|{2}|#-)/i; +const TOKEN_CAPTURE_REGEX = /^\s*((?:([`"'])(?:(?!\2).|\2{2})*\2)|[\w\d\s]+|[().,;+-])/i; + +export class OracleQueryGenerator extends AbstractQueryGenerator { + constructor(options) { + super(options); + } + + /** + * Returns the value as it is stored in the Oracle DB + * + * @param {string} value + */ + getCatalogName(value) { + if (value) { + if (this.options.quoteIdentifiers === false) { + const quotedValue = this.quoteIdentifier(value); + if (quotedValue === value) { + value = value.toUpperCase(); + } + } + } + return value; + } + + /** + * Returns the tableName and schemaName as it is stored the Oracle DB + * + * @param {object|string} table + */ + getSchemaNameAndTableName(table) { + const tableName = this.getCatalogName(table.tableName || table); + const schemaName = this.getCatalogName(table.schema); + return [tableName, schemaName]; + } + + createSchema(schema) { + const quotedSchema = this.quoteIdentifier(schema); + return [ + 'DECLARE', + 'USER_FOUND BOOLEAN := FALSE;', + 'BEGIN', + ' BEGIN', + ' EXECUTE IMMEDIATE ', + this.escape(`CREATE USER ${quotedSchema} IDENTIFIED BY 12345 DEFAULT TABLESPACE USERS`), + ';', + ' EXCEPTION WHEN OTHERS THEN', + ' IF SQLCODE != -1920 THEN', + ' RAISE;', + ' ELSE', + ' USER_FOUND := TRUE;', + ' END IF;', + ' END;', + ' IF NOT USER_FOUND THEN', + ' EXECUTE IMMEDIATE ', + this.escape(`GRANT "CONNECT" TO ${quotedSchema}`), + ';', + ' EXECUTE IMMEDIATE ', + this.escape(`GRANT CREATE TABLE TO ${quotedSchema}`), + ';', + ' EXECUTE IMMEDIATE ', + this.escape(`GRANT CREATE VIEW TO ${quotedSchema}`), + ';', + ' EXECUTE IMMEDIATE ', + this.escape(`GRANT CREATE ANY TRIGGER TO ${quotedSchema}`), + ';', + ' EXECUTE IMMEDIATE ', + this.escape(`GRANT CREATE ANY PROCEDURE TO ${quotedSchema}`), + ';', + ' EXECUTE IMMEDIATE ', + this.escape(`GRANT CREATE SEQUENCE TO ${quotedSchema}`), + ';', + ' EXECUTE IMMEDIATE ', + this.escape(`GRANT CREATE SYNONYM TO ${quotedSchema}`), + ';', + ' EXECUTE IMMEDIATE ', + this.escape(`ALTER USER ${quotedSchema} QUOTA UNLIMITED ON USERS`), + ';', + ' END IF;', + 'END;' + ].join(' '); + } + + showSchemasQuery() { + return 'SELECT USERNAME AS "schema_name" FROM ALL_USERS WHERE COMMON = (\'NO\') AND USERNAME != user'; + } + + dropSchema(schema) { + return [ + 'BEGIN', + 'EXECUTE IMMEDIATE ', + this.escape(`DROP USER ${this.quoteTable(schema)} CASCADE`), + ';', + 'EXCEPTION WHEN OTHERS THEN', + ' IF SQLCODE != -1918 THEN', + ' RAISE;', + ' END IF;', + 'END;' + ].join(' '); + } + + versionQuery() { + return "SELECT VERSION_FULL FROM PRODUCT_COMPONENT_VERSION WHERE PRODUCT LIKE 'Oracle%'"; + } + + createTableQuery(tableName, attributes, options) { + const primaryKeys = [], + foreignKeys = Object.create(null), + attrStr = [], + checkStr = []; + + const values = { + table: this.quoteTable(tableName) + }; + + // Starting by dealing with all attributes + for (let attr in attributes) { + if (!Object.prototype.hasOwnProperty.call(attributes, attr)) continue; + const dataType = attributes[attr]; + attr = this.quoteIdentifier(attr); + + // ORACLE doesn't support inline REFERENCES declarations: move to the end + if (dataType.includes('PRIMARY KEY')) { + // Primary key + primaryKeys.push(attr); + if (dataType.includes('REFERENCES')) { + const match = dataType.match(/^(.+) (REFERENCES.*)$/); + attrStr.push(`${attr} ${match[1].replace(/PRIMARY KEY/, '')}`); + + // match[2] already has foreignKeys in correct format so we don't need to replace + foreignKeys[attr] = match[2]; + } else { + attrStr.push(`${attr} ${dataType.replace(/PRIMARY KEY/, '').trim()}`); + } + } else if (dataType.includes('REFERENCES')) { + // Foreign key + const match = dataType.match(/^(.+) (REFERENCES.*)$/); + attrStr.push(`${attr} ${match[1]}`); + + // match[2] already has foreignKeys in correct format so we don't need to replace + foreignKeys[attr] = match[2]; + } else { + attrStr.push(`${attr} ${dataType}`); + } + } + + values['attributes'] = attrStr.join(', '); + + const pkString = primaryKeys.map(pk => this.quoteIdentifier(pk)).join(', '); + + if (pkString.length > 0) { + values.attributes += `,PRIMARY KEY (${pkString})`; + } + + // Dealing with FKs + for (const fkey in foreignKeys) { + if (!Object.prototype.hasOwnProperty.call(foreignKeys, fkey)) continue; + // Oracle default response for FK, doesn't support if defined + if (foreignKeys[fkey].indexOf('ON DELETE NO ACTION') > -1) { + foreignKeys[fkey] = foreignKeys[fkey].replace('ON DELETE NO ACTION', ''); + } + values.attributes += `,FOREIGN KEY (${this.quoteIdentifier(fkey)}) ${foreignKeys[fkey]}`; + } + + if (checkStr.length > 0) { + values.attributes += `, ${checkStr.join(', ')}`; + } + + // Specific case for unique indexes with Oracle, we have to set the constraint on the column, if not, no FK will be possible (ORA-02270: no matching unique or primary key for this column-list) + if (options && options.indexes && options.indexes.length > 0) { + const idxToDelete = []; + options.indexes.forEach((index, idx) => { + if ('unique' in index && (index.unique === true || index.unique.length > 0 && index.unique !== false)) { + // If unique index, transform to unique constraint on column + const fields = index.fields.map(field => { + if (typeof field === 'string') { + return field; + } + return field.attribute; + + }); + + // Now we have to be sure that the constraint isn't already declared in uniqueKeys + let canContinue = true; + if (options.uniqueKeys) { + const keys = Object.keys(options.uniqueKeys); + + for (let fieldIdx = 0; fieldIdx < keys.length; fieldIdx++) { + const currUnique = options.uniqueKeys[keys[fieldIdx]]; + + if (currUnique.fields.length === fields.length) { + // lengths are the same, possible same constraint + for (let i = 0; i < currUnique.fields.length; i++) { + const field = currUnique.fields[i]; + + if (_.includes(fields, field)) { + canContinue = false; + } else { + // We have at least one different column, even if we found the same columns previously, we let the constraint be created + canContinue = true; + break; + } + } + } + } + + if (canContinue) { + const indexName = 'name' in index ? index.name : ''; + const constraintToAdd = { + name: indexName, + fields + }; + if (!('uniqueKeys' in options)) { + options.uniqueKeys = {}; + } + + options.uniqueKeys[indexName] = constraintToAdd; + idxToDelete.push(idx); + } else { + // The constraint already exists, we remove it from the list + idxToDelete.push(idx); + } + } + } + }); + idxToDelete.forEach(idx => { + options.indexes.splice(idx, 1); + }); + } + + if (options && !!options.uniqueKeys) { + _.each(options.uniqueKeys, (columns, indexName) => { + let canBeUniq = false; + + // Check if we can create the unique key + primaryKeys.forEach(primaryKey => { + // We can create an unique constraint if it's not on the primary key AND if it doesn't have unique in its definition + // We replace quotes in primary key with '' + // Primary key would be a list with double quotes in it so we remove the double quotes + primaryKey = primaryKey.replace(/"/g, ''); + + // We check if the unique indexes are already a part of primary key or not + // If it is not then we set canbeuniq to true and add a unique constraint to these fields. + // Else we can ignore unique constraint on these + if (!_.includes(columns.fields, primaryKey)) { + canBeUniq = true; + } + }); + + columns.fields.forEach(field => { + let currField = ''; + if (!_.isString(field)) { + currField = field.attribute.replace(/[.,"\s]/g, ''); + } else { + currField = field.replace(/[.,"\s]/g, ''); + } + if (currField in attributes) { + // If canBeUniq is false we need not replace the UNIQUE for the attribute + // So we replace UNIQUE with '' only if there exists a primary key + if (attributes[currField].toUpperCase().indexOf('UNIQUE') > -1 && canBeUniq) { + // We generate the attribute without UNIQUE + const attrToReplace = attributes[currField].replace('UNIQUE', ''); + // We replace in the final string + values.attributes = values.attributes.replace(attributes[currField], attrToReplace); + } + } + }); + + // Oracle cannot have an unique AND a primary key on the same fields, prior to the primary key + if (canBeUniq) { + const index = options.uniqueKeys[columns.name]; + delete options.uniqueKeys[columns.name]; + indexName = indexName.replace(/[.,\s]/g, ''); + columns.name = indexName; + options.uniqueKeys[indexName] = index; + + // Autogenerate Constraint name, if no indexName is given + if (indexName.length === 0) { + values.attributes += `,UNIQUE (${columns.fields.map(field => this.quoteIdentifier(field)).join(', ') })`; + } else { + values.attributes += + `, CONSTRAINT ${this.quoteIdentifier(indexName)} UNIQUE (${columns.fields.map(field => this.quoteIdentifier(field)).join(', ') })`; + } + } + }); + } + + // we replace single quotes by two quotes in order for the execute statement to work + const query = Utils.joinSQLFragments([ + 'CREATE TABLE', + values.table, + `(${values.attributes})` + ]); + + return Utils.joinSQLFragments([ + 'BEGIN', + 'EXECUTE IMMEDIATE', + `${this.escape(query)};`, + 'EXCEPTION WHEN OTHERS THEN', + 'IF SQLCODE != -955 THEN', + 'RAISE;', + 'END IF;', + 'END;' + ]); + } + + tableExistsQuery(table) { + const [tableName, schemaName] = this.getSchemaNameAndTableName(table); + return `SELECT TABLE_NAME FROM ALL_TABLES WHERE TABLE_NAME = ${this.escape(tableName)} AND OWNER = ${table.schema ? this.escape(schemaName) : 'USER'}`; + } + + describeTableQuery(tableName, schema) { + const currTableName = this.getCatalogName(tableName.tableName || tableName); + schema = this.getCatalogName(schema); + // name, type, datalength (except number / nvarchar), datalength varchar, datalength number, nullable, default value, primary ? + return [ + 'SELECT atc.COLUMN_NAME, atc.DATA_TYPE, atc.DATA_LENGTH, atc.CHAR_LENGTH, atc.DEFAULT_LENGTH, atc.NULLABLE, ucc.constraint_type ', + 'FROM all_tab_columns atc ', + 'LEFT OUTER JOIN ', + '(SELECT acc.column_name, acc.table_name, ac.constraint_type FROM all_cons_columns acc INNER JOIN all_constraints ac ON acc.constraint_name = ac.constraint_name) ucc ', + 'ON (atc.table_name = ucc.table_name AND atc.COLUMN_NAME = ucc.COLUMN_NAME) ', + schema + ? `WHERE (atc.OWNER = ${this.escape(schema)}) ` + : 'WHERE atc.OWNER = USER ', + `AND (atc.TABLE_NAME = ${this.escape(currTableName)})`, + 'ORDER BY atc.COLUMN_NAME, CONSTRAINT_TYPE DESC' + ].join(''); + } + + renameTableQuery(before, after) { + return Utils.joinSQLFragments([ + 'ALTER TABLE', + this.quoteTable(before), + 'RENAME TO', + this.quoteTable(after) + ]); + } + + showConstraintsQuery(table) { + const tableName = this.getCatalogName(table.tableName || table); + return `SELECT CONSTRAINT_NAME constraint_name FROM user_cons_columns WHERE table_name = ${this.escape(tableName)}`; + } + + showTablesQuery() { + return 'SELECT owner as table_schema, table_name, 0 as lvl FROM all_tables where OWNER IN(SELECT USERNAME AS "schema_name" FROM ALL_USERS WHERE ORACLE_MAINTAINED = \'N\')'; + } + + dropTableQuery(tableName) { + return Utils.joinSQLFragments([ + 'BEGIN ', + 'EXECUTE IMMEDIATE \'DROP TABLE', + this.quoteTable(tableName), + 'CASCADE CONSTRAINTS PURGE\';', + 'EXCEPTION WHEN OTHERS THEN', + ' IF SQLCODE != -942 THEN', + ' RAISE;', + ' END IF;', + 'END;' + ]); + } + + /* + Modifying the indexname so that it is prefixed with the schema name + otherwise Oracle tries to add the index to the USER schema + @overide + */ + addIndexQuery(tableName, attributes, options, rawTablename) { + if (typeof tableName !== 'string' && attributes.name) { + attributes.name = `${tableName.schema}.${attributes.name}`; + } + return super.addIndexQuery(tableName, attributes, options, rawTablename); + } + + addConstraintQuery(tableName, options) { + options = options || {}; + + if (options.onUpdate) { + // Oracle does not support ON UPDATE, remove it. + delete options.onUpdate; + } + + if (options.onDelete && options.onDelete.toUpperCase() === 'NO ACTION') { + // 'ON DELETE NO ACTION' is the default option in Oracle, but it is not supported if defined + delete options.onDelete; + } + + const constraintSnippet = this.getConstraintSnippet(tableName, options); + + tableName = this.quoteTable(tableName); + return `ALTER TABLE ${tableName} ADD ${constraintSnippet};`; + } + + addColumnQuery(table, key, dataType) { + dataType.field = key; + + const attribute = Utils.joinSQLFragments([ + this.quoteIdentifier(key), + this.attributeToSQL(dataType, { + attributeName: key, + context: 'addColumn' + }) + ]); + + return Utils.joinSQLFragments([ + 'ALTER TABLE', + this.quoteTable(table), + 'ADD', + attribute + ]); + } + + removeColumnQuery(tableName, attributeName) { + return Utils.joinSQLFragments([ + 'ALTER TABLE', + this.quoteTable(tableName), + 'DROP COLUMN', + this.quoteIdentifier(attributeName), + ';' + ]); + } + + /** + * Function to add new foreign key to the attribute + * Block for add and drop foreign key constraint query + * taking the assumption that there is a single column foreign key reference always + * i.e. we always do - FOREIGN KEY (a) reference B(a) during createTable queryGenerator + * so there would be one and only one match for a constraint name for each column + * and every foreign keyed column would have a different constraint name + * Since sequelize doesn't support multiple column foreign key, added complexity to + * add the feature isn't needed + * + * @param {string} definition The operation that needs to be performed on the attribute + * @param {string|object} table The table that needs to be altered + * @param {string} attributeName The name of the attribute which would get altered + */ + _alterForeignKeyConstraint(definition, table, attributeName) { + const [tableName, schemaName] = this.getSchemaNameAndTableName(table); + const attributeNameConstant = this.escape(this.getCatalogName(attributeName)); + const schemaNameConstant = table.schema ? this.escape(this.getCatalogName(schemaName)) : 'USER'; + const tableNameConstant = this.escape(this.getCatalogName(tableName)); + const getConsNameQuery = [ + 'SELECT constraint_name INTO cons_name', + 'FROM (', + ' SELECT DISTINCT cc.owner, cc.table_name, cc.constraint_name, cc.column_name AS cons_columns', + ' FROM all_cons_columns cc, all_constraints c', + ' WHERE cc.owner = c.owner', + ' AND cc.table_name = c.table_name', + ' AND cc.constraint_name = c.constraint_name', + ' AND c.constraint_type = \'R\'', + ' GROUP BY cc.owner, cc.table_name, cc.constraint_name, cc.column_name', + ')', + 'WHERE owner =', + schemaNameConstant, + 'AND table_name =', + tableNameConstant, + 'AND cons_columns =', + attributeNameConstant, + ';' + ].join(' '); + const secondQuery = Utils.joinSQLFragments([ + `ALTER TABLE ${this.quoteIdentifier(tableName)}`, + 'ADD FOREIGN KEY', + `(${this.quoteIdentifier(attributeName)})`, + definition.replace(/.+?(?=REFERENCES)/, '') + ]); + return [ + 'BEGIN', + getConsNameQuery, + 'EXCEPTION', + 'WHEN NO_DATA_FOUND THEN', + ' CONS_NAME := NULL;', + 'END;', + 'IF CONS_NAME IS NOT NULL THEN', + ` EXECUTE IMMEDIATE 'ALTER TABLE ${this.quoteTable(table)} DROP CONSTRAINT "'||CONS_NAME||'"';`, + 'END IF;', + `EXECUTE IMMEDIATE ${this.escape(secondQuery)};` + ].join(' '); + } + + /** + * Function to alter table modify + * + * @param {string} definition The operation that needs to be performed on the attribute + * @param {object|string} table The table that needs to be altered + * @param {string} attributeName The name of the attribute which would get altered + */ + _modifyQuery(definition, table, attributeName) { + definition = definition.startsWith('BLOB') ? definition.replace('BLOB ', '') : definition; + const query = Utils.joinSQLFragments([ + 'ALTER TABLE', + this.quoteTable(table), + 'MODIFY', + this.quoteIdentifier(attributeName), + definition + ]); + const secondQuery = query.replace('NOT NULL', '').replace('NULL', ''); + return [ + 'BEGIN', + `EXECUTE IMMEDIATE ${this.escape(query)};`, + 'EXCEPTION', + 'WHEN OTHERS THEN', + ' IF SQLCODE = -1442 OR SQLCODE = -1451 THEN', + // We execute the statement without the NULL / NOT NULL clause if the first statement failed due to this + ` EXECUTE IMMEDIATE ${this.escape(secondQuery)};`, + ' ELSE', + ' RAISE;', + ' END IF;', + 'END;' + ].join(' '); + } + + changeColumnQuery(table, attributes) { + const sql = [ + 'DECLARE', + 'CONS_NAME VARCHAR2(200);', + 'BEGIN' + ]; + for (const attributeName in attributes) { + if (!Object.prototype.hasOwnProperty.call(attributes, attributeName)) continue; + const definition = attributes[attributeName]; + if (definition.match(/REFERENCES/)) { + sql.push(this._alterForeignKeyConstraint(definition, table, attributeName)); + } else { + // Building the modify query + sql.push(this._modifyQuery(definition, table, attributeName)); + } + } + sql.push('END;'); + return sql.join(' '); + } + + renameColumnQuery(tableName, attrBefore, attributes) { + const newName = Object.keys(attributes)[0]; + return `ALTER TABLE ${this.quoteTable(tableName)} RENAME COLUMN ${this.quoteIdentifier(attrBefore)} TO ${this.quoteIdentifier(newName)}`; + } + + /** + * Populates the returnAttributes array with outbind bindByPosition values + * and also the options.outBindAttributes map with bindDef for outbind of InsertQuery + * + * @param {Array} returningModelAttributes + * @param {Array} returnTypes + * @param {number} inbindLength + * @param {object} returnAttributes + * @param {object} options + * + * @private + */ + populateInsertQueryReturnIntoBinds(returningModelAttributes, returnTypes, inbindLength, returnAttributes, options) { + const oracledb = this.sequelize.connectionManager.lib; + const outBindAttributes = Object.create(null); + const outbind = []; + const outbindParam = this.bindParam(outbind, inbindLength); + returningModelAttributes.forEach((element, index) => { + // generateReturnValues function quotes identifier based on the quoteIdentifier option + // If the identifier starts with a quote we remove it else we use it as is + if (element.startsWith('"')) { + element = element.substring(1, element.length - 1); + } + outBindAttributes[element] = Object.assign(returnTypes[index]._getBindDef(oracledb), { dir: oracledb.BIND_OUT }); + const returnAttribute = `${this.format(undefined, undefined, { context: 'INSERT' }, outbindParam)}`; + returnAttributes.push(returnAttribute); + }); + options.outBindAttributes = outBindAttributes; + } + + /** + * Override of upsertQuery, Oracle specific + * Using PL/SQL for finding the row + * + * @param {object|string} tableName + * @param {Array} insertValues + * @param {Array} updateValues + * @param {Array} where + * @param {object} model + * @param {object} options + */ + upsertQuery(tableName, insertValues, updateValues, where, model, options) { + const rawAttributes = model.rawAttributes; + const updateQuery = this.updateQuery(tableName, updateValues, where, options, rawAttributes); + // This bind is passed so that the insert query starts appending to this same bind array + options.bind = updateQuery.bind; + const insertQuery = this.insertQuery(tableName, insertValues, rawAttributes, options); + + const sql = [ + 'DECLARE ', + 'BEGIN ', + updateQuery.query ? [ + updateQuery.query, + '; ', + ' IF ( SQL%ROWCOUNT = 0 ) THEN ', + insertQuery.query, + ' :isUpdate := 0; ', + 'ELSE ', + ' :isUpdate := 1; ', + ' END IF; ' + ].join('') : [ + insertQuery.query, + ' :isUpdate := 0; ', + // If there is a conflict on insert we ignore + 'EXCEPTION WHEN OTHERS THEN', + ' IF SQLCODE != -1 THEN', + ' RAISE;', + ' END IF;' + ].join(''), + 'END;' + ]; + + const query = sql.join(''); + const result = { query }; + + if (options.bindParam !== false) { + result.bind = updateQuery.bind || insertQuery.bind; + } + + return result; + } + + /** + * Returns an insert into command for multiple values. + * + * @param {string} tableName + * @param {object} fieldValueHashes + * @param {object} options + * @param {object} fieldMappedAttributes + * + * @private + */ + bulkInsertQuery(tableName, fieldValueHashes, options, fieldMappedAttributes) { + options = options || {}; + options.executeMany = true; + fieldMappedAttributes = fieldMappedAttributes || {}; + + const tuples = []; + const allColumns = {}; + const inBindBindDefMap = {}; + const outBindBindDefMap = {}; + const oracledb = this.sequelize.connectionManager.lib; + + // Generating the allColumns map + // The data is provided as an array of objects. + // Each object may contain differing numbers of attributes. + // A set of the attribute names that are used in all objects must be determined. + // The allColumns map contains the column names and indicates whether the value is generated or not + // We set allColumns[key] to true if the field is an + // auto-increment field and the value given is null and fieldMappedAttributes[key] + // is valid for the specific column else it is set to false + for (const fieldValueHash of fieldValueHashes) { + _.forOwn(fieldValueHash, (value, key) => { + allColumns[key] = fieldMappedAttributes[key] && fieldMappedAttributes[key].autoIncrement === true && value === null; + }); + } + + // Building the inbind parameter + // A list that would have inbind positions like [:1, :2, :3...] to be used in generating sql string + let inBindPosition; + // Iterating over each row of the fieldValueHashes + for (const fieldValueHash of fieldValueHashes) { + // Has each column for a row after coverting it to appropriate format using this.format function + // like ['Mick', 'Broadstone', 2022-02-16T05:24:18.949Z, 2022-02-16T05:24:18.949Z], + const tuple = []; + // A function expression for this.bindParam/options.bindparam function + // This function is passed to this.format function which inserts column values to the tuple list + // using _bindParam/_stringify function in data-type.js file + const inbindParam = options.bindParam === undefined ? this.bindParam(tuple) : options.bindParam; + // We are iterating over each col + // and pushing the given values to tuple list using this.format function + // and also simultaneously generating the bindPosition + // tempBindPostions has the inbind positions + const tempBindPositions = Object.keys(allColumns).map(key => { + if (allColumns[key] === true) { + // We had set allAttributes[key] to true since at least one row for an auto increment column was null + // If we get any other row that has this specific column as non-null we must raise an error + // Since for an auto-increment column, either all row has to be null or all row has to be a non-null + if (fieldValueHash[key] !== null) { + throw Error('For an auto-increment column either all row must be null or non-null, a mix of null and non-null is not allowed!'); + } + // Return DEFAULT for auto-increment column and if all values for the column is null in each row + return 'DEFAULT'; + } + // Sanitizes the values given by the user and pushes it to the tuple list using inBindParam function and + // also generates the inbind position for the sql string for example (:1, :2, :3.....) which is a by product of the push + return this.format(fieldValueHash[key], fieldMappedAttributes[key], { context: 'INSERT' }, inbindParam); + }); + + // Even though the bind variable positions are calculated for each row we only retain the values for the first row + // since the values will be identical + if (!inBindPosition) { + inBindPosition = tempBindPositions; + } + // Adding the row to the array of rows that will be supplied to executeMany() + tuples.push(tuple); + } + + // The columns that we are expecting to be returned from the DB like ["id1", "id2"...] + const returnColumn = []; + // The outbind positions for the returning columns like [:3, :4, :5....] + const returnColumnBindPositions = []; + // Has the columns name in which data would be inserted like ["id", "name".....] + const insertColumns = []; + // Iterating over the allColumns keys to get the bindDef for inbind and outbinds + // and also to get the list of insert and return column after applying this.quoteIdentifier + for (const key of Object.keys(allColumns)) { + // If fieldMappenAttributes[attr] is defined we generate the bindDef + // and return clause else we can skip it + if (fieldMappedAttributes[key]) { + // BindDef for the specific column + const bindDef = fieldMappedAttributes[key].type._getBindDef(oracledb); + if (allColumns[key]) { + // Binddef for outbinds + bindDef.dir = oracledb.BIND_OUT; + outBindBindDefMap[key] = bindDef; + + // Building the outbind parameter list + // ReturnColumn has the column name for example "id", "usedId", quoting depends on quoteIdentifier option + returnColumn.push(this.quoteIdentifier(key)); + // Pushing the outbind index to the returnColumnPositions to generate (:3, :4, :5) + // The start offset depend on the tuple length (bind array size of a particular row) + // the outbind position starts after the position where inbind position ends + returnColumnBindPositions.push(`:${tuples[0].length + returnColumn.length}`); + } else { + // Binddef for inbinds + bindDef.dir = oracledb.BIND_IN; + inBindBindDefMap[key] = bindDef; + } + } + // Quoting and pushing each insert column based on quoteIdentifier option + insertColumns.push(this.quoteIdentifier(key)); + } + + // Generating the sql query + let query = Utils.joinSQLFragments([ + 'INSERT', + 'INTO', + // Table name for the table in which data needs to inserted + this.quoteTable(tableName), + // Columns names for the columns of the table (example "a", "b", "c" - quoting depends on the quoteidentifier option) + `(${insertColumns.join(',')})`, + 'VALUES', + // InBind position for the insert query (for example :1, :2, :3....) + `(${inBindPosition})` + ]); + + // If returnColumn.length is > 0 + // then the returning into clause is needed + if (returnColumn.length > 0) { + options.outBindAttributes = outBindBindDefMap; + query = Utils.joinSQLFragments([ + query, + 'RETURNING', + // List of return column (for example "id", "userId"....) + `${returnColumn.join(',')}`, + 'INTO', + // List of outbindPosition (for example :4, :5, :6....) + // Start offset depends on where inbindPosition end + `${returnColumnBindPositions}` + ]); + } + + // Binding the bind variable to result + const result = { query }; + // Binding the bindParam to result + // Tuple has each row for the insert query + result.bind = tuples; + // Setting options.inbindAttribute + options.inbindAttributes = inBindBindDefMap; + return result; + } + + truncateTableQuery(tableName) { + return `TRUNCATE TABLE ${this.quoteTable(tableName)}`; + } + + deleteQuery(tableName, where, options, model) { + options = options || {}; + + const table = tableName; + + where = this.getWhereConditions(where, null, model, options); + let queryTmpl; + // delete with limit and optional condition on Oracle: DELETE FROM WHERE rowid in (SELECT rowid FROM WHERE AND rownum <= ) + // Note that the condition has to be in the subquery; otherwise, the subquery would select arbitrary rows. + if (options.limit) { + const whereTmpl = where ? ` AND ${where}` : ''; + queryTmpl = + `DELETE FROM ${this.quoteTable(table)} WHERE rowid IN (SELECT rowid FROM ${this.quoteTable(table)} WHERE rownum <= ${this.escape(options.limit)}${ + whereTmpl + })`; + } else { + const whereTmpl = where ? ` WHERE ${where}` : ''; + queryTmpl = `DELETE FROM ${this.quoteTable(table)}${whereTmpl}`; + } + return queryTmpl; + } + + showIndexesQuery(table) { + const [tableName, owner] = this.getSchemaNameAndTableName(table); + const sql = [ + 'SELECT i.index_name,i.table_name, i.column_name, u.uniqueness, i.descend, c.constraint_type ', + 'FROM all_ind_columns i ', + 'INNER JOIN all_indexes u ', + 'ON (u.table_name = i.table_name AND u.index_name = i.index_name) ', + 'LEFT OUTER JOIN all_constraints c ', + 'ON (c.table_name = i.table_name AND c.index_name = i.index_name) ', + `WHERE i.table_name = ${this.escape(tableName)}`, + ' AND u.table_owner = ', + owner ? this.escape(owner) : 'USER', + ' ORDER BY index_name, column_position' + ]; + + return sql.join(''); + } + + removeIndexQuery(tableName, indexNameOrAttributes) { + let indexName = indexNameOrAttributes; + + if (typeof indexName !== 'string') { + indexName = Utils.underscore(`${tableName }_${indexNameOrAttributes.join('_')}`); + } + + return `DROP INDEX ${this.quoteIdentifier(indexName)}`; + } + + attributeToSQL(attribute, options) { + if (!_.isPlainObject(attribute)) { + attribute = { + type: attribute + }; + } + + // TODO: Address on update cascade issue whether to throw error or ignore. + // Add this to documentation when merging to sequelize-main + // ON UPDATE CASCADE IS NOT SUPPORTED BY ORACLE. + attribute.onUpdate = ''; + + // handle self referential constraints + if (attribute.references) { + if (attribute.Model && attribute.Model.tableName === attribute.references.model) { + this.sequelize.log( + 'Oracle does not support self referencial constraints, ' + + 'we will remove it but we recommend restructuring your query' + ); + attribute.onDelete = ''; + } + } + + let template; + + template = attribute.type.toSql ? attribute.type.toSql() : ''; + if (attribute.type instanceof DataTypes.JSON) { + template += ` CHECK (${this.quoteIdentifier(options.attributeName)} IS JSON)`; + return template; + } + if (Utils.defaultValueSchemable(attribute.defaultValue)) { + template += ` DEFAULT ${this.escape(attribute.defaultValue)}`; + } + if (attribute.allowNull === false) { + template += ' NOT NULL'; + } + if (attribute.type instanceof DataTypes.ENUM) { + if (attribute.type.values && !attribute.values) attribute.values = attribute.type.values; + // enums are a special case + template += + ` CHECK (${this.quoteIdentifier(options.attributeName)} IN(${ + _.map(attribute.values, value => { + return this.escape(value); + }).join(', ') + }))`; + return template; + } + if (attribute.type instanceof DataTypes.BOOLEAN) { + template += + ` CHECK (${this.quoteIdentifier(options.attributeName)} IN('1', '0'))`; + return template; + } + if (attribute.autoIncrement) { + template = ' NUMBER(*,0) GENERATED BY DEFAULT ON NULL AS IDENTITY'; + } else if (attribute.type && attribute.type.key === DataTypes.DOUBLE.key) { + template = attribute.type.toSql(); + } else if (attribute.type) { + // setting it to false because oracle doesn't support unsigned int so put a check to make it behave like unsigned int + let unsignedTemplate = ''; + if (attribute.type._unsigned) { + attribute.type._unsigned = false; + unsignedTemplate += ` check(${this.quoteIdentifier(options.attributeName)} >= 0)`; + } + template = attribute.type.toString(); + + // Blobs/texts cannot have a defaultValue + if ( + attribute.type && + attribute.type !== 'TEXT' && + attribute.type._binary !== true && + Utils.defaultValueSchemable(attribute.defaultValue) + ) { + template += ` DEFAULT ${this.escape(attribute.defaultValue)}`; + } + + if (!attribute.autoIncrement) { + // If autoincrement, not null is set automatically + if (attribute.allowNull === false) { + template += ' NOT NULL'; + } else if (!attribute.primaryKey && !Utils.defaultValueSchemable(attribute.defaultValue)) { + template += ' NULL'; + } + } + template += unsignedTemplate; + } else { + template = ''; + } + + if (attribute.unique === true && !attribute.primaryKey) { + template += ' UNIQUE'; + } + + if (attribute.primaryKey) { + template += ' PRIMARY KEY'; + } + + if ((!options || !options.withoutForeignKeyConstraints) && attribute.references) { + template += ` REFERENCES ${this.quoteTable(attribute.references.model)}`; + + if (attribute.references.key) { + template += ` (${this.quoteIdentifier(attribute.references.key) })`; + } else { + template += ` (${this.quoteIdentifier('id') })`; + } + + if (attribute.onDelete && attribute.onDelete.toUpperCase() !== 'NO ACTION') { + template += ` ON DELETE ${attribute.onDelete.toUpperCase()}`; + } + } + + return template; + } + attributesToSQL(attributes, options) { + const result = {}; + + for (const key in attributes) { + const attribute = attributes[key]; + const attributeName = attribute.field || key; + result[attributeName] = this.attributeToSQL(attribute, { attributeName, ...options }); + } + + return result; + } + + createTrigger() { + throwMethodUndefined('createTrigger'); + } + + dropTrigger() { + throwMethodUndefined('dropTrigger'); + } + + renameTrigger() { + throwMethodUndefined('renameTrigger'); + } + + createFunction() { + throwMethodUndefined('createFunction'); + } + + dropFunction() { + throwMethodUndefined('dropFunction'); + } + + renameFunction() { + throwMethodUndefined('renameFunction'); + } + + getConstraintsOnColumn(table, column) { + const [tableName, schemaName] = this.getSchemaNameAndTableName(table); + column = this.getCatalogName(column); + const sql = [ + 'SELECT CONSTRAINT_NAME FROM user_cons_columns WHERE TABLE_NAME = ', + this.escape(tableName), + ' and OWNER = ', + table.schema ? this.escape(schemaName) : 'USER', + ' and COLUMN_NAME = ', + this.escape(column), + ' AND POSITION IS NOT NULL ORDER BY POSITION' + ].join(''); + + return sql; + } + + getForeignKeysQuery(table) { + // We don't call quoteTable as we don't want the schema in the table name, Oracle seperates it on another field + const [tableName, schemaName] = this.getSchemaNameAndTableName(table); + const sql = [ + 'SELECT DISTINCT a.table_name "tableName", a.constraint_name "constraintName", a.owner "owner", a.column_name "columnName",', + ' b.table_name "referencedTableName", b.column_name "referencedColumnName"', + ' FROM all_cons_columns a', + ' JOIN all_constraints c ON a.owner = c.owner AND a.constraint_name = c.constraint_name', + ' JOIN all_cons_columns b ON c.owner = b.owner AND c.r_constraint_name = b.constraint_name', + " WHERE c.constraint_type = 'R'", + ' AND a.table_name = ', + this.escape(tableName), + ' AND a.owner = ', + table.schema ? this.escape(schemaName) : 'USER', + ' ORDER BY a.table_name, a.constraint_name' + ].join(''); + + return sql; + } + + dropForeignKeyQuery(tableName, foreignKey) { + return this.dropConstraintQuery(tableName, foreignKey); + } + + getPrimaryKeyConstraintQuery(table) { + const [tableName, schemaName] = this.getSchemaNameAndTableName(table); + const sql = [ + 'SELECT cols.column_name, atc.identity_column ', + 'FROM all_constraints cons, all_cons_columns cols ', + 'INNER JOIN all_tab_columns atc ON(atc.table_name = cols.table_name AND atc.COLUMN_NAME = cols.COLUMN_NAME )', + 'WHERE cols.table_name = ', + this.escape(tableName), + 'AND cols.owner = ', + table.schema ? this.escape(schemaName) : 'USER ', + "AND cons.constraint_type = 'P' ", + 'AND cons.constraint_name = cols.constraint_name ', + 'AND cons.owner = cols.owner ', + 'ORDER BY cols.table_name, cols.position' + ].join(''); + + return sql; + } + + dropConstraintQuery(tableName, constraintName) { + return `ALTER TABLE ${this.quoteTable(tableName)} DROP CONSTRAINT ${constraintName}`; + } + + setIsolationLevelQuery(value, options) { + if (options.parent) { + return; + } + + switch (value) { + case Transaction.ISOLATION_LEVELS.READ_UNCOMMITTED: + case Transaction.ISOLATION_LEVELS.READ_COMMITTED: + return 'SET TRANSACTION ISOLATION LEVEL READ COMMITTED;'; + case Transaction.ISOLATION_LEVELS.REPEATABLE_READ: + // Serializable mode is equal to Snapshot Isolation (SI) + // defined in ANSI std. + return 'SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;'; + default: + throw new Error(`isolation level "${value}" is not supported`); + } + } + + getAliasToken() { + return ''; + } + + startTransactionQuery(transaction) { + if (transaction.parent) { + return `SAVEPOINT ${this.quoteIdentifier(transaction.name)}`; + } + + return 'BEGIN TRANSACTION'; + } + + commitTransactionQuery(transaction) { + if (transaction.parent) { + return; + } + + return 'COMMIT TRANSACTION'; + } + + rollbackTransactionQuery(transaction) { + if (transaction.parent) { + return `ROLLBACK TO SAVEPOINT ${this.quoteIdentifier(transaction.name)}`; + } + + return 'ROLLBACK TRANSACTION'; + } + + handleSequelizeMethod(smth, tableName, factory, options, prepend) { + let str; + if (smth instanceof Utils.Json) { + // Parse nested object + if (smth.conditions) { + const conditions = this.parseConditionObject(smth.conditions).map(condition => + `${this.jsonPathExtractionQuery(condition.path[0], _.tail(condition.path))} = '${condition.value}'` + ); + + return conditions.join(' AND '); + } + if (smth.path) { + + // Allow specifying conditions using the sqlite json functions + if (this._checkValidJsonStatement(smth.path)) { + str = smth.path; + } else { + // Also support json property accessors + const paths = _.toPath(smth.path); + const column = paths.shift(); + str = this.jsonPathExtractionQuery(column, paths); + } + if (smth.value) { + str += util.format(' = %s', this.escape(smth.value)); + } + + return str; + } + } + if (smth instanceof Utils.Cast) { + if (smth.val instanceof Utils.SequelizeMethod) { + str = this.handleSequelizeMethod(smth.val, tableName, factory, options, prepend); + if (smth.type === 'boolean') { + str = `(CASE WHEN ${str}='true' THEN 1 ELSE 0 END)`; + return `CAST(${str} AS NUMBER)`; + } if (smth.type === 'timestamptz' && /json_value\(/.test(str)) { + str = str.slice(0, -1); + return `${str} RETURNING TIMESTAMP WITH TIME ZONE)`; + } + } + } + return super.handleSequelizeMethod(smth, tableName, factory, options, prepend); + } + + _checkValidJsonStatement(stmt) { + if (typeof stmt !== 'string') { + return false; + } + + let currentIndex = 0; + let openingBrackets = 0; + let closingBrackets = 0; + let hasJsonFunction = false; + let hasInvalidToken = false; + + while (currentIndex < stmt.length) { + const string = stmt.substr(currentIndex); + const functionMatches = JSON_FUNCTION_REGEX.exec(string); + if (functionMatches) { + currentIndex += functionMatches[0].indexOf('('); + hasJsonFunction = true; + continue; + } + + const operatorMatches = JSON_OPERATOR_REGEX.exec(string); + if (operatorMatches) { + currentIndex += operatorMatches[0].length; + hasJsonFunction = true; + continue; + } + + const tokenMatches = TOKEN_CAPTURE_REGEX.exec(string); + if (tokenMatches) { + const capturedToken = tokenMatches[1]; + if (capturedToken === '(') { + openingBrackets++; + } else if (capturedToken === ')') { + closingBrackets++; + } else if (capturedToken === ';') { + hasInvalidToken = true; + break; + } + currentIndex += tokenMatches[0].length; + continue; + } + + break; + } + + // Check invalid json statement + if (hasJsonFunction && (hasInvalidToken || openingBrackets !== closingBrackets)) { + throw new Error(`Invalid json statement: ${stmt}`); + } + + // return true if the statement has valid json function + return hasJsonFunction; + } + + jsonPathExtractionQuery(column, path) { + let paths = _.toPath(path); + const quotedColumn = this.isIdentifierQuoted(column) ? column : this.quoteIdentifier(column); + + paths = paths.map(subPath => { + return /\D/.test(subPath) ? Utils.addTicks(subPath, '"') : subPath; + }); + + const pathStr = this.escape(['$'].concat(paths).join('.').replace(/\.(\d+)(?:(?=\.)|$)/g, (__, digit) => `[${digit}]`)); + + return `json_value(${quotedColumn},${pathStr})`; + } + + addLimitAndOffset(options, model) { + let fragment = ''; + const offset = options.offset || 0, + isSubQuery = options.hasIncludeWhere || options.hasIncludeRequired || options.hasMultiAssociation; + + let orders = {}; + if (options.order) { + orders = this.getQueryOrders(options, model, isSubQuery); + } + + if (options.limit || options.offset) { + // Add needed order by clause only when it is not provided + if (!orders.mainQueryOrder || !orders.mainQueryOrder.length || isSubQuery && (!orders.subQueryOrder || !orders.subQueryOrder.length)) { + const tablePkFragment = `${this.quoteTable(options.tableAs || model.name)}.${this.quoteIdentifier(model.primaryKeyField)}`; + fragment += ` ORDER BY ${tablePkFragment}`; + } + + if (options.offset || options.limit) { + fragment += ` OFFSET ${this.escape(offset)} ROWS`; + } + + if (options.limit) { + fragment += ` FETCH NEXT ${this.escape(options.limit)} ROWS ONLY`; + } + } + + return fragment; + } + + booleanValue(value) { + return value ? 1 : 0; + } + + quoteIdentifier(identifier, force = false) { + const optForceQuote = force; + const optQuoteIdentifiers = this.options.quoteIdentifiers !== false; + const rawIdentifier = Utils.removeTicks(identifier, '"'); + const regExp = /^(([\w][\w\d_]*))$/g; + + if ( + optForceQuote !== true && + optQuoteIdentifiers === false && + regExp.test(rawIdentifier) && + !ORACLE_RESERVED_WORDS.includes(rawIdentifier.toUpperCase()) + ) { + // In Oracle, if tables, attributes or alias are created double-quoted, + // they are always case sensitive. If they contain any lowercase + // characters, they must always be double-quoted otherwise it + // would get uppercased by the DB. + // Here, we strip quotes if we don't want case sensitivity. + return rawIdentifier; + } + return Utils.addTicks(rawIdentifier, '"'); + } + + /** + * It causes bindbyPosition like :1, :2, :3 + * We pass the val parameter so that the outBind indexes + * starts after the inBind indexes end + * + * @param {Array} bind + * @param {number} posOffset + */ + bindParam(bind, posOffset = 0) { + return value => { + bind.push(value); + return `:${bind.length + posOffset}`; + }; + } + + /** + * Returns the authenticate test query string + */ + authTestQuery() { + return 'SELECT 1+1 AS result FROM DUAL'; + } +} + +/* istanbul ignore next */ +function throwMethodUndefined(methodName) { + throw new Error(`The method "${methodName}" is not defined! Please add it to your sql dialect.`); +} diff --git a/src/dialects/oracle/query-interface.js b/src/dialects/oracle/query-interface.js new file mode 100644 index 000000000000..ac188bbaae11 --- /dev/null +++ b/src/dialects/oracle/query-interface.js @@ -0,0 +1,85 @@ +// Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved + +'use strict'; +const { QueryInterface } = require('../abstract/query-interface'); +const QueryTypes = require('../../query-types'); + +const _ = require('lodash'); +/** + * The interface that Sequelize uses to talk with Oracle database + */ +export class OracleQueryInterface extends QueryInterface { + + /** + * Upsert + * + * @param {string} tableName table to upsert on + * @param {object} insertValues values to be inserted, mapped to field name + * @param {object} updateValues values to be updated, mapped to field name + * @param {object} where where conditions, which can be used for UPDATE part when INSERT fails + * @param {object} options query options + * + * @returns {Promise} Resolves an array with + */ + async upsert(tableName, insertValues, updateValues, where, options) { + options = { ...options }; + + const model = options.model; + const primaryKeys = Object.values(model.primaryKeys).map(item => item.field); + const uniqueKeys = Object.values(model.uniqueKeys).filter(c => c.fields.length > 0).map(c => c.fields); + const indexKeys = Object.values(model._indexes).filter(c => c.unique && c.fields.length > 0).map(c => c.fields); + + options.type = QueryTypes.UPSERT; + options.updateOnDuplicate = Object.keys(updateValues); + options.upsertKeys = []; + + // For fields in updateValues, try to find a constraint or unique index + // that includes given field. Only first matching upsert key is used. + for (const field of options.updateOnDuplicate) { + const uniqueKey = uniqueKeys.find(fields => fields.includes(field)); + if (uniqueKey) { + options.upsertKeys = uniqueKey; + break; + } + + const indexKey = indexKeys.find(fields => fields.includes(field)); + if (indexKey) { + options.upsertKeys = indexKey; + break; + } + } + + // Always use PK, if no constraint available OR update data contains PK + if ( + options.upsertKeys.length === 0 + || _.intersection(options.updateOnDuplicate, primaryKeys).length + ) { + options.upsertKeys = primaryKeys; + } + + options.upsertKeys = _.uniq(options.upsertKeys); + + let whereHasNull = false; + + primaryKeys.forEach(element => { + if (where[element] === null) { + whereHasNull = true; + } + }); + + if (whereHasNull === true) { + where = options.upsertKeys.reduce((result, attribute) => { + result[attribute] = insertValues[attribute]; + return result; + }, {}); + } + + const sql = this.queryGenerator.upsertQuery(tableName, insertValues, updateValues, where, model, options); + // we need set this to undefined otherwise sequelize would raise an error + // Error: Both `sql.bind` and `options.bind` cannot be set at the same time + if (sql.bind) { + options.bind = undefined; + } + return await this.sequelize.query(sql, options); + } +} diff --git a/src/dialects/oracle/query.js b/src/dialects/oracle/query.js new file mode 100644 index 000000000000..494b9a50822e --- /dev/null +++ b/src/dialects/oracle/query.js @@ -0,0 +1,675 @@ +// Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved + +'use strict'; + +const AbstractQuery = require('../abstract/query'); +const SequelizeErrors = require('../../errors'); +const parserStore = require('../parserStore')('oracle'); +const _ = require('lodash'); +const Utils = require('../../utils'); +const { logger } = require('../../utils/logger'); + +const debug = logger.debugContext('sql:oracle'); + +export class OracleQuery extends AbstractQuery { + constructor(connection, sequelize, options) { + super(connection, sequelize, options); + this.options = _.extend( + { + logging: console.log, + plain: false, + raw: false + }, + options || {} + ); + + this.checkLoggingOption(); + this.outFormat = options.outFormat || this.sequelize.connectionManager.lib.OBJECT; + } + + getInsertIdField() { + return 'id'; + } + + getExecOptions() { + const execOpts = { outFormat: this.outFormat, autoCommit: this.autoCommit }; + + // We set the oracledb + const oracledb = this.sequelize.connectionManager.lib; + + if (this.model && this.isSelectQuery()) { + const fInfo = {}; + const keys = Object.keys(this.model.tableAttributes); + for (const key of keys) { + const keyValue = this.model.tableAttributes[key]; + if (keyValue.type.key === 'DECIMAL') { + fInfo[key] = { type: oracledb.STRING }; + } + // Fetching BIGINT as string since, node-oracledb doesn't support JS BIGINT yet + if (keyValue.type.key === 'BIGINT') { + fInfo[key] = { type: oracledb.STRING }; + } + } + if ( fInfo ) { + execOpts.fetchInfo = fInfo; + } + } + return execOpts; + } + + /** + * convert binding values for unsupported + * types in connector library + * + * @param {string} bindingDictionary a string representing the key to scan + * @param {object} oracledb native oracle library + * @private + */ + _convertBindAttributes(bindingDictionary, oracledb) { + if (this.model && this.options[bindingDictionary]) { + // check against model if we have some BIGINT + const keys = Object.keys(this.model.tableAttributes); + for (const key of keys) { + const keyValue = this.model.tableAttributes[key]; + if (keyValue.type.key === 'BIGINT') { + const oldBinding = this.options[bindingDictionary][key]; + if (oldBinding) { + this.options[bindingDictionary][key] = { + ...oldBinding, + type: oracledb.STRING, + maxSize: 10000000 //TOTALLY ARBITRARY Number to prevent query failure + }; + } + } + } + } + } + + async run(sql, parameters) { + // We set the oracledb + const oracledb = this.sequelize.connectionManager.lib; + const complete = this._logQuery(sql, debug, parameters); + const outParameters = []; + const bindParameters = []; + const bindDef = []; + + if (!sql.match(/END;$/)) { + this.sql = sql.replace(/; *$/, ''); + } else { + this.sql = sql; + } + + // When this.options.bindAttributes exists then it is an insertQuery/upsertQuery + // So we insert the return bind direction and type + if (this.options.outBindAttributes && (Array.isArray(parameters) || _.isPlainObject(parameters))) { + this._convertBindAttributes('outBindAttributes', oracledb); + outParameters.push(...Object.values(this.options.outBindAttributes)); + // For upsertQuery we need to push the bindDef for isUpdate + if (this.isUpsertQuery()) { + outParameters.push({ dir: oracledb.BIND_OUT }); + } + } + + this.bindParameters = outParameters; + // construct input binds from parameters for single row insert execute call + // ex: [3, 4,...] + if (Array.isArray(parameters) || _.isPlainObject(parameters)) { + if (this.options.executeMany) { + // Constructing BindDefs for ExecuteMany call + // Building the bindDef for in and out binds + this._convertBindAttributes('inbindAttributes', oracledb); + bindDef.push(...Object.values(this.options.inbindAttributes)); + bindDef.push(...outParameters); + this.bindParameters = parameters; + } else if (this.isRawQuery()) { + this.bindParameters = parameters; + } else { + Object.values(parameters).forEach(value => { + bindParameters.push(value); + }); + bindParameters.push(...outParameters); + Object.assign(this.bindParameters, bindParameters); + } + } + + // TRANSACTION SUPPORT + if (this.sql.startsWith('BEGIN TRANSACTION')) { + this.autocommit = false; + return Promise.resolve(); + } + if (this.sql.startsWith('SET AUTOCOMMIT ON')) { + this.autocommit = true; + return Promise.resolve(); + } + if (this.sql.startsWith('SET AUTOCOMMIT OFF')) { + this.autocommit = false; + return Promise.resolve(); + } + if (this.sql.startsWith('DECLARE x NUMBER')) { + // Calling a stored procedure for bulkInsert with NO attributes, returns nothing + if (this.autoCommit === undefined) { + if (this.connection.uuid) { + this.autoCommit = false; + } else { + this.autoCommit = true; + } + } + + try { + await this.connection.execute(this.sql, this.bindParameters, { autoCommit: this.autoCommit }); + return Object.create(null); + } catch (error) { + throw this.formatError(error); + } finally { + complete(); + } + } + if (this.sql.startsWith('BEGIN')) { + // Call to stored procedures - BEGIN TRANSACTION has been treated before + if (this.autoCommit === undefined) { + if (this.connection.uuid) { + this.autoCommit = false; + } else { + this.autoCommit = true; + } + } + + try { + const result = await this.connection.execute(this.sql, this.bindParameters, { + outFormat: this.outFormat, + autoCommit: this.autoCommit + }); + if (!Array.isArray(result.outBinds)) { + return [result.outBinds]; + } + return result.outBinds; + } catch (error) { + throw this.formatError(error); + } finally { + complete(); + } + } + if (this.sql.startsWith('COMMIT TRANSACTION')) { + try { + await this.connection.commit(); + return Object.create(null); + } catch (error) { + throw this.formatError(error); + } finally { + complete(); + } + } + if (this.sql.startsWith('ROLLBACK TRANSACTION')) { + try { + await this.connection.rollback(); + return Object.create(null); + } catch (error) { + throw this.formatError(error); + } finally { + complete(); + } + } + if (this.sql.startsWith('SET TRANSACTION')) { + try { + await this.connection.execute(this.sql, [], { autoCommit: false }); + return Object.create(null); + } catch (error) { + throw this.formatError(error); + } finally { + complete(); + } + } + // QUERY SUPPORT + // As Oracle does everything in transaction, if autoCommit is not defined, we set it to true + if (this.autoCommit === undefined) { + if (this.connection.uuid) { + this.autoCommit = false; + } else { + this.autoCommit = true; + } + } + + // inbind parameters added byname. merge them + if ('inputParameters' in this.options && this.options.inputParameters !== null) { + Object.assign(this.bindParameters, this.options.inputParameters); + } + const execOpts = this.getExecOptions(); + if (this.options.executeMany && bindDef.length > 0) { + execOpts.bindDefs = bindDef; + } + const executePromise = this.options.executeMany ? this.connection.executeMany(this.sql, this.bindParameters, execOpts) : this.connection.execute(this.sql, this.bindParameters, execOpts); + try { + const result = await executePromise; + return this.formatResults(result); + } catch (error) { + throw this.formatError(error); + } finally { + complete(); + } + } + + /** + * The parameters to query.run function are built here + * + * @param {string} sql + * @param {Array} values + * @param {string} dialect + */ + static formatBindParameters(sql, values, dialect) { + + const replacementFunc = (match, key, values) => { + if (values[key] !== undefined) { + return `:${key}`; + } + return undefined; + }; + sql = AbstractQuery.formatBindParameters(sql, values, dialect, replacementFunc)[0]; + + return [sql, values]; + } + + /** + * Building the attribute map by matching the column names received + * from DB and the one in rawAttributes + * to sequelize format + * + * @param {object} attrsMap + * @param {object} rawAttributes + * @private + */ + _getAttributeMap(attrsMap, rawAttributes) { + attrsMap = Object.assign(attrsMap, _.reduce(rawAttributes, (mp, _, key) => { + const catalogKey = this.sequelize.queryInterface.queryGenerator.getCatalogName(key); + mp[catalogKey] = key; + return mp; + }, {})); + } + + /** + * Process rows received from the DB. + * Use parse function to parse the returned value + * to sequelize format + * + * @param {Array} rows + * @private + */ + _processRows(rows) { + let result = rows; + let attrsMap = {}; + + // When quoteIdentifiers is false we need to map the DB column names + // To the one in attribute list + if (this.sequelize.options.quoteIdentifiers === false) { + // Building the attribute map from this.options.attributes + // Needed in case of an aggregate function + attrsMap = _.reduce(this.options.attributes, (mp, v) => { + // Aggregate function is of form + // Fn {fn: 'min', min}, so we have the name in index one of the object + if (typeof v === 'object') { + v = v[1]; + } + const catalogv = this.sequelize.queryInterface.queryGenerator.getCatalogName(v); + mp[catalogv] = v; + return mp; + }, {}); + + + // Building the attribute map by matching the column names received + // from DB and the one in model.rawAttributes + if (this.model) { + this._getAttributeMap(attrsMap, this.model.rawAttributes); + } + + // If aliasesmapping exists we update the attribute map + if (this.options.aliasesMapping) { + const obj = Object.fromEntries(this.options.aliasesMapping); + rows = rows + .map(row => _.toPairs(row) + .reduce((acc, [key, value]) => { + const mapping = Object.values(obj).find(element => { + const catalogElement = this.sequelize.queryInterface.queryGenerator.getCatalogName(element); + return catalogElement === key; + }); + if (mapping) + acc[mapping || key] = value; + return acc; + }, {}) + ); + } + + // Modify the keys into the format that sequelize expects + result = rows.map(row => { + return _.mapKeys(row, (value, key) => { + const targetAttr = attrsMap[key]; + if (typeof targetAttr === 'string' && targetAttr !== key) { + return targetAttr; + } + return key; + }); + }); + } + + // We parse the value received from the DB based on its datatype + if (this.model) { + result = result.map(row => { + return _.mapValues(row, (value, key) => { + if (this.model.rawAttributes[key] && this.model.rawAttributes[key].type) { + let typeid = this.model.rawAttributes[key].type.toLocaleString(); + if (this.model.rawAttributes[key].type.key === 'JSON') { + value = JSON.parse(value); + } + // For some types, the "name" of the type is returned with the length, we remove it + // For Boolean we skip this because BOOLEAN is mapped to CHAR(1) and we dont' want to + // remove the (1) for BOOLEAN + if (typeid.indexOf('(') > -1 && this.model.rawAttributes[key].type.key !== 'BOOLEAN') { + typeid = typeid.substr(0, typeid.indexOf('(')); + } + const parse = parserStore.get(typeid); + if (value !== null & !!parse) { + value = parse(value); + } + } + return value; + }); + }); + } + + return result; + } + + /** + * High level function that handles the results of a query execution. + * Example: + * Oracle format : + * { rows: //All rows + [ [ 'Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production' ], + [ 'PL/SQL Release 11.2.0.1.0 - Production' ], + [ 'CORE\t11.2.0.1.0\tProduction' ], + [ 'TNS for 64-bit Windows: Version 11.2.0.1.0 - Production' ], + [ 'NLSRTL Version 11.2.0.1.0 - Production' ] ], + resultSet: undefined, + outBinds: undefined, //Used for dbms_put.line + rowsAffected: undefined, //Number of rows affected + metaData: [ { name: 'BANNER' } ] } + * + * @param {Array} data - The result of the query execution. + */ + formatResults(data) { + let result = this.instance; + if (this.isInsertQuery(data)) { + let insertData; + if (data.outBinds) { + const keys = Object.keys(this.options.outBindAttributes); + insertData = data.outBinds; + // For one row insert out bind array is 1D array + // we convert it to 2D array for uniformity + if (this.instance) { + insertData = [insertData]; + } + // Mapping the bind parameter to their values + const res = insertData.map(row =>{ + const obj = {}; + row.forEach((element, index) =>{ + obj[keys[index]] = element[0]; + }); + return obj; + }); + insertData = res; + // For bulk insert this.insert is undefined + // we map result to res, for one row insert + // result needs to be this.instance + if (!this.instance) { + result = res; + } + } + this.handleInsertQuery(insertData); + return [result, data.rowsAffected]; + } + if (this.isShowTablesQuery()) { + result = this.handleShowTablesQuery(data.rows); + } else if (this.isDescribeQuery()) { + result = {}; + // Getting the table name on which we are doing describe query + const table = Object.keys(this.sequelize.models); + const modelAttributes = {}; + // Get the model raw attributes + if (this.sequelize.models && table.length > 0) { + this._getAttributeMap(modelAttributes, this.sequelize.models[table[0]].rawAttributes); + } + data.rows.forEach(_result => { + if (_result.Default) { + _result.Default = _result.Default.replace("('", '') + .replace("')", '') + .replace(/'/g, ''); /* jshint ignore: line */ + } + + if (!(modelAttributes[_result.COLUMN_NAME] in result)) { + let key = modelAttributes[_result.COLUMN_NAME]; + if (!key) { + key = _result.COLUMN_NAME; + } + + result[key] = { + type: _result.DATA_TYPE.toUpperCase(), + allowNull: _result.NULLABLE === 'N' ? false : true, + defaultValue: undefined, + primaryKey: _result.CONSTRAINT_TYPE === 'P' + }; + } + }); + } else if (this.isShowIndexesQuery()) { + result = this.handleShowIndexesQuery(data.rows); + } else if (this.isSelectQuery()) { + const rows = data.rows; + const result = this._processRows(rows); + return this.handleSelectQuery(result); + } else if (this.isCallQuery()) { + result = data.rows[0]; + } else if (this.isUpdateQuery()) { + result = [result, data.rowsAffected]; + } else if (this.isBulkUpdateQuery()) { + result = data.rowsAffected; + } else if (this.isBulkDeleteQuery()) { + result = data.rowsAffected; + } else if (this.isVersionQuery()) { + const version = data.rows[0].VERSION_FULL; + if (version) { + const versions = version.split('.'); + result = `${versions[0]}.${versions[1]}.${versions[2]}`; + } else { + result = '0.0.0'; + } + } else if (this.isForeignKeysQuery()) { + result = data.rows; + } else if (this.isUpsertQuery()) { + // Upsert Query, will return nothing + data = data.outBinds; + const keys = Object.keys(this.options.outBindAttributes); + const obj = {}; + for (const k in keys) { + obj[keys[k]] = data[k]; + } + obj.isUpdate = data[data.length - 1]; + data = obj; + result = [{ isNewRecord: data.isUpdate, value: data }, data.isUpdate == 0]; + } else if (this.isShowConstraintsQuery()) { + result = this.handleShowConstraintsQuery(data); + } else if (this.isRawQuery()) { + // If data.rows exists then it is a select query + // Hence we would have two components + // metaData and rows and we return them + // as [data.rows, data.metaData] + // Else it is result of update/upsert/insert query + // and it has no rows so we return [data, data] + if (data && data.rows) { + return [data.rows, data.metaData]; + } + return [data, data]; + } + + return result; + } + + handleShowConstraintsQuery(data) { + // Convert snake_case keys to camelCase as its generated by stored procedure + return data.rows.map(result => { + const constraint = {}; + for (const key in result) { + constraint[_.camelCase(key)] = result[key].toLowerCase(); + } + return constraint; + }); + } + + handleShowTablesQuery(results) { + return results.map(resultSet => { + return { + tableName: resultSet.TABLE_NAME, + schema: resultSet.TABLE_SCHEMA + }; + }); + } + + formatError(err) { + let match; + // ORA-00001: unique constraint (USER.XXXXXXX) violated + match = err.message.match(/unique constraint ([\s\S]*) violated/); + if (match && match.length > 1) { + match[1] = match[1].replace('(', '').replace(')', '').split('.')[1]; // As we get (SEQUELIZE.UNIQNAME), we replace to have UNIQNAME + const errors = []; + let fields = [], + message = 'Validation error', + uniqueKey = null; + + if (this.model) { + const uniqueKeys = Object.keys(this.model.uniqueKeys); + + const currKey = uniqueKeys.find(key => { + // We check directly AND with quotes -> "a"" === a || "a" === "a" + return key.toUpperCase() === match[1].toUpperCase() || key.toUpperCase() === `"${match[1].toUpperCase()}"`; + }); + + if (currKey) { + uniqueKey = this.model.uniqueKeys[currKey]; + fields = uniqueKey.fields; + } + + if (uniqueKey && !!uniqueKey.msg) { + message = uniqueKey.msg; + } + + fields.forEach(field => { + errors.push( + new SequelizeErrors.ValidationErrorItem( + this.getUniqueConstraintErrorMessage(field), + 'unique violation', + field, + null + ) + ); + }); + } + + return new SequelizeErrors.UniqueConstraintError({ + message, + errors, + err, + fields + }); + } + + // ORA-02291: integrity constraint (string.string) violated - parent key not found / ORA-02292: integrity constraint (string.string) violated - child record found + match = err.message.match(/ORA-02291/) || err.message.match(/ORA-02292/); + if (match && match.length > 0) { + return new SequelizeErrors.ForeignKeyConstraintError({ + fields: null, + index: match[1], + parent: err + }); + } + + // ORA-02443: Cannot drop constraint - nonexistent constraint + match = err.message.match(/ORA-02443/); + if (match && match.length > 0) { + return new SequelizeErrors.UnknownConstraintError(match[1]); + } + + return new SequelizeErrors.DatabaseError(err); + } + + isShowIndexesQuery() { + return this.sql.indexOf('SELECT i.index_name,i.table_name, i.column_name, u.uniqueness') > -1; + } + + isSelectCountQuery() { + return this.sql.toUpperCase().indexOf('SELECT COUNT(') > -1; + } + + handleShowIndexesQuery(data) { + const acc = []; + + // We first treat the datas + data.forEach(indexRecord => { + // We create the object + if (!acc[indexRecord.INDEX_NAME]) { + acc[indexRecord.INDEX_NAME] = { + unique: indexRecord.UNIQUENESS === 'UNIQUE' ? true : false, + primary: indexRecord.CONSTRAINT_TYPE === 'P', + name: indexRecord.INDEX_NAME.toLowerCase(), + tableName: indexRecord.TABLE_NAME.toLowerCase(), + type: undefined + }; + acc[indexRecord.INDEX_NAME].fields = []; + } + + // We create the fields + acc[indexRecord.INDEX_NAME].fields.push({ + attribute: indexRecord.COLUMN_NAME, + length: undefined, + order: indexRecord.DESCEND, + collate: undefined + }); + }); + + const returnIndexes = []; + const accKeys = Object.keys(acc); + for (const accKey of accKeys) { + const columns = {}; + columns.fields = acc[accKey].fields; + // We are generating index field name in the format sequelize expects + // to avoid creating a unique index on auto-generated index name + if (acc[accKey].name.match(/sys_c[0-9]*/)) { + acc[accKey].name = Utils.nameIndex(columns, acc[accKey].tableName).name; + } + returnIndexes.push(acc[accKey]); + } + return returnIndexes; + } + + handleInsertQuery(results, metaData) { + if (this.instance && results.length > 0) { + if ('pkReturnVal' in results[0]) { + // The PK of the table is a reserved word (ex : uuid), we have to change the name in the result for the model to find the value correctly + results[0][this.model.primaryKeyAttribute] = results[0].pkReturnVal; + delete results[0].pkReturnVal; + } + // add the inserted row id to the instance + const autoIncrementField = this.model.autoIncrementAttribute; + let autoIncrementFieldAlias = null, + id = null; + + if ( + Object.prototype.hasOwnProperty.call(this.model.rawAttributes, autoIncrementField) && + this.model.rawAttributes[autoIncrementField].field !== undefined + ) + autoIncrementFieldAlias = this.model.rawAttributes[autoIncrementField].field; + + id = id || results && results[0][this.getInsertIdField()]; + id = id || metaData && metaData[this.getInsertIdField()]; + id = id || results && results[0][autoIncrementField]; + id = id || autoIncrementFieldAlias && results && results[0][autoIncrementFieldAlias]; + + this.instance[autoIncrementField] = id; + } + } +} diff --git a/lib/dialects/parserStore.js b/src/dialects/parserStore.js similarity index 100% rename from lib/dialects/parserStore.js rename to src/dialects/parserStore.js diff --git a/lib/dialects/postgres/connection-manager.js b/src/dialects/postgres/connection-manager.js similarity index 96% rename from lib/dialects/postgres/connection-manager.js rename to src/dialects/postgres/connection-manager.js index f60b67df9d4e..b6dad3984531 100644 --- a/lib/dialects/postgres/connection-manager.js +++ b/src/dialects/postgres/connection-manager.js @@ -117,11 +117,18 @@ class ConnectionManager extends AbstractConnectionManager { 'statement_timeout', // Times out queries after a set time in milliseconds in client end, query would be still running in database end. 'query_timeout', + // Number of milliseconds to wait for connection, default is no timeout. + 'connectionTimeoutMillis', // Terminate any session with an open transaction that has been idle for longer than the specified duration in milliseconds. Added in pg v7.17.0 only supported in postgres >= 10 'idle_in_transaction_session_timeout', + // Maximum wait time for lock requests in milliseconds. Added in pg v8.8.0. + 'lock_timeout', // Postgres allows additional session variables to be configured in the connection string in the `options` param. // see [https://www.postgresql.org/docs/14/libpq-connect.html#LIBPQ-CONNECT-OPTIONS] - 'options' + 'options', + // The stream acts as a user-defined socket factory for postgres. In particular, it enables IAM autentication + // with Google Cloud SQL. see: https://github.com/sequelize/sequelize/issues/16001#issuecomment-1561136388 + 'stream' ])); } @@ -200,6 +207,13 @@ class ConnectionManager extends AbstractConnectionManager { }); }); + // Don't let a Postgres restart (or error) to take down the whole app + connection.on('error', error => { + connection._invalid = true; + debug(`connection error ${error.code || error.message}`); + this.pool.destroy(connection); + }); + let query = ''; if (this.sequelize.options.standardConformingStrings !== false && connection['standard_conforming_strings'] !== 'on') { @@ -240,12 +254,6 @@ class ConnectionManager extends AbstractConnectionManager { this.enumOids.arrayOids.length === 0) { await this._refreshDynamicOIDs(connection); } - // Don't let a Postgres restart (or error) to take down the whole app - connection.on('error', error => { - connection._invalid = true; - debug(`connection error ${error.code || error.message}`); - this.pool.destroy(connection); - }); return connection; } diff --git a/lib/dialects/postgres/data-types.js b/src/dialects/postgres/data-types.js similarity index 100% rename from lib/dialects/postgres/data-types.js rename to src/dialects/postgres/data-types.js diff --git a/lib/dialects/postgres/hstore.js b/src/dialects/postgres/hstore.js similarity index 100% rename from lib/dialects/postgres/hstore.js rename to src/dialects/postgres/hstore.js diff --git a/lib/dialects/postgres/index.js b/src/dialects/postgres/index.js similarity index 85% rename from lib/dialects/postgres/index.js rename to src/dialects/postgres/index.js index eb1cd3e27234..c754d1c0f61a 100644 --- a/lib/dialects/postgres/index.js +++ b/src/dialects/postgres/index.js @@ -22,6 +22,14 @@ class PostgresDialect extends AbstractDialect { this.queryGenerator ); } + + canBackslashEscape() { + // postgres can use \ to escape if one of these is true: + // - standard_conforming_strings is off + // - the string is prefixed with E (out of scope for this method) + + return !this.sequelize.options.standardConformingStrings; + } } PostgresDialect.prototype.supports = _.merge( @@ -52,7 +60,8 @@ PostgresDialect.prototype.supports = _.merge( inserts: { onConflictDoNothing: ' ON CONFLICT DO NOTHING', updateOnDuplicate: ' ON CONFLICT DO UPDATE SET', - conflictFields: true + conflictFields: true, + onConflictWhere: true }, NUMERIC: true, ARRAY: true, @@ -65,7 +74,8 @@ PostgresDialect.prototype.supports = _.merge( HSTORE: true, TSVECTOR: true, deferrableConstraints: true, - searchPath: true + searchPath: true, + escapeStringConstants: true } ); diff --git a/lib/dialects/postgres/query-generator.js b/src/dialects/postgres/query-generator.js similarity index 95% rename from lib/dialects/postgres/query-generator.js rename to src/dialects/postgres/query-generator.js index 7ee3e0b621da..0cf9370ac164 100644 --- a/lib/dialects/postgres/query-generator.js +++ b/src/dialects/postgres/query-generator.js @@ -46,14 +46,14 @@ class PostgresQueryGenerator extends AbstractQueryGenerator { const databaseVersion = _.get(this, 'sequelize.options.databaseVersion', 0); if (databaseVersion && semver.gte(databaseVersion, '9.2.0')) { - return `CREATE SCHEMA IF NOT EXISTS ${schema};`; + return `CREATE SCHEMA IF NOT EXISTS ${this.quoteIdentifier(schema)};`; } - return `CREATE SCHEMA ${schema};`; + return `CREATE SCHEMA ${this.quoteIdentifier(schema)};`; } dropSchema(schema) { - return `DROP SCHEMA IF EXISTS ${schema} CASCADE;`; + return `DROP SCHEMA IF EXISTS ${this.quoteIdentifier(schema)} CASCADE;`; } showSchemasQuery() { @@ -124,11 +124,20 @@ class PostgresQueryGenerator extends AbstractQueryGenerator { } showTablesQuery() { - return "SELECT table_name FROM information_schema.tables WHERE table_schema = 'public' AND table_type LIKE '%TABLE' AND table_name != 'spatial_ref_sys';"; + const schema = this.options.schema || 'public'; + + return `SELECT table_name FROM information_schema.tables WHERE table_schema = ${this.escape(schema)} AND table_type LIKE '%TABLE' AND table_name != 'spatial_ref_sys';`; + } + + tableExistsQuery(tableName) { + const table = tableName.tableName || tableName; + const schema = tableName.schema || 'public'; + + return `SELECT table_name FROM information_schema.tables WHERE table_schema = ${this.escape(schema)} AND table_name = ${this.escape(table)}`; } describeTableQuery(tableName, schema) { - if (!schema) schema = 'public'; + schema = schema || this.options.schema || 'public'; return 'SELECT ' + 'pk.constraint_type as "Constraint",' + @@ -149,7 +158,7 @@ class PostgresQueryGenerator extends AbstractQueryGenerator { 'ON pk.table_schema=c.table_schema ' + 'AND pk.table_name=c.table_name ' + 'AND pk.column_name=c.column_name ' + - `WHERE c.table_name = ${this.escape(tableName)} AND c.table_schema = ${this.escape(schema)} `; + `WHERE c.table_name = ${this.escape(tableName)} AND c.table_schema = ${this.escape(schema)}`; } /** @@ -524,24 +533,26 @@ class PostgresQueryGenerator extends AbstractQueryGenerator { let referencesKey; - if (attribute.references.key) { - referencesKey = this.quoteIdentifiers(attribute.references.key); - } else { - referencesKey = this.quoteIdentifier('id'); - } + if (!options.withoutForeignKeyConstraints) { + if (attribute.references.key) { + referencesKey = this.quoteIdentifiers(attribute.references.key); + } else { + referencesKey = this.quoteIdentifier('id'); + } - sql += ` REFERENCES ${referencesTable} (${referencesKey})`; + sql += ` REFERENCES ${referencesTable} (${referencesKey})`; - if (attribute.onDelete) { - sql += ` ON DELETE ${attribute.onDelete.toUpperCase()}`; - } + if (attribute.onDelete) { + sql += ` ON DELETE ${attribute.onDelete.toUpperCase()}`; + } - if (attribute.onUpdate) { - sql += ` ON UPDATE ${attribute.onUpdate.toUpperCase()}`; - } + if (attribute.onUpdate) { + sql += ` ON UPDATE ${attribute.onUpdate.toUpperCase()}`; + } - if (attribute.references.deferrable) { - sql += ` ${attribute.references.deferrable.toString(this)}`; + if (attribute.references.deferrable) { + sql += ` ${attribute.references.deferrable.toString(this)}`; + } } } @@ -772,7 +783,7 @@ class PostgresQueryGenerator extends AbstractQueryGenerator { values = dataType.toString().match(/^ENUM\(.+\)/)[0]; } - let sql = `CREATE TYPE ${enumName} AS ${values};`; + let sql = `DO ${this.escape(`BEGIN CREATE TYPE ${enumName} AS ${values}; EXCEPTION WHEN duplicate_object THEN null; END`)};`; if (!!options && options.force === true) { sql = this.pgEnumDrop(tableName, attr) + sql; } @@ -865,6 +876,8 @@ class PostgresQueryGenerator extends AbstractQueryGenerator { 'tc.table_name as table_name,' + 'tc.table_schema as table_schema,' + 'tc.table_catalog as table_catalog,' + + 'tc.initially_deferred as initially_deferred,' + + 'tc.is_deferrable as is_deferrable,' + 'kcu.column_name as column_name,' + 'ccu.table_schema AS referenced_table_schema,' + 'ccu.table_catalog AS referenced_table_catalog,' + diff --git a/lib/dialects/postgres/query-interface.js b/src/dialects/postgres/query-interface.js similarity index 94% rename from lib/dialects/postgres/query-interface.js rename to src/dialects/postgres/query-interface.js index 19a07e467564..b13fe3ec25f8 100644 --- a/lib/dialects/postgres/query-interface.js +++ b/src/dialects/postgres/query-interface.js @@ -4,6 +4,7 @@ const DataTypes = require('../../data-types'); const QueryTypes = require('../../query-types'); const { QueryInterface } = require('../abstract/query-interface'); const Utils = require('../../utils'); +const Deferrable = require('../../deferrable'); /** * The interface that Sequelize uses to talk with Postgres database @@ -156,9 +157,19 @@ class PostgresQueryInterface extends QueryInterface { // postgres needs some special treatment as those field names returned are all lowercase // in order to keep same result with other dialects. - const query = this.queryGenerator.getForeignKeyReferencesQuery(table.tableName || table, this.sequelize.config.database); + const query = this.queryGenerator.getForeignKeyReferencesQuery(table.tableName || table, this.sequelize.config.database, table.schema); const result = await this.sequelize.query(query, queryOptions); - return result.map(Utils.camelizeObjectKeys); + + return result.map(fkMeta => { + const { initiallyDeferred, isDeferrable, ...remaining } = Utils.camelizeObjectKeys(fkMeta); + + return { + ...remaining, + deferrable: isDeferrable === 'NO' ? Deferrable.NOT + : initiallyDeferred === 'NO' ? Deferrable.INITIALLY_IMMEDIATE + : Deferrable.INITIALLY_DEFERRED + }; + }); } /** diff --git a/lib/dialects/postgres/query.js b/src/dialects/postgres/query.js similarity index 95% rename from lib/dialects/postgres/query.js rename to src/dialects/postgres/query.js index 8d63110340b2..70e330becf1d 100644 --- a/lib/dialects/postgres/query.js +++ b/src/dialects/postgres/query.js @@ -77,15 +77,23 @@ class Query extends AbstractQuery { try { queryResult = await query; - } catch (err) { + } catch (error) { // set the client so that it will be reaped if the connection resets while executing - if (err.code === 'ECONNRESET') { + if (error.code === 'ECONNRESET' + // https://github.com/sequelize/sequelize/pull/14090 + // pg-native throws custom exception or libpq formatted errors + || /Unable to set non-blocking to true/i.test(error) + || /SSL SYSCALL error: EOF detected/i.test(error) + || /Local: Authentication failure/i.test(error) + // https://github.com/sequelize/sequelize/pull/15144 + || error.message === 'Query read timeout' + ) { connection._invalid = true; } - err.sql = sql; - err.parameters = parameters; - throw this.formatError(err, errForStack.stack); + error.sql = sql; + error.parameters = parameters; + throw this.formatError(error, errForStack.stack); } complete(); diff --git a/lib/dialects/postgres/range.js b/src/dialects/postgres/range.js similarity index 100% rename from lib/dialects/postgres/range.js rename to src/dialects/postgres/range.js diff --git a/lib/dialects/snowflake/connection-manager.js b/src/dialects/snowflake/connection-manager.js similarity index 100% rename from lib/dialects/snowflake/connection-manager.js rename to src/dialects/snowflake/connection-manager.js diff --git a/lib/dialects/snowflake/data-types.js b/src/dialects/snowflake/data-types.js similarity index 100% rename from lib/dialects/snowflake/data-types.js rename to src/dialects/snowflake/data-types.js diff --git a/lib/dialects/snowflake/index.js b/src/dialects/snowflake/index.js similarity index 100% rename from lib/dialects/snowflake/index.js rename to src/dialects/snowflake/index.js diff --git a/lib/dialects/snowflake/query-generator.js b/src/dialects/snowflake/query-generator.js similarity index 98% rename from lib/dialects/snowflake/query-generator.js rename to src/dialects/snowflake/query-generator.js index 91851c22c45d..6db85321213a 100644 --- a/lib/dialects/snowflake/query-generator.js +++ b/src/dialects/snowflake/query-generator.js @@ -32,7 +32,7 @@ const FOREIGN_KEY_FIELDS = [ * @private */ const SNOWFLAKE_RESERVED_WORDS = 'account,all,alter,and,any,as,between,by,case,cast,check,column,connect,connections,constraint,create,cross,current,current_date,current_time,current_timestamp,current_user,database,delete,distinct,drop,else,exists,false,following,for,from,full,grant,group,gscluster,having,ilike,in,increment,inner,insert,intersect,into,is,issue,join,lateral,left,like,localtime,localtimestamp,minus,natural,not,null,of,on,or,order,organization,qualify,regexp,revoke,right,rlike,row,rows,sample,schema,select,set,some,start,table,tablesample,then,to,trigger,true,try_cast,union,unique,update,using,values,view,when,whenever,where,with'.split(','); - + const typeWithoutDefault = new Set(['BLOB', 'TEXT', 'GEOMETRY', 'JSON']); class SnowflakeQueryGenerator extends AbstractQueryGenerator { @@ -170,6 +170,18 @@ class SnowflakeQueryGenerator extends AbstractQueryGenerator { ]); } + tableExistsQuery(table) { + const tableName = table.tableName || table; + const schema = table.schema; + + return Utils.joinSQLFragments([ + 'SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = \'BASE TABLE\'', + `AND TABLE_SCHEMA = ${schema !== undefined ? this.escape(schema) : 'CURRENT_SCHEMA()'}`, + `AND TABLE_NAME = ${this.escape(tableName)}`, + ';' + ]); + } + addColumnQuery(table, key, dataType) { return Utils.joinSQLFragments([ 'ALTER TABLE', diff --git a/lib/dialects/snowflake/query-interface.js b/src/dialects/snowflake/query-interface.js similarity index 100% rename from lib/dialects/snowflake/query-interface.js rename to src/dialects/snowflake/query-interface.js diff --git a/lib/dialects/snowflake/query.js b/src/dialects/snowflake/query.js similarity index 100% rename from lib/dialects/snowflake/query.js rename to src/dialects/snowflake/query.js diff --git a/lib/dialects/sqlite/connection-manager.js b/src/dialects/sqlite/connection-manager.js similarity index 100% rename from lib/dialects/sqlite/connection-manager.js rename to src/dialects/sqlite/connection-manager.js diff --git a/lib/dialects/sqlite/data-types.js b/src/dialects/sqlite/data-types.js similarity index 100% rename from lib/dialects/sqlite/data-types.js rename to src/dialects/sqlite/data-types.js diff --git a/lib/dialects/sqlite/index.js b/src/dialects/sqlite/index.js similarity index 97% rename from lib/dialects/sqlite/index.js rename to src/dialects/sqlite/index.js index d866de37bcae..7b04af9fc92a 100644 --- a/lib/dialects/sqlite/index.js +++ b/src/dialects/sqlite/index.js @@ -35,7 +35,8 @@ SqliteDialect.prototype.supports = _.merge( inserts: { ignoreDuplicates: ' OR IGNORE', updateOnDuplicate: ' ON CONFLICT DO UPDATE SET', - conflictFields: true + conflictFields: true, + onConflictWhere: true }, index: { using: false, diff --git a/lib/dialects/sqlite/query-generator.js b/src/dialects/sqlite/query-generator.js similarity index 98% rename from lib/dialects/sqlite/query-generator.js rename to src/dialects/sqlite/query-generator.js index e0dba2098a27..55bd86445e1c 100644 --- a/lib/dialects/sqlite/query-generator.js +++ b/src/dialects/sqlite/query-generator.js @@ -457,7 +457,7 @@ class SQLiteQueryGenerator extends MySqlQueryGenerator { /** * Generates an SQL query that returns all foreign keys of a table. * - * @param {string} tableName The name of the table. + * @param {TableName} tableName The name of the table. * @returns {string} The generated sql query. * @private */ @@ -465,6 +465,10 @@ class SQLiteQueryGenerator extends MySqlQueryGenerator { return `PRAGMA foreign_key_list(${this.quoteTable(this.addSchema(tableName))})`; } + tableExistsQuery(tableName) { + return `SELECT name FROM sqlite_master WHERE type='table' AND name=${this.escape(this.addSchema(tableName))};`; + } + /** * Quote identifier in sql clause * diff --git a/lib/dialects/sqlite/query-interface.js b/src/dialects/sqlite/query-interface.js similarity index 100% rename from lib/dialects/sqlite/query-interface.js rename to src/dialects/sqlite/query-interface.js diff --git a/lib/dialects/sqlite/query.js b/src/dialects/sqlite/query.js similarity index 95% rename from lib/dialects/sqlite/query.js rename to src/dialects/sqlite/query.js index 9518b91ec8e1..6cd118a93644 100644 --- a/lib/dialects/sqlite/query.js +++ b/src/dialects/sqlite/query.js @@ -10,6 +10,15 @@ const { logger } = require('../../utils/logger'); const debug = logger.debugContext('sql:sqlite'); +// sqlite3 currently ignores bigint values, so we have to translate to string for now +// There's a WIP here: https://github.com/TryGhost/node-sqlite3/pull/1501 +function stringifyIfBigint(value) { + if (typeof value === 'bigint') { + return value.toString(); + } + + return value; +} class Query extends AbstractQuery { getInsertIdField() { @@ -244,6 +253,17 @@ class Query extends AbstractQuery { } if (!parameters) parameters = []; + + if (_.isPlainObject(parameters)) { + const newParameters = Object.create(null); + for (const key of Object.keys(parameters)) { + newParameters[`${key}`] = stringifyIfBigint(parameters[key]); + } + parameters = newParameters; + } else { + parameters = parameters.map(stringifyIfBigint); + } + conn[method](sql, parameters, afterExecute); return null; diff --git a/src/dialects/sqlite/sqlite-utils.ts b/src/dialects/sqlite/sqlite-utils.ts new file mode 100644 index 000000000000..1fdc62c2983e --- /dev/null +++ b/src/dialects/sqlite/sqlite-utils.ts @@ -0,0 +1,12 @@ +import type { Sequelize } from '../../sequelize.js'; +import type { QueryOptions } from '../abstract/query-interface.js'; + +export async function withSqliteForeignKeysOff(sequelize: Sequelize, options: QueryOptions, cb: () => Promise): Promise { + try { + await sequelize.query('PRAGMA foreign_keys = OFF', options); + + return await cb(); + } finally { + await sequelize.query('PRAGMA foreign_keys = ON', options); + } +} diff --git a/lib/errors/aggregate-error.ts b/src/errors/aggregate-error.ts similarity index 82% rename from lib/errors/aggregate-error.ts rename to src/errors/aggregate-error.ts index 59a69c13eaf6..d1e6fb1235de 100644 --- a/lib/errors/aggregate-error.ts +++ b/src/errors/aggregate-error.ts @@ -3,10 +3,11 @@ import BaseError from './base-error'; /** * A wrapper for multiple Errors * - * @param errors Array of errors + * @param errors The aggregated errors that occurred */ class AggregateError extends BaseError { - errors: Array; + /** the aggregated errors that occurred */ + readonly errors: Array; constructor(errors: Array) { super(); diff --git a/lib/errors/association-error.ts b/src/errors/association-error.ts similarity index 100% rename from lib/errors/association-error.ts rename to src/errors/association-error.ts diff --git a/lib/errors/base-error.ts b/src/errors/base-error.ts similarity index 99% rename from lib/errors/base-error.ts rename to src/errors/base-error.ts index 74cca10f295a..3e36660d0711 100644 --- a/lib/errors/base-error.ts +++ b/src/errors/base-error.ts @@ -14,11 +14,12 @@ export interface CommonErrorProperties { } /** + * The Base Error all Sequelize Errors inherit from. + * * Sequelize provides a host of custom error classes, to allow you to do easier debugging. All of these errors are exposed on the sequelize object and the sequelize constructor. * All sequelize errors inherit from the base JS error object. * * This means that errors can be accessed using `Sequelize.ValidationError` - * The Base Error all Sequelize Errors inherit from. */ abstract class BaseError extends Error { constructor(message?: string) { diff --git a/lib/errors/bulk-record-error.ts b/src/errors/bulk-record-error.ts similarity index 91% rename from lib/errors/bulk-record-error.ts rename to src/errors/bulk-record-error.ts index ad5ede0b9cda..4491ff7c9bab 100644 --- a/lib/errors/bulk-record-error.ts +++ b/src/errors/bulk-record-error.ts @@ -1,5 +1,5 @@ +import type { Model } from '..'; import BaseError from './base-error'; -import type { Model } from '../../types/lib/model'; /** * Thrown when bulk operation fails, it represent per record level error. diff --git a/lib/errors/connection-error.ts b/src/errors/connection-error.ts similarity index 100% rename from lib/errors/connection-error.ts rename to src/errors/connection-error.ts diff --git a/lib/errors/connection/access-denied-error.ts b/src/errors/connection/access-denied-error.ts similarity index 84% rename from lib/errors/connection/access-denied-error.ts rename to src/errors/connection/access-denied-error.ts index 03e216e60e13..d27630b68855 100644 --- a/lib/errors/connection/access-denied-error.ts +++ b/src/errors/connection/access-denied-error.ts @@ -1,4 +1,4 @@ -import ConnectionError from './../connection-error'; +import ConnectionError from '../connection-error'; /** * Thrown when a connection to a database is refused due to insufficient privileges diff --git a/lib/errors/connection/connection-acquire-timeout-error.ts b/src/errors/connection/connection-acquire-timeout-error.ts similarity index 100% rename from lib/errors/connection/connection-acquire-timeout-error.ts rename to src/errors/connection/connection-acquire-timeout-error.ts diff --git a/lib/errors/connection/connection-refused-error.ts b/src/errors/connection/connection-refused-error.ts similarity index 100% rename from lib/errors/connection/connection-refused-error.ts rename to src/errors/connection/connection-refused-error.ts diff --git a/lib/errors/connection/connection-timed-out-error.ts b/src/errors/connection/connection-timed-out-error.ts similarity index 100% rename from lib/errors/connection/connection-timed-out-error.ts rename to src/errors/connection/connection-timed-out-error.ts diff --git a/lib/errors/connection/host-not-found-error.ts b/src/errors/connection/host-not-found-error.ts similarity index 100% rename from lib/errors/connection/host-not-found-error.ts rename to src/errors/connection/host-not-found-error.ts diff --git a/lib/errors/connection/host-not-reachable-error.ts b/src/errors/connection/host-not-reachable-error.ts similarity index 100% rename from lib/errors/connection/host-not-reachable-error.ts rename to src/errors/connection/host-not-reachable-error.ts diff --git a/lib/errors/connection/invalid-connection-error.ts b/src/errors/connection/invalid-connection-error.ts similarity index 100% rename from lib/errors/connection/invalid-connection-error.ts rename to src/errors/connection/invalid-connection-error.ts diff --git a/lib/errors/database-error.ts b/src/errors/database-error.ts similarity index 90% rename from lib/errors/database-error.ts rename to src/errors/database-error.ts index d4dd00a474ef..944052588ade 100644 --- a/lib/errors/database-error.ts +++ b/src/errors/database-error.ts @@ -24,6 +24,10 @@ class DatabaseError sql: string; parameters: object; + /** + * @param parent The database specific error which triggered this one + * @param options + */ constructor(parent: DatabaseErrorParent, options: ErrorOptions = {}) { super(parent.message); this.name = 'SequelizeDatabaseError'; diff --git a/lib/errors/database/exclusion-constraint-error.ts b/src/errors/database/exclusion-constraint-error.ts similarity index 71% rename from lib/errors/database/exclusion-constraint-error.ts rename to src/errors/database/exclusion-constraint-error.ts index 715bba245826..e2b575eae17f 100644 --- a/lib/errors/database/exclusion-constraint-error.ts +++ b/src/errors/database/exclusion-constraint-error.ts @@ -1,21 +1,18 @@ import DatabaseError, { DatabaseErrorSubclassOptions } from '../database-error'; interface ExclusionConstraintErrorOptions { - constraint: string; - fields: Record; - table: string; + constraint?: string; + fields?: Record; + table?: string; } /** * Thrown when an exclusion constraint is violated in the database */ -class ExclusionConstraintError - extends DatabaseError - implements ExclusionConstraintErrorOptions -{ - constraint: string; - fields: Record; - table: string; +class ExclusionConstraintError extends DatabaseError implements ExclusionConstraintErrorOptions { + constraint: string | undefined; + fields: Record | undefined; + table: string | undefined; constructor( options: DatabaseErrorSubclassOptions & ExclusionConstraintErrorOptions diff --git a/lib/errors/database/foreign-key-constraint-error.ts b/src/errors/database/foreign-key-constraint-error.ts similarity index 77% rename from lib/errors/database/foreign-key-constraint-error.ts rename to src/errors/database/foreign-key-constraint-error.ts index 8ffb38cfdc15..9b6a1335f972 100644 --- a/lib/errors/database/foreign-key-constraint-error.ts +++ b/src/errors/database/foreign-key-constraint-error.ts @@ -6,22 +6,22 @@ export enum RelationshipType { } interface ForeignKeyConstraintErrorOptions { - table: string; - fields: { [field: string]: string }; - value: unknown; - index: string; - reltype: RelationshipType; + table?: string; + fields?: { [field: string]: string }; + value?: unknown; + index?: string; + reltype?: RelationshipType; } /** * Thrown when a foreign key constraint is violated in the database */ class ForeignKeyConstraintError extends DatabaseError { - table: string; - fields: { [field: string]: string }; + table: string | undefined; + fields: { [field: string]: string } | undefined; value: unknown; - index: string; - reltype: RelationshipType; + index: string | undefined; + reltype: RelationshipType | undefined; constructor( options: ForeignKeyConstraintErrorOptions & DatabaseErrorSubclassOptions diff --git a/lib/errors/database/timeout-error.ts b/src/errors/database/timeout-error.ts similarity index 100% rename from lib/errors/database/timeout-error.ts rename to src/errors/database/timeout-error.ts diff --git a/lib/errors/database/unknown-constraint-error.ts b/src/errors/database/unknown-constraint-error.ts similarity index 71% rename from lib/errors/database/unknown-constraint-error.ts rename to src/errors/database/unknown-constraint-error.ts index 69d1ff0c2b1b..517fd380db6f 100644 --- a/lib/errors/database/unknown-constraint-error.ts +++ b/src/errors/database/unknown-constraint-error.ts @@ -1,21 +1,18 @@ import DatabaseError, { DatabaseErrorSubclassOptions } from '../database-error'; interface UnknownConstraintErrorOptions { - constraint: string; - fields: Record; - table: string; + constraint?: string; + fields?: Record; + table?: string; } /** * Thrown when constraint name is not found in the database */ -class UnknownConstraintError - extends DatabaseError - implements UnknownConstraintErrorOptions -{ - constraint: string; - fields: Record; - table: string; +class UnknownConstraintError extends DatabaseError implements UnknownConstraintErrorOptions { + constraint: string | undefined; + fields: Record | undefined; + table: string | undefined; constructor( options: UnknownConstraintErrorOptions & DatabaseErrorSubclassOptions diff --git a/lib/errors/eager-loading-error.ts b/src/errors/eager-loading-error.ts similarity index 100% rename from lib/errors/eager-loading-error.ts rename to src/errors/eager-loading-error.ts diff --git a/lib/errors/empty-result-error.ts b/src/errors/empty-result-error.ts similarity index 100% rename from lib/errors/empty-result-error.ts rename to src/errors/empty-result-error.ts diff --git a/lib/errors/index.ts b/src/errors/index.ts similarity index 100% rename from lib/errors/index.ts rename to src/errors/index.ts diff --git a/lib/errors/instance-error.ts b/src/errors/instance-error.ts similarity index 100% rename from lib/errors/instance-error.ts rename to src/errors/instance-error.ts diff --git a/lib/errors/optimistic-lock-error.ts b/src/errors/optimistic-lock-error.ts similarity index 87% rename from lib/errors/optimistic-lock-error.ts rename to src/errors/optimistic-lock-error.ts index 17e6d025b52a..45aebb5ece07 100644 --- a/lib/errors/optimistic-lock-error.ts +++ b/src/errors/optimistic-lock-error.ts @@ -15,9 +15,9 @@ interface OptimisticLockErrorOptions { * Thrown when attempting to update a stale model instance */ class OptimisticLockError extends BaseError { - modelName?: string; - values?: Record; - where?: Record; + modelName: string | undefined; + values: Record | undefined; + where: Record | undefined; constructor(options: OptimisticLockErrorOptions) { options = options || {}; diff --git a/lib/errors/query-error.ts b/src/errors/query-error.ts similarity index 100% rename from lib/errors/query-error.ts rename to src/errors/query-error.ts diff --git a/lib/errors/sequelize-scope-error.ts b/src/errors/sequelize-scope-error.ts similarity index 100% rename from lib/errors/sequelize-scope-error.ts rename to src/errors/sequelize-scope-error.ts diff --git a/lib/errors/validation-error.ts b/src/errors/validation-error.ts similarity index 91% rename from lib/errors/validation-error.ts rename to src/errors/validation-error.ts index 70e788e82d9a..873c2355c844 100644 --- a/lib/errors/validation-error.ts +++ b/src/errors/validation-error.ts @@ -1,5 +1,6 @@ -import BaseError, { ErrorOptions } from './base-error'; -import type { Model } from '../../types/lib/model'; +import type { Model } from '..'; +import type { ErrorOptions } from './base-error'; +import BaseError from './base-error'; /** * An enum that is used internally by the `ValidationErrorItem` class @@ -51,44 +52,44 @@ export class ValidationErrorItem { /** * An error message */ - message: string; + readonly message: string; /** * The type/origin of the validation error */ - type: keyof typeof ValidationErrorItemType | null; + readonly type: keyof typeof ValidationErrorItemType | null; /** * The field that triggered the validation error */ - path: string | null; + readonly path: string | null; /** * The value that generated the error */ - value: string | null; + readonly value: string | null; - origin: keyof typeof ValidationErrorItemOrigin | null; + readonly origin: keyof typeof ValidationErrorItemOrigin | null; /** * The DAO instance that caused the validation error */ - instance: Model | null; + readonly instance: Model | null; /** * A validation "key", used for identification */ - validatorKey: string | null; + readonly validatorKey: string | null; /** * Property name of the BUILT-IN validator function that caused the validation error (e.g. "in" or "len"), if applicable */ - validatorName: string | null; + readonly validatorName: string | null; /** * Parameters used with the BUILT-IN validator function, if applicable */ - validatorArgs: unknown[]; + readonly validatorArgs: unknown[]; /** * Creates a new ValidationError item. Instances of this class are included in the `ValidationError.errors` property. @@ -202,7 +203,8 @@ export class ValidationErrorItem { * @param errors Array of ValidationErrorItem objects describing the validation errors */ class ValidationError extends BaseError { - errors: ValidationErrorItem[]; + /** Array of ValidationErrorItem objects describing the validation errors */ + readonly errors: ValidationErrorItem[]; constructor( message: string, diff --git a/lib/errors/validation/unique-constraint-error.ts b/src/errors/validation/unique-constraint-error.ts similarity index 77% rename from lib/errors/validation/unique-constraint-error.ts rename to src/errors/validation/unique-constraint-error.ts index 11b208031b9b..ef91c15cfd0c 100644 --- a/lib/errors/validation/unique-constraint-error.ts +++ b/src/errors/validation/unique-constraint-error.ts @@ -5,7 +5,7 @@ interface UniqueConstraintErrorParent extends Error, Pick {} -interface UniqueConstraintErrorOptions extends ErrorOptions { +export interface UniqueConstraintErrorOptions extends ErrorOptions { parent?: UniqueConstraintErrorParent; original?: UniqueConstraintErrorParent; errors?: ValidationErrorItem[]; @@ -16,14 +16,11 @@ interface UniqueConstraintErrorOptions extends ErrorOptions { /** * Thrown when a unique constraint is violated in the database */ -class UniqueConstraintError - extends ValidationError - implements CommonErrorProperties -{ - parent: UniqueConstraintErrorParent; - original: UniqueConstraintErrorParent; - fields: Record; - sql: string; +class UniqueConstraintError extends ValidationError implements CommonErrorProperties { + readonly parent: UniqueConstraintErrorParent; + readonly original: UniqueConstraintErrorParent; + readonly fields: Record; + readonly sql: string; constructor(options: UniqueConstraintErrorOptions) { options = options ?? {}; @@ -34,7 +31,6 @@ class UniqueConstraintError super(options.message, options.errors, { stack: options.stack }); this.name = 'SequelizeUniqueConstraintError'; - this.errors = options.errors; this.fields = options.fields ?? {}; this.parent = options.parent; this.original = options.parent; diff --git a/lib/generic/falsy.ts b/src/generic/falsy.ts similarity index 100% rename from lib/generic/falsy.ts rename to src/generic/falsy.ts diff --git a/lib/generic/sql-fragment.ts b/src/generic/sql-fragment.ts similarity index 100% rename from lib/generic/sql-fragment.ts rename to src/generic/sql-fragment.ts diff --git a/types/lib/hooks.d.ts b/src/hooks.d.ts similarity index 92% rename from types/lib/hooks.d.ts rename to src/hooks.d.ts index b9620f172a64..50b399802af0 100644 --- a/types/lib/hooks.d.ts +++ b/src/hooks.d.ts @@ -1,4 +1,3 @@ -import { Attributes, CreationAttributes, ModelType } from '../index'; import { ValidationOptions } from './instance-validator'; import Model, { BulkCreateOptions, @@ -9,12 +8,14 @@ import Model, { InstanceRestoreOptions, InstanceUpdateOptions, ModelAttributes, - ModelOptions, RestoreOptions, UpdateOptions, UpsertOptions + ModelOptions, RestoreOptions, UpdateOptions, UpsertOptions, + Attributes, CreationAttributes, ModelType } from './model'; -import { AbstractQuery } from './query'; -import { QueryOptions } from './query-interface'; +import { AbstractQuery } from './dialects/abstract/query'; +import { QueryOptions } from './dialects/abstract/query-interface'; import { Config, Options, Sequelize, SyncOptions } from './sequelize'; import { DeepWriteable } from './utils'; +import { Connection, GetConnectionOptions } from './dialects/abstract/connection-manager'; export type HookReturn = Promise | void; @@ -34,7 +35,7 @@ export interface ModelHooks { beforeUpdate(instance: M, options: InstanceUpdateOptions): HookReturn; afterUpdate(instance: M, options: InstanceUpdateOptions): HookReturn; beforeUpsert(attributes: M, options: UpsertOptions): HookReturn; - afterUpsert(attributes: [ M, boolean | null ], options: UpsertOptions): HookReturn; + afterUpsert(attributes: [ M, boolean | null ], options: UpsertOptions): HookReturn; beforeSave( instance: M, options: InstanceUpdateOptions | CreateOptions @@ -67,8 +68,8 @@ export interface ModelHooks { export interface SequelizeHooks< M extends Model = Model, - TAttributes = any, - TCreationAttributes = TAttributes + TAttributes extends {} = any, + TCreationAttributes extends {} = TAttributes > extends ModelHooks { beforeDefine(attributes: ModelAttributes, options: ModelOptions): void; afterDefine(model: ModelType): void; @@ -76,6 +77,8 @@ export interface SequelizeHooks< afterInit(sequelize: Sequelize): void; beforeConnect(config: DeepWriteable): HookReturn; afterConnect(connection: unknown, config: Config): HookReturn; + beforePoolAcquire(config: GetConnectionOptions): HookReturn; + afterPoolAcquire(connection: Connection, config: GetConnectionOptions): HookReturn; beforeDisconnect(connection: unknown): HookReturn; afterDisconnect(connection: unknown): HookReturn; } diff --git a/lib/hooks.js b/src/hooks.js similarity index 96% rename from lib/hooks.js rename to src/hooks.js index 69602a048b4d..b3c4befce09c 100644 --- a/lib/hooks.js +++ b/src/hooks.js @@ -43,6 +43,8 @@ const hookTypes = { afterConnect: { params: 2, noModel: true }, beforeDisconnect: { params: 1, noModel: true }, afterDisconnect: { params: 1, noModel: true }, + beforePoolAcquire: { params: 1, noModel: true }, + afterPoolAcquire: { params: 2, noModel: true }, beforeSync: { params: 1 }, afterSync: { params: 1 }, beforeBulkSync: { params: 1 }, @@ -541,6 +543,24 @@ exports.applyTo = applyTo; * @memberof Sequelize */ +/** + * A hook that is run before a connection to the pool + * + * @param {string} name + * @param {Function} fn A callback function that is called with config passed to connection + * @name beforePoolAcquire + * @memberof Sequelize + */ + +/** + * A hook that is run after a connection to the pool + * + * @param {string} name + * @param {Function} fn A callback function that is called with the connection object and the config passed to connection + * @name afterPoolAcquire + * @memberof Sequelize + */ + /** * A hook that is run before a connection is disconnected * diff --git a/types/lib/index-hints.d.ts b/src/index-hints.d.ts similarity index 100% rename from types/lib/index-hints.d.ts rename to src/index-hints.d.ts diff --git a/lib/index-hints.js b/src/index-hints.js similarity index 100% rename from lib/index-hints.js rename to src/index-hints.js diff --git a/src/index.d.ts b/src/index.d.ts new file mode 100644 index 000000000000..78c9c94428ee --- /dev/null +++ b/src/index.d.ts @@ -0,0 +1,25 @@ +import DataTypes = require('./data-types'); +import Deferrable = require('./deferrable'); +import Op from './operators'; +import QueryTypes = require('./query-types'); +import TableHints = require('./table-hints'); +import IndexHints = require('./index-hints'); +import Utils = require('./utils'); + +export * from './associations/index'; +export * from './data-types'; +export * from './errors/index'; +export { BaseError as Error } from './errors/index'; +export * from './model'; +export * from './dialects/abstract/query-interface'; +export * from './sequelize'; +export * from './transaction'; +export { useInflection } from './utils'; +export { Validator } from './utils/validator-extras'; +export { Utils, QueryTypes, Op, TableHints, IndexHints, DataTypes, Deferrable }; + +/** + * Type helper for making certain fields of an object optional. This is helpful + * for creating the `CreationAttributes` from your `Attributes` for a Model. + */ +export type Optional = Omit & Partial>; diff --git a/src/index.js b/src/index.js new file mode 100644 index 000000000000..c05fac2bd7c9 --- /dev/null +++ b/src/index.js @@ -0,0 +1,10 @@ +'use strict'; + +/** + * A Sequelize module that contains the sequelize entry point. + * + * @module sequelize + */ + +/** Exports the sequelize entry point. */ +module.exports = require('./sequelize'); diff --git a/index.mjs b/src/index.mjs similarity index 100% rename from index.mjs rename to src/index.mjs diff --git a/types/lib/instance-validator.d.ts b/src/instance-validator.d.ts similarity index 100% rename from types/lib/instance-validator.d.ts rename to src/instance-validator.d.ts diff --git a/lib/instance-validator.js b/src/instance-validator.js similarity index 100% rename from lib/instance-validator.js rename to src/instance-validator.js diff --git a/types/lib/model-manager.d.ts b/src/model-manager.d.ts similarity index 51% rename from types/lib/model-manager.d.ts rename to src/model-manager.d.ts index 41e72dae6636..248c11f7c965 100644 --- a/types/lib/model-manager.d.ts +++ b/src/model-manager.d.ts @@ -10,6 +10,16 @@ export class ModelManager { public addModel(model: T): T; public removeModel(model: ModelType): void; public getModel(against: unknown, options?: { attribute?: string }): typeof Model; + public findModel(callback: (model: typeof Model) => boolean): typeof Model | undefined + + /** + * Returns an array that lists every model, sorted in order + * of foreign key references: The first model is a model that is depended upon, + * the last model is a model that is not depended upon. + * + * If there is a cyclic dependency, this returns null. + */ + public getModelsTopoSortedByForeignKey(): ModelType[] | null; } export default ModelManager; diff --git a/lib/model-manager.js b/src/model-manager.js similarity index 64% rename from lib/model-manager.js rename to src/model-manager.js index 3f36edcf1e3e..69b753b32b88 100644 --- a/lib/model-manager.js +++ b/src/model-manager.js @@ -30,27 +30,24 @@ class ModelManager { return this.models.find(model => model[options.attribute] === against); } + findModel(callback) { + return this.models.find(callback); + } + get all() { return this.models; } /** - * Iterate over Models in an order suitable for e.g. creating tables. - * Will take foreign key constraints into account so that dependencies are visited before dependents. + * Returns an array that lists every model, sorted in order + * of foreign key references: The first model is a model that is depended upon, + * the last model is a model that is not depended upon. * - * @param {Function} iterator method to execute on each model - * @param {object} [options] iterator options - * @private + * If there is a cyclic dependency, this returns null. */ - forEachModel(iterator, options) { - const models = {}; + getModelsTopoSortedByForeignKey() { + const models = new Map(); const sorter = new Toposort(); - let sorted; - let dep; - - options = _.defaults(options || {}, { - reverse: true - }); for (const model of this.models) { let deps = []; @@ -60,14 +57,14 @@ class ModelManager { tableName = `${tableName.schema}.${tableName.tableName}`; } - models[tableName] = model; + models.set(tableName, model); for (const attrName in model.rawAttributes) { if (Object.prototype.hasOwnProperty.call(model.rawAttributes, attrName)) { const attribute = model.rawAttributes[attrName]; if (attribute.references) { - dep = attribute.references.model; + let dep = attribute.references.model; if (_.isObject(dep)) { dep = `${dep.schema}.${dep.tableName}`; @@ -83,12 +80,50 @@ class ModelManager { sorter.add(tableName, deps); } - sorted = sorter.sort(); + let sorted; + try { + sorted = sorter.sort(); + } catch (e) { + if (!e.message.startsWith('Cyclic dependency found.')) { + throw e; + } + + return null; + } + + return sorted + .map(modelName => { + return models.get(modelName); + }) + .filter(Boolean); + } + + /** + * Iterate over Models in an order suitable for e.g. creating tables. + * Will take foreign key constraints into account so that dependencies are visited before dependents. + * + * @param {Function} iterator method to execute on each model + * @param {object} options + * @private + * + * @deprecated + */ + forEachModel(iterator, options) { + const sortedModels = this.getModelsTopoSortedByForeignKey(); + if (sortedModels == null) { + throw new Error('Cyclic dependency found.'); + } + + options = _.defaults(options || {}, { + reverse: true + }); + if (options.reverse) { - sorted = sorted.reverse(); + sortedModels.reverse(); } - for (const name of sorted) { - iterator(models[name], name); + + for (const model of sortedModels) { + iterator(model); } } } diff --git a/types/lib/model.d.ts b/src/model.d.ts similarity index 77% rename from types/lib/model.d.ts rename to src/model.d.ts index b5f5982dbf92..7ab36db85b7f 100644 --- a/types/lib/model.d.ts +++ b/src/model.d.ts @@ -1,14 +1,17 @@ -import { IndexHints } from '..'; +import IndexHints = require('./index-hints'); import { Association, BelongsTo, BelongsToMany, BelongsToManyOptions, BelongsToOptions, HasMany, HasManyOptions, HasOne, HasOneOptions } from './associations/index'; import { DataType } from './data-types'; import { Deferrable } from './deferrable'; import { HookReturn, Hooks, ModelHooks } from './hooks'; import { ValidationOptions } from './instance-validator'; -import { IndexesOptions, QueryOptions, TableName } from './query-interface'; +import { IndexesOptions, QueryOptions, TableName } from './dialects/abstract/query-interface'; import { Sequelize, SyncOptions } from './sequelize'; -import { Col, Fn, Literal, Where, MakeUndefinedOptional, AnyFunction } from './utils'; -import { LOCK, Transaction, Op } from '..'; -import { SetRequired } from '../type-helpers/set-required' +import { Col, Fn, Literal, Where, MakeNullishOptional, AnyFunction, Cast, Json } from './utils'; +import { LOCK, Transaction, Op, Optional } from './index'; +import { SetRequired } from './utils/set-required'; + +// Backport of https://github.com/sequelize/sequelize/blob/a68b439fb3ea748d3f3d37356d9fe610f86184f6/src/utils/index.ts#L85 +export type AllowReadonlyArray = T | readonly T[]; export interface Logging { /** @@ -106,225 +109,430 @@ export interface ScopeOptions { method: string | readonly [string, ...unknown[]]; } +type InvalidInSqlArray = ColumnReference | Fn | Cast | null | Literal; + +/** + * This type allows using `Op.or`, `Op.and`, and `Op.not` recursively around another type. + * It also supports using a plain Array as an alias for `Op.and`. (unlike {@link AllowNotOrAndRecursive}). + * + * Example of plain-array treated as `Op.and`: + * User.findAll({ where: [{ id: 1 }, { id: 2 }] }); + * + * Meant to be used by {@link WhereOptions}. + */ +type AllowNotOrAndWithImplicitAndArrayRecursive = AllowArray< + // this is the equivalent of Op.and + | T + | { [Op.or]: AllowArray> } + | { [Op.and]: AllowArray> } + | { [Op.not]: AllowNotOrAndWithImplicitAndArrayRecursive } +>; + +/** + * This type allows using `Op.or`, `Op.and`, and `Op.not` recursively around another type. + * Unlike {@link AllowNotOrAndWithImplicitAndArrayRecursive}, it does not allow the 'implicit AND Array'. + * + * Example of plain-array NOT treated as Op.and: + * User.findAll({ where: { id: [1, 2] } }); + * + * Meant to be used by {@link WhereAttributeHashValue}. + */ +type AllowNotOrAndRecursive = + | T + | { [Op.or]: AllowArray> } + | { [Op.and]: AllowArray> } + | { [Op.not]: AllowNotOrAndRecursive }; + +type AllowArray = T | T[]; +type AllowAnyAll = + | T + // Op.all: [x, z] results in ALL (ARRAY[x, z]) + // Some things cannot go in ARRAY. Op.values must be used to support them. + | { [Op.all]: Exclude[] | Literal | { [Op.values]: Array> } } + | { [Op.any]: Exclude[] | Literal | { [Op.values]: Array> } }; + /** * The type accepted by every `where` option */ -export type WhereOptions = +export type WhereOptions = AllowNotOrAndWithImplicitAndArrayRecursive< | WhereAttributeHash - | AndOperator - | OrOperator | Literal | Fn - | Where; + | Where + | Json +>; /** - * Example: `[Op.any]: [2,3]` becomes `ANY ARRAY[2, 3]::INTEGER` - * - * _PG only_ + * @deprecated unused */ export interface AnyOperator { - [Op.any]: readonly (string | number)[]; + [Op.any]: readonly (string | number | Date | Literal)[] | Literal; } -/** TODO: Undocumented? */ +/** @deprecated unused */ export interface AllOperator { - [Op.all]: readonly (string | number | Date | Literal)[]; + [Op.all]: readonly (string | number | Date | Literal)[] | Literal; } -export type Rangable = readonly [number, number] | readonly [Date, Date] | readonly [string, string] | Literal; +// number is always allowed because -Infinity & +Infinity are valid +export type Rangable = readonly [ + lower: T | RangePart | number | null, + higher: T | RangePart | number | null +] | EmptyRange; + +/** + * This type represents the output of the {@link RANGE} data type. + */ +// number is always allowed because -Infinity & +Infinity are valid +export type Range = readonly [lower: RangePart, higher: RangePart] | EmptyRange; + +type EmptyRange = []; + +type RangePart = { value: T, inclusive: boolean }; + +/** + * Internal type - prone to changes. Do not export. + * @private + */ +export type ColumnReference = Col | { [Op.col]: string }; + +/** + * Internal type - prone to changes. Do not export. + * @private + */ +type WhereSerializableValue = boolean | string | number | Buffer | Date; + +/** + * Internal type - prone to changes. Do not export. + * @private + */ +type OperatorValues = + | StaticValues + | DynamicValues; + +/** + * Represents acceptable Dynamic values. + * + * Dynamic values, as opposed to {@link StaticValues}. i.e. column references, functions, etc... + */ +type DynamicValues = + | Literal + | ColumnReference + | Fn + | Cast + // where() can only be used on boolean attributes + | (AcceptableValues extends boolean ? Where : never) + +/** + * Represents acceptable Static values. + * + * Static values, as opposed to {@link DynamicValues}. i.e. booleans, strings, etc... + */ +type StaticValues = + Type extends Range ? [lower: RangeType | RangePart, higher: RangeType | RangePart] + : Type extends any[] ? { readonly [Key in keyof Type]: StaticValues} + : Type extends null ? Type | WhereSerializableValue | null + : Type | WhereSerializableValue; /** - * Operators that can be used in WhereOptions + * Operators that can be used in {@link WhereOptions} + * + * @typeParam AttributeType - The JS type of the attribute the operator is operating on. * * See https://sequelize.org/master/en/v3/docs/querying/#operators */ -export interface WhereOperators { +// TODO: default to something more strict than `any` which lists serializable values +export interface WhereOperators { + /** + * @example: `[Op.eq]: 6,` becomes `= 6` + * @example: `[Op.eq]: [6, 7]` becomes `= ARRAY[6, 7]` + * @example: `[Op.eq]: null` becomes `IS NULL` + * @example: `[Op.eq]: true` becomes `= true` + * @example: `[Op.eq]: literal('raw sql')` becomes `= raw sql` + * @example: `[Op.eq]: col('column')` becomes `= "column"` + * @example: `[Op.eq]: fn('NOW')` becomes `= NOW()` + */ + [Op.eq]?: AllowAnyAll>; + /** - * Example: `[Op.any]: [2,3]` becomes `ANY ARRAY[2, 3]::INTEGER` - * - * _PG only_ + * @example: `[Op.ne]: 20,` becomes `!= 20` + * @example: `[Op.ne]: [20, 21]` becomes `!= ARRAY[20, 21]` + * @example: `[Op.ne]: null` becomes `IS NOT NULL` + * @example: `[Op.ne]: true` becomes `!= true` + * @example: `[Op.ne]: literal('raw sql')` becomes `!= raw sql` + * @example: `[Op.ne]: col('column')` becomes `!= "column"` + * @example: `[Op.ne]: fn('NOW')` becomes `!= NOW()` */ + [Op.ne]?: WhereOperators[typeof Op.eq]; // accepts the same types as Op.eq - /** Example: `[Op.eq]: 6,` becomes `= 6` */ - [Op.eq]?: null | boolean | string | number | Literal | WhereOperators | Col; - - [Op.any]?: readonly (string | number | Literal)[] | Literal; - - /** Example: `[Op.gte]: 6,` becomes `>= 6` */ - [Op.gte]?: number | string | Date | Literal | Col; + /** + * @example: `[Op.is]: null` becomes `IS NULL` + * @example: `[Op.is]: true` becomes `IS TRUE` + * @example: `[Op.is]: literal('value')` becomes `IS value` + */ + [Op.is]?: Extract | Literal; - /** Example: `[Op.lt]: 10,` becomes `< 10` */ - [Op.lt]?: number | string | Date | Literal | Col; + /** + * @example: `[Op.not]: true` becomes `IS NOT TRUE` + * @example: `{ col: { [Op.not]: { [Op.gt]: 5 } } }` becomes `NOT (col > 5)` + */ + [Op.not]?: WhereOperators[typeof Op.eq]; // accepts the same types as Op.eq ('Op.not' is not strictly the opposite of 'Op.is' due to legacy reasons) - /** Example: `[Op.lte]: 10,` becomes `<= 10` */ - [Op.lte]?: number | string | Date | Literal | Col; + /** @example: `[Op.gte]: 6` becomes `>= 6` */ + [Op.gte]?: AllowAnyAll>>; - /** Example: `[Op.match]: Sequelize.fn('to_tsquery', 'fat & rat')` becomes `@@ to_tsquery('fat & rat')` */ - [Op.match]?: Fn; + /** @example: `[Op.lte]: 10` becomes `<= 10` */ + [Op.lte]?: WhereOperators[typeof Op.gte]; // accepts the same types as Op.gte - /** Example: `[Op.ne]: 20,` becomes `!= 20` */ - [Op.ne]?: null | string | number | Literal | WhereOperators; + /** @example: `[Op.lt]: 10` becomes `< 10` */ + [Op.lt]?: WhereOperators[typeof Op.gte]; // accepts the same types as Op.gte - /** Example: `[Op.not]: true,` becomes `IS NOT TRUE` */ - [Op.not]?: null | boolean | string | number | Literal | WhereOperators; + /** @example: `[Op.gt]: 6` becomes `> 6` */ + [Op.gt]?: WhereOperators[typeof Op.gte]; // accepts the same types as Op.gte - /** Example: `[Op.is]: null,` becomes `IS NULL` */ - [Op.is]?: null; + /** + * @example: `[Op.between]: [6, 10],` becomes `BETWEEN 6 AND 10` + */ + [Op.between]?: + | [ + lowerInclusive: OperatorValues>, + higherInclusive: OperatorValues>, + ] + | Literal; - /** Example: `[Op.between]: [6, 10],` becomes `BETWEEN 6 AND 10` */ - [Op.between]?: Rangable; + /** @example: `[Op.notBetween]: [11, 15],` becomes `NOT BETWEEN 11 AND 15` */ + [Op.notBetween]?: WhereOperators[typeof Op.between]; - /** Example: `[Op.in]: [1, 2],` becomes `IN [1, 2]` */ - [Op.in]?: readonly (string | number | Literal)[] | Literal; + /** @example: `[Op.in]: [1, 2],` becomes `IN (1, 2)` */ + [Op.in]?: ReadonlyArray>> | Literal; - /** Example: `[Op.notIn]: [1, 2],` becomes `NOT IN [1, 2]` */ - [Op.notIn]?: readonly (string | number | Literal)[] | Literal; + /** @example: `[Op.notIn]: [1, 2],` becomes `NOT IN (1, 2)` */ + [Op.notIn]?: WhereOperators[typeof Op.in]; /** - * Examples: - * - `[Op.like]: '%hat',` becomes `LIKE '%hat'` - * - `[Op.like]: { [Op.any]: ['cat', 'hat']}` becomes `LIKE ANY ARRAY['cat', 'hat']` + * @example: `[Op.like]: '%hat',` becomes `LIKE '%hat'` + * @example: `[Op.like]: { [Op.any]: ['cat', 'hat'] }` becomes `LIKE ANY ARRAY['cat', 'hat']` */ - [Op.like]?: string | Literal | AnyOperator | AllOperator; + [Op.like]?: AllowAnyAll>>; /** - * Examples: - * - `[Op.notLike]: '%hat'` becomes `NOT LIKE '%hat'` - * - `[Op.notLike]: { [Op.any]: ['cat', 'hat']}` becomes `NOT LIKE ANY ARRAY['cat', 'hat']` + * @example: `[Op.notLike]: '%hat'` becomes `NOT LIKE '%hat'` + * @example: `[Op.notLike]: { [Op.any]: ['cat', 'hat']}` becomes `NOT LIKE ANY ARRAY['cat', 'hat']` */ - [Op.notLike]?: string | Literal | AnyOperator | AllOperator; + [Op.notLike]?: WhereOperators[typeof Op.like]; /** * case insensitive PG only * - * Examples: - * - `[Op.iLike]: '%hat'` becomes `ILIKE '%hat'` - * - `[Op.iLike]: { [Op.any]: ['cat', 'hat']}` becomes `ILIKE ANY ARRAY['cat', 'hat']` + * @example: `[Op.iLike]: '%hat'` becomes `ILIKE '%hat'` + * @example: `[Op.iLike]: { [Op.any]: ['cat', 'hat']}` becomes `ILIKE ANY ARRAY['cat', 'hat']` */ - [Op.iLike]?: string | Literal | AnyOperator | AllOperator; + [Op.iLike]?: WhereOperators[typeof Op.like]; /** - * PG array overlap operator + * PG only * - * Example: `[Op.overlap]: [1, 2]` becomes `&& [1, 2]` + * @example: `[Op.notILike]: '%hat'` becomes `NOT ILIKE '%hat'` + * @example: `[Op.notLike]: ['cat', 'hat']` becomes `LIKE ANY ARRAY['cat', 'hat']` */ - [Op.overlap]?: Rangable; + [Op.notILike]?: WhereOperators[typeof Op.like]; /** - * PG array contains operator + * PG array & range 'overlaps' operator * - * Example: `[Op.contains]: [1, 2]` becomes `@> [1, 2]` + * @example: `[Op.overlap]: [1, 2]` becomes `&& [1, 2]` */ - [Op.contains]?: readonly (string | number)[] | Rangable; + // https://www.postgresql.org/docs/14/functions-range.html range && range + // https://www.postgresql.org/docs/14/functions-array.html array && array + [Op.overlap]?: AllowAnyAll< + | ( + // RANGE && RANGE + AttributeType extends Range ? Rangable + // ARRAY && ARRAY + : AttributeType extends any[] ? StaticValues> + : never + ) + | DynamicValues + >; /** - * PG array contained by operator + * PG array & range 'contains' operator * - * Example: `[Op.contained]: [1, 2]` becomes `<@ [1, 2]` + * @example: `[Op.contains]: [1, 2]` becomes `@> [1, 2]` */ - [Op.contained]?: readonly (string | number)[] | Rangable; - - /** Example: `[Op.gt]: 6,` becomes `> 6` */ - [Op.gt]?: number | string | Date | Literal | Col; + // https://www.postgresql.org/docs/14/functions-json.html jsonb @> jsonb + // https://www.postgresql.org/docs/14/functions-range.html range @> range ; range @> element + // https://www.postgresql.org/docs/14/functions-array.html array @> array + [Op.contains]?: + // RANGE @> ELEMENT + | AttributeType extends Range ? OperatorValues>> : never + // ARRAY @> ARRAY ; RANGE @> RANGE + | WhereOperators[typeof Op.overlap]; /** - * PG only + * PG array & range 'contained by' operator * - * Examples: - * - `[Op.notILike]: '%hat'` becomes `NOT ILIKE '%hat'` - * - `[Op.notLike]: ['cat', 'hat']` becomes `LIKE ANY ARRAY['cat', 'hat']` + * @example: `[Op.contained]: [1, 2]` becomes `<@ [1, 2]` */ - [Op.notILike]?: string | Literal | AnyOperator | AllOperator; - - /** Example: `[Op.notBetween]: [11, 15],` becomes `NOT BETWEEN 11 AND 15` */ - [Op.notBetween]?: Rangable; + [Op.contained]?: + AttributeType extends any[] + // ARRAY <@ ARRAY ; RANGE <@ RANGE + ? WhereOperators[typeof Op.overlap] + // ELEMENT <@ RANGE + : AllowAnyAll>>; /** * Strings starts with value. */ - [Op.startsWith]?: string; + [Op.startsWith]?: OperatorValues>; /** * String ends with value. */ - [Op.endsWith]?: string; + [Op.endsWith]?: WhereOperators[typeof Op.startsWith]; /** * String contains value. */ - [Op.substring]?: string; + [Op.substring]?: WhereOperators[typeof Op.startsWith]; /** * MySQL/PG only * * Matches regular expression, case sensitive * - * Example: `[Op.regexp]: '^[h|a|t]'` becomes `REGEXP/~ '^[h|a|t]'` + * @example: `[Op.regexp]: '^[h|a|t]'` becomes `REGEXP/~ '^[h|a|t]'` */ - [Op.regexp]?: string; + [Op.regexp]?: AllowAnyAll>>; /** * MySQL/PG only * * Does not match regular expression, case sensitive * - * Example: `[Op.notRegexp]: '^[h|a|t]'` becomes `NOT REGEXP/!~ '^[h|a|t]'` + * @example: `[Op.notRegexp]: '^[h|a|t]'` becomes `NOT REGEXP/!~ '^[h|a|t]'` */ - [Op.notRegexp]?: string; + [Op.notRegexp]?: WhereOperators[typeof Op.regexp]; /** * PG only * * Matches regular expression, case insensitive * - * Example: `[Op.iRegexp]: '^[h|a|t]'` becomes `~* '^[h|a|t]'` + * @example: `[Op.iRegexp]: '^[h|a|t]'` becomes `~* '^[h|a|t]'` */ - [Op.iRegexp]?: string; + [Op.iRegexp]?: WhereOperators[typeof Op.regexp]; /** * PG only * * Does not match regular expression, case insensitive * - * Example: `[Op.notIRegexp]: '^[h|a|t]'` becomes `!~* '^[h|a|t]'` + * @example: `[Op.notIRegexp]: '^[h|a|t]'` becomes `!~* '^[h|a|t]'` */ - [Op.notIRegexp]?: string; + [Op.notIRegexp]?: WhereOperators[typeof Op.regexp]; + + /** @example: `[Op.match]: Sequelize.fn('to_tsquery', 'fat & rat')` becomes `@@ to_tsquery('fat & rat')` */ + [Op.match]?: AllowAnyAll>; /** * PG only * - * Forces the operator to be strictly left eg. `<< [a, b)` + * Whether the range is strictly left of the other range. + * + * @example: + * ```typescript + * { rangeAttribute: { [Op.strictLeft]: [1, 2] } } + * // results in + * // "rangeAttribute" << [1, 2) + * ``` + * + * https://www.postgresql.org/docs/14/functions-range.html */ - [Op.strictLeft]?: Rangable; + [Op.strictLeft]?: + | AttributeType extends Range ? Rangable : never + | DynamicValues; /** * PG only * - * Forces the operator to be strictly right eg. `>> [a, b)` + * Whether the range is strictly right of the other range. + * + * @example: + * ```typescript + * { rangeAttribute: { [Op.strictRight]: [1, 2] } } + * // results in + * // "rangeAttribute" >> [1, 2) + * ``` + * + * https://www.postgresql.org/docs/14/functions-range.html */ - [Op.strictRight]?: Rangable; + [Op.strictRight]?: WhereOperators[typeof Op.strictLeft]; /** * PG only * - * Forces the operator to not extend the left eg. `&> [1, 2)` + * Whether the range extends to the left of the other range. + * + * @example: + * ```typescript + * { rangeAttribute: { [Op.noExtendLeft]: [1, 2] } } + * // results in + * // "rangeAttribute" &> [1, 2) + * ``` + * + * https://www.postgresql.org/docs/14/functions-range.html */ - [Op.noExtendLeft]?: Rangable; + [Op.noExtendLeft]?: WhereOperators[typeof Op.strictLeft]; /** * PG only * - * Forces the operator to not extend the left eg. `&< [1, 2)` + * Whether the range extends to the right of the other range. + * + * @example: + * ```typescript + * { rangeAttribute: { [Op.noExtendRight]: [1, 2] } } + * // results in + * // "rangeAttribute" &< [1, 2) + * ``` + * + * https://www.postgresql.org/docs/14/functions-range.html */ - [Op.noExtendRight]?: Rangable; + [Op.noExtendRight]?: WhereOperators[typeof Op.strictLeft]; + /** + * PG only + * + * Whether the two ranges are adjacent. + * + * @example: + * ```typescript + * { rangeAttribute: { [Op.adjacent]: [1, 2] } } + * // results in + * // "rangeAttribute" -|- [1, 2) + * ``` + * + * https://www.postgresql.org/docs/14/functions-range.html + */ + [Op.adjacent]?: WhereOperators[typeof Op.strictLeft]; } -/** Example: `[Op.or]: [{a: 5}, {a: 6}]` becomes `(a = 5 OR a = 6)` */ +/** + * Example: `[Op.or]: [{a: 5}, {a: 6}]` becomes `(a = 5 OR a = 6)` + * + * @deprecated do not use me! + */ +// TODO [>6]: Remove me export interface OrOperator { [Op.or]: WhereOptions | readonly WhereOptions[] | WhereValue | readonly WhereValue[]; } -/** Example: `[Op.and]: {a: 5}` becomes `AND (a = 5)` */ +/** + * Example: `[Op.and]: {a: 5}` becomes `AND (a = 5)` + * + * @deprecated do not use me! + */ +// TODO [>6]: Remove me export interface AndOperator { [Op.and]: WhereOptions | readonly WhereOptions[] | WhereValue | readonly WhereValue[]; } @@ -340,7 +548,10 @@ export interface WhereGeometryOptions { /** * Used for the right hand side of WhereAttributeHash. * WhereAttributeHash is in there for JSON columns. + * + * @deprecated do not use me */ +// TODO [>6]: remove this export type WhereValue = | string | number @@ -349,32 +560,61 @@ export type WhereValue = | Date | Buffer | null - | WhereOperators | WhereAttributeHash // for JSON columns | Col // reference another column | Fn - | OrOperator - | AndOperator | WhereGeometryOptions - | readonly (string | number | Buffer | WhereAttributeHash)[]; // implicit [Op.or] /** * A hash of attributes to describe your search. + * + * Possible key values: + * + * - An attribute name: `{ id: 1 }` + * - A nested attribute: `{ '$projects.id$': 1 }` + * - A JSON key: `{ 'object.key': 1 }` + * - A cast: `{ 'id::integer': 1 }` + * + * - A combination of the above: `{ '$join.attribute$.json.path::integer': 1 }` */ export type WhereAttributeHash = { - /** - * Possible key values: - * - A simple attribute name - * - A nested key for JSON columns - * - * { - * "meta.audio.length": { - * [Op.gt]: 20 - * } - * } - */ - [field in keyof TAttributes]?: WhereValue | WhereOptions; + // support 'attribute' & '$attribute$' + [AttributeName in keyof TAttributes as AttributeName extends string ? AttributeName | `$${AttributeName}$` : never]?: WhereAttributeHashValue; +} & { + [AttributeName in keyof TAttributes as AttributeName extends string ? + // support 'json.path', '$json$.path' + | `${AttributeName}.${string}` | `$${AttributeName}$.${string}` + // support 'attribute::cast', '$attribute$::cast', 'json.path::cast' & '$json$.path::cast' + | `${AttributeName | `$${AttributeName}$` | `${AttributeName}.${string}` | `$${AttributeName}$.${string}`}::${string}` + : never]?: WhereAttributeHashValue; +} & { + // support '$nested.attribute$', '$nested.attribute$::cast', '$nested.attribute$.json.path', & '$nested.attribute$.json.path::cast' + // TODO [2022-05-26]: Remove this ts-ignore once we drop support for TS < 4.4 + // TypeScript < 4.4 does not support using a Template Literal Type as a key. + // note: this *must* be a ts-ignore, as it works in ts >= 4.4 + // @ts-ignore + [attribute: `$${string}.${string}$` | `$${string}.${string}$::${string}` | `$${string}.${string}$.${string}` | `$${string}.${string}$.${string}::${string}`]: WhereAttributeHashValue; } + +/** + * Types that can be compared to an attribute in a WHERE context. + */ +export type WhereAttributeHashValue = + | AllowNotOrAndRecursive< + // if the right-hand side is an array, it will be equal to Op.in + // otherwise it will be equal to Op.eq + // Exception: array attribtues always use Op.eq, never Op.in. + | AttributeType extends any[] + ? WhereOperators[typeof Op.eq] | WhereOperators + : ( + | WhereOperators[typeof Op.in] + | WhereOperators[typeof Op.eq] + | WhereOperators + ) + > + // TODO: this needs a simplified version just for JSON columns + | WhereAttributeHash // for JSON columns + /** * Through options for Include Options */ @@ -522,8 +762,6 @@ export interface IndexHintable { indexHints?: IndexHint[]; } -type Omit = Pick> - /** * Options that are passed to any model creating a SELECT query * @@ -536,7 +774,7 @@ export interface FindOptions * A list of associations to eagerly load using a left join (a single association is also supported). Supported is either * `{ include: Model1 }`, `{ include: [ Model1, Model2, ...]}`, `{ include: [{ model: Model1, as: 'Alias' }]}` or * `{ include: [{ all: true }]}`. - * If your association are set up with an `as` (eg. `X.hasMany(Y, { as: 'Z }`, you need to specify Z in + * If your association are set up with an `as` (eg. `X.hasMany(Y, { as: 'Z' }`, you need to specify Z in * the as attribute when eager loading Y). */ include?: Includeable | Includeable[]; @@ -555,10 +793,37 @@ export interface FindOptions group?: GroupOption; /** - * Limit the results + * Limits how many items will be retrieved by the operation. + * + * If `limit` and `include` are used together, Sequelize will turn the `subQuery` option on by default. + * This is done to ensure that `limit` only impacts the Model on the same level as the `limit` option. + * + * You can disable this behavior by explicitly setting `subQuery: false`, however `limit` will then + * affect the total count of returned values, including eager-loaded associations, instead of just one table. + * + * @example + * // in the following query, `limit` only affects the "User" model. + * // This will return 2 users, each including all of their projects. + * User.findAll({ + * limit: 2, + * include: [User.associations.projects], + * }); + * + * @example + * // in the following query, `limit` affects the total number of returned values, eager-loaded associations included. + * // This may return 2 users, each with one project, + * // or 1 user with 2 projects. + * User.findAll({ + * limit: 2, + * include: [User.associations.projects], + * subQuery: false, + * }); */ limit?: number; + // TODO: document this - this is an undocumented property but it exists and there are tests for it. + groupedLimit?: unknown; + /** * Skip the results; */ @@ -589,7 +854,10 @@ export interface FindOptions having?: WhereOptions; /** - * Use sub queries (internal) + * Use sub queries (internal). + * + * If unspecified, this will `true` by default if `limit` is specified, and `false` otherwise. + * See {@link FindOptions#limit} for more information. */ subQuery?: boolean; } @@ -620,6 +888,7 @@ export interface CountOptions /** * GROUP BY in sql * Used in conjunction with `attributes`. + * * @see Projectable */ group?: GroupOption; @@ -637,7 +906,7 @@ export type CountWithOptions = SetRequired extends CountOptions, FindOptions { } -interface GroupedCountResultItem { +export interface GroupedCountResultItem { [key: string]: unknown // projected attributes count: number // the count for each group } @@ -753,6 +1022,12 @@ export interface UpsertOptions extends Logging, Transactionab * Run validations before the row is inserted */ validate?: boolean; + /** + * An optional parameter that specifies a where clause for the `ON CONFLICT` part of the query + * (in particular: for applying to partial unique indexes). + * Only supported in Postgres >= 9.5 and SQLite >= 3.24.0 + */ + conflictWhere?: WhereOptions; /** * Optional override for the conflict fields in the ON CONFLICT part of the query. * Only supported in Postgres >= 9.5 and SQLite >= 3.24.0 @@ -803,6 +1078,17 @@ export interface BulkCreateOptions extends Logging, Transacti * Return all columns or only the specified columns for the affected rows (only for postgres) */ returning?: boolean | (keyof TAttributes)[]; + /** + * An optional parameter to specify a where clause for partial unique indexes + * (note: `ON CONFLICT WHERE` not `ON CONFLICT DO UPDATE WHERE`). + * Only supported in Postgres >= 9.5 and sqlite >= 9.5 + */ + conflictWhere?: WhereOptions; + /** + * Optional override for the conflict fields in the ON CONFLICT part of the query. + * Only supported in Postgres >= 9.5 and SQLite >= 3.24.0 + */ + conflictAttributes?: Array; } /** @@ -1018,6 +1304,11 @@ export interface SaveOptions extends Logging, Transactionable * @default false */ omitNull?: boolean; + + /** + * Return the affected rows (only for postgres) + */ + returning?: boolean | Array; } /** @@ -1250,6 +1541,7 @@ export interface ColumnOptions { /** * If false, the column will have a NOT NULL constraint, and a not null validation will be run before an * instance is saved. + * * @default true */ allowNull?: boolean; @@ -1393,7 +1685,7 @@ export type ModelAttributes = { /** * Possible types for primary keys */ -export type Identifier = number | string | Buffer; +export type Identifier = number | bigint | string | Buffer; /** * Options for model definition @@ -1534,9 +1826,23 @@ export interface ModelOptions { * OptimisticLockingError error when stale instances are saved. * - If string: Uses the named attribute. * - If boolean: Uses `version`. + * * @default false */ version?: boolean | string; + + /** + * Specify the scopes merging strategy (default 'overwrite'). Valid values are 'and' and 'overwrite'. + * When the 'and' strategy is set, scopes will be grouped using the Op.and operator. + * For instance merging scopes containing `{ where: { myField: 1 }}` and `{ where: { myField: 2 }}` will result in + * `{ where: { [Op.and]: [{ myField: 1 }, { myField: 2 }] } }`. + * When the 'overwrite' strategy is set, scopes containing the same attribute in a where clause will be overwritten by the lastly defined one. + * For instance merging scopes containing `{ where: { myField: 1 }}` and `{ where: { myField: 2 }}` will result in + * `{ where: { myField: 2 } }`. + * + * @default false + */ + whereMergeStrategy?: 'and' | 'overwrite'; } /** @@ -1582,6 +1888,11 @@ export abstract class Model6]: make this a non-exported symbol (same as the one in hooks.d.ts) + /** + * Object that contains underlying model data + */ + dataValues: TModelAttributes; + /** * A similar dummy variable that doesn't exist on the real object. Do not * try to access this in real code. @@ -1616,15 +1927,20 @@ export abstract class Model7]: Remove `rawAttributes` in v8 /** - * The attributes of the model + * The attributes of the model. + * + * @deprecated use {@link Model.getAttributes} for better typings. */ public static readonly rawAttributes: { [attribute: string]: ModelAttributeColumnOptions }; /** * Returns the attributes of the model */ - public static getAttributes(): { [attribute: string]: ModelAttributeColumnOptions }; + public static getAttributes(this: ModelStatic): { + readonly [Key in keyof Attributes]: ModelAttributeColumnOptions + }; /** * Reference to the sequelize instance the model was initialized with @@ -1672,11 +1988,16 @@ export abstract class Model, M extends InstanceType>( this: MS, - attributes: ModelAttributes>, options: InitOptions + attributes: ModelAttributes< + M, + // 'foreign keys' are optional in Model.init as they are added by association declaration methods + Optional, BrandedKeysOf, typeof ForeignKeyBrand>> + >, + options: InitOptions ): MS; /** @@ -1775,7 +2096,7 @@ export abstract class Model= 42 * ``` * - * @return Model A reference to the model, with the scope(s) applied. Calling scope again on the returned + * @returns Model A reference to the model, with the scope(s) applied. Calling scope again on the returned * model will clear the previous scope. */ public static scope( @@ -1903,7 +2224,7 @@ export abstract class Model( @@ -1915,7 +2236,8 @@ export abstract class Model( this: ModelStatic, @@ -1926,7 +2248,8 @@ export abstract class Model( this: ModelStatic, @@ -2132,7 +2455,7 @@ export abstract class Model The number of destroyed rows + * @returns Promise The number of destroyed rows */ public static destroy( this: ModelStatic, @@ -2157,62 +2480,84 @@ export abstract class Model]?: Attributes[key] | Fn | Col | Literal; }, - options: UpdateOptions> - ): Promise<[number, M[]]>; + options: Omit>, 'returning'> + & { returning: Exclude>['returning'], undefined | false> } + ): Promise<[affectedCount: number, affectedRows: M[]]>; /** - * Increments a single field. + * Update multiple instances that match the where options. The promise returns an array with one or two + * elements. The first element is always the number of affected rows, while the second element is the actual + * affected rows (only supported in postgres and mssql with `options.returning` true.) */ - public static increment( + public static update( this: ModelStatic, - field: keyof Attributes, - options: IncrementDecrementOptionsWithBy> - ): Promise; + values: { + [key in keyof Attributes]?: Attributes[key] | Fn | Col | Literal; + }, + options: UpdateOptions> + ): Promise<[affectedCount: number]>; /** - * Increments multiple fields by the same value. + * Increments the value of one or more attributes. + * + * The increment is done using a `SET column = column + X WHERE foo = 'bar'` query. + * + * @example increment number by 1 + * ```javascript + * Model.increment('number', { where: { foo: 'bar' }); + * ``` + * + * @example increment number and count by 2 + * ```javascript + * Model.increment(['number', 'count'], { by: 2, where: { foo: 'bar' } }); + * ``` + * + * @example increment answer by 42, and decrement tries by 1 + * ```javascript + * // `by` cannot be used, as each attribute specifies its own value + * Model.increment({ answer: 42, tries: -1}, { where: { foo: 'bar' } }); + * ``` + * + * @param fields If a string is provided, that column is incremented by the + * value of `by` given in options. If an array is provided, the same is true for each column. + * If an object is provided, each key is incremented by the corresponding value, `by` is ignored. + * + * @returns an array of affected rows or with affected count if `options.returning` is true, whenever supported by dialect */ - public static increment( + static increment( this: ModelStatic, - fields: ReadonlyArray>, + fields: AllowReadonlyArray>, options: IncrementDecrementOptionsWithBy> - ): Promise; - - /** - * Increments multiple fields by different values. - */ - public static increment( + ): Promise<[affectedRows: M[], affectedCount?: number]>; + static increment( this: ModelStatic, fields: { [key in keyof Attributes]?: number }, options: IncrementDecrementOptions> - ): Promise; - - /** - * Decrements a single field. - */ - public static decrement( - this: ModelStatic, - field: keyof Attributes, - options: IncrementDecrementOptionsWithBy> - ): Promise; + ): Promise<[affectedRows: M[], affectedCount?: number]>; /** - * Decrements multiple fields by the same value. + * Decrements the value of one or more attributes. + * + * Works like {@link Model.increment} + * + * @param fields If a string is provided, that column is incremented by the + * value of `by` given in options. If an array is provided, the same is true for each column. + * If an object is provided, each key is incremented by the corresponding value, `by` is ignored. + * + * @returns an array of affected rows or with affected count if `options.returning` is true, whenever supported by dialect + * + * @since 4.36.0 */ - public static decrement( + static decrement( this: ModelStatic, - fields: (keyof Attributes)[], + fields: AllowReadonlyArray>, options: IncrementDecrementOptionsWithBy> - ): Promise; - - /** - * Decrements multiple fields by different values. - */ - public static decrement( + ): Promise<[affectedRows: M[], affectedCount?: number]>; + static decrement( this: ModelStatic, fields: { [key in keyof Attributes]?: number }, options: IncrementDecrementOptions> - ): Promise; + ): Promise<[affectedRows: M[], affectedCount?: number]>; /** * Run a describe query on the table. The result will be return to the listener as a hash of attributes and @@ -2554,6 +2899,7 @@ export abstract class Model HookReturn): void; @@ -2561,6 +2907,7 @@ export abstract class Model HookReturn): void; @@ -2568,6 +2915,7 @@ export abstract class Model HookReturn): void; @@ -2575,6 +2923,7 @@ export abstract class Model HookReturn): void; @@ -2728,9 +3077,10 @@ export abstract class Model, options?: BuildOptions); + constructor(values?: MakeNullishOptional, options?: BuildOptions); /** * Get an object representing the query for this instance, use with `options.where` @@ -2937,7 +3287,7 @@ export abstract class Model = new () => Model; +export type ModelType = new () => Model; type NonConstructorKeys = ({[P in keyof T]: T[P] extends new () => any ? never : P })[keyof T]; type NonConstructor = Pick>; @@ -2945,33 +3295,67 @@ type NonConstructor = Pick>; /** @deprecated use ModelStatic */ export type ModelCtor = ModelStatic; -export type ModelDefined = ModelStatic>; +export type ModelDefined = ModelStatic>; // remove the existing constructor that tries to return `Model<{},{}>` which would be incompatible with models that have typing defined & replace with proper constructor. export type ModelStatic = NonConstructor & { new(): M }; export default Model; +/** + * Type will be true is T is branded with Brand, false otherwise + */ +// How this works: +// - `A extends B` will be true if A has *at least* all the properties of B +// - If we do `A extends Omit` - the result will only be true if A did not have Checked to begin with +// - So if we want to check if T is branded, we remove the brand, and check if they list of keys is still the same. +// we exclude Null & Undefined so "field: Brand | null" is still detected as branded +// this is important because "Brand" are transformed into "Brand | null" to not break null & undefined +type IsBranded = keyof NonNullable extends keyof Omit, Brand> + ? false + : true; + +type BrandedKeysOf = { + [P in keyof T]-?: IsBranded extends true ? P : never +}[keyof T]; + /** * Dummy Symbol used as branding by {@link NonAttribute}. * * Do not export, Do not use. */ declare const NonAttributeBrand: unique symbol; -interface NonAttributeBrandedArray extends Array { - [NonAttributeBrand]: true -} /** * This is a Branded Type. * You can use it to tag fields from your class that are NOT attributes. * They will be ignored by {@link InferAttributes} and {@link InferCreationAttributes} */ -export type NonAttribute = T extends Array - // Arrays are a special case when branding. Both sides need to be an array, - // otherwise property access breaks. - ? T | NonAttributeBrandedArray - : T | { [NonAttributeBrand]: true }; // this MUST be a union or nothing will be assignable to this type. +export type NonAttribute = + // we don't brand null & undefined as they can't have properties. + // This means `NonAttribute` will not work, but who makes an attribute that only accepts null? + // Note that `NonAttribute` does work! + T extends null | undefined ? T + : (T & { [NonAttributeBrand]?: true }); + +/** + * Dummy Symbol used as branding by {@link ForeignKey}. + * + * Do not export, Do not use. + */ +declare const ForeignKeyBrand: unique symbol; + +/** + * This is a Branded Type. + * You can use it to tag fields from your class that are foreign keys. + * They will become optional in {@link Model.init} (as foreign keys are added by association methods, like {@link Model.hasMany}. + */ +export type ForeignKey = + // we don't brand null & undefined as they can't have properties. + // This means `ForeignKey` will not work, but who makes an attribute that only accepts null? + // Note that `ForeignKey` does work! + T extends null | undefined ? T + : (T & { [ForeignKeyBrand]?: true }); /** * Option bag for {@link InferAttributes}. @@ -3028,17 +3412,8 @@ type InferAttributesOptions = { omit?: Excluded }; export type InferAttributes< M extends Model, Options extends InferAttributesOptions = { omit: never } -> = { - [Key in keyof M as - M[Key] extends AnyFunction ? never - : { [NonAttributeBrand]: true } extends M[Key] ? never - // array special case - : M[Key] extends NonAttributeBrandedArray ? never - : Key extends keyof Model ? never - // check 'omit' option is provided - : Options['omit'] extends string ? (Key extends Options['omit'] ? never : Key) - : Key - ]: M[Key] + > = { + [Key in keyof M as InternalInferAttributeKeysFromFields]: M[Key] }; /** @@ -3047,9 +3422,6 @@ export type InferAttributes< * Do not export, Do not use. */ declare const CreationAttributeBrand: unique symbol; -interface CreationAttributeBrandedArray extends Array { - [CreationAttributeBrand]: true -} /** * This is a Branded Type. @@ -3057,11 +3429,12 @@ interface CreationAttributeBrandedArray extends Array { * * For use with {@link InferCreationAttributes}. */ -export type CreationOptional = T extends Array - // Arrays are a special case when branding. Both sides need to be an array, - // otherwise property access breaks. - ? T | CreationAttributeBrandedArray - : T | { [CreationAttributeBrand]: true }; // this MUST be a union or nothing will be assignable to this type. +export type CreationOptional = + // we don't brand null & undefined as they can't have properties. + // This means `CreationOptional` will not work, but who makes an attribute that only accepts null? + // Note that `CreationOptional` does work! + T extends null | undefined ? T + : (T & { [CreationAttributeBrand]?: true }); /** * Utility type to extract Creation Attributes of a given Model class. @@ -3081,24 +3454,33 @@ export type CreationOptional = T extends Array export type InferCreationAttributes< M extends Model, Options extends InferAttributesOptions = { omit: never } -> = { - [Key in keyof M as - M[Key] extends AnyFunction ? never - : { [NonAttributeBrand]: true } extends M[Key] ? never - // array special case - : M[Key] extends NonAttributeBrandedArray ? never - : Key extends keyof Model ? never - // check 'omit' option is provided - : Options['omit'] extends string ? (Key extends Options['omit'] ? never : Key) - : Key - // it is normal that the brand extends the type. - // We're checking if it's in the type. - ]: { [CreationAttributeBrand]: true } extends M[Key] ? (M[Key] | undefined) - // array special case - : CreationAttributeBrandedArray extends M[Key] ? (M[Key] | undefined) + > = { + [Key in keyof M as InternalInferAttributeKeysFromFields]: IsBranded extends true + ? (M[Key] | undefined) : M[Key] }; +/** + * @private + * + * Internal type used by {@link InferCreationAttributes} and {@link InferAttributes} to exclude + * attributes that are: + * - functions + * - branded using {@link NonAttribute} + * - inherited from {@link Model} + * - Excluded manually using {@link InferAttributesOptions#omit} + */ +type InternalInferAttributeKeysFromFields> = + // fields inherited from Model are all excluded + Key extends keyof Model ? never + // functions are always excluded + : M[Key] extends AnyFunction ? never + // fields branded with NonAttribute are excluded + : IsBranded extends true ? never + // check 'omit' option is provided & exclude those listed in it + : Options['omit'] extends string ? (Key extends Options['omit'] ? never : Key) + : Key; + // in v7, we should be able to drop InferCreationAttributes and InferAttributes, // resolving this confusion. /** @@ -3110,7 +3492,7 @@ export type InferCreationAttributes< * @example * function buildModel(modelClass: ModelStatic, attributes: CreationAttributes) {} */ -export type CreationAttributes = MakeUndefinedOptional; +export type CreationAttributes = MakeNullishOptional; /** * Returns the creation attributes of a given Model. diff --git a/lib/model.js b/src/model.js similarity index 96% rename from lib/model.js rename to src/model.js index 971929411849..368590a84e8a 100644 --- a/lib/model.js +++ b/src/model.js @@ -824,10 +824,16 @@ class Model { if (Array.isArray(objValue) && Array.isArray(srcValue)) { return _.union(objValue, srcValue); } + if (['where', 'having'].includes(key)) { + if (this.options && this.options.whereMergeStrategy === 'and') { + return combineWheresWithAnd(objValue, srcValue); + } + if (srcValue instanceof Utils.SequelizeMethod) { srcValue = { [Op.and]: srcValue }; } + if (_.isPlainObject(objValue) && _.isPlainObject(srcValue)) { return Object.assign(objValue, srcValue); } @@ -848,7 +854,7 @@ class Model { } static _assignOptions(...args) { - return this._baseMerge(...args, this._mergeFunction); + return this._baseMerge(...args, this._mergeFunction.bind(this)); } static _defaultsOptions(target, opts) { @@ -945,6 +951,7 @@ class Model { * @param {string} [options.initialAutoIncrement] Set the initial AUTO_INCREMENT value for the table in MySQL. * @param {object} [options.hooks] An object of hook function that are called before and after certain lifecycle events. The possible hooks are: beforeValidate, afterValidate, validationFailed, beforeBulkCreate, beforeBulkDestroy, beforeBulkUpdate, beforeCreate, beforeDestroy, beforeUpdate, afterCreate, beforeSave, afterDestroy, afterUpdate, afterBulkCreate, afterSave, afterBulkDestroy and afterBulkUpdate. See Hooks for more information about hook functions and their signatures. Each property can either be a function, or an array of functions. * @param {object} [options.validate] An object of model wide validations. Validations have access to all model values via `this`. If the validator function takes an argument, it is assumed to be async, and is called with a callback that accepts an optional error. + * @param {'and'|'overwrite'} [options.whereMergeStrategy] Specify the scopes merging strategy (default 'overwrite'). 'and' strategy will merge `where` properties of scopes together by adding `Op.and` at the top-most level. 'overwrite' strategy will overwrite similar attributes using the lastly defined one. * * @returns {Model} */ @@ -993,6 +1000,7 @@ class Model { defaultScope: {}, scopes: {}, indexes: [], + whereMergeStrategy: 'overwrite', ...options }; @@ -1026,6 +1034,11 @@ class Model { } }); + if (!_.includes(['and', 'overwrite'], this.options && this.options.whereMergeStrategy)) { + throw new Error(`Invalid value ${this.options && this.options.whereMergeStrategy} for whereMergeStrategy. Allowed values are 'and' and 'overwrite'.`); + } + + this.rawAttributes = _.mapValues(attributes, (attribute, name) => { attribute = this.sequelize.normalizeAttribute(attribute); @@ -1325,19 +1338,30 @@ class Model { if (options.hooks) { await this.runHooks('beforeSync', options); } + + const tableName = this.getTableName(options); + + let tableExists; if (options.force) { await this.drop(options); + tableExists = false; + } else { + tableExists = await this.queryInterface.tableExists(tableName, options); } - const tableName = this.getTableName(options); - - await this.queryInterface.createTable(tableName, attributes, options, this); + if (!tableExists) { + await this.queryInterface.createTable(tableName, attributes, options, this); + } else { + // enums are always updated, even if alter is not set. createTable calls it too. + await this.queryInterface.ensureEnums(tableName, attributes, options, this); + } - if (options.alter) { + if (tableExists && options.alter) { const tableInfos = await Promise.all([ this.queryInterface.describeTable(tableName, options), this.queryInterface.getForeignKeyReferencesForTable(tableName, options) ]); + const columns = tableInfos[0]; // Use for alter foreign keys const foreignKeyReferences = tableInfos[1]; @@ -1380,13 +1404,15 @@ class Model { } } } + await this.queryInterface.changeColumn(tableName, columnName, currentAttribute, options); } } } - let indexes = await this.queryInterface.showIndex(tableName, options); - indexes = this._indexes.filter(item1 => - !indexes.some(item2 => item1.name === item2.name) + + const existingIndexes = await this.queryInterface.showIndex(tableName, options); + const missingIndexes = this._indexes.filter(item1 => + !existingIndexes.some(item2 => item1.name === item2.name) ).sort((index1, index2) => { if (this.sequelize.options.dialect === 'postgres') { // move concurrent indexes to the bottom to avoid weird deadlocks @@ -1397,7 +1423,7 @@ class Model { return 0; }); - for (const index of indexes) { + for (const index of missingIndexes) { await this.queryInterface.addIndex(tableName, { ...options, ...index }); } @@ -1677,7 +1703,7 @@ class Model { * @param {Array} [options.attributes.include] Select all the attributes of the model, plus some additional ones. Useful for aggregations, e.g. `{ attributes: { include: [[sequelize.fn('COUNT', sequelize.col('id')), 'total']] }` * @param {Array} [options.attributes.exclude] Select all the attributes of the model, except some few. Useful for security purposes e.g. `{ attributes: { exclude: ['password'] } }` * @param {boolean} [options.paranoid=true] If true, only non-deleted records will be returned. If false, both deleted and non-deleted records will be returned. Only applies if `options.paranoid` is true for the model. - * @param {Array} [options.include] A list of associations to eagerly load using a left join. Supported is either `{ include: [ Model1, Model2, ...]}` or `{ include: [{ model: Model1, as: 'Alias' }]}` or `{ include: ['Alias']}`. If your association are set up with an `as` (eg. `X.hasMany(Y, { as: 'Z }`, you need to specify Z in the as attribute when eager loading Y). + * @param {Array} [options.include] A list of associations to eagerly load using a left join. Supported is either `{ include: [ Model1, Model2, ...]}` or `{ include: [{ model: Model1, as: 'Alias' }]}` or `{ include: ['Alias']}`. If your association are set up with an `as` (eg. `X.hasMany(Y, { as: 'Z' }`, you need to specify Z in the as attribute when eager loading Y). * @param {Model} [options.include[].model] The model you want to eagerly load * @param {string} [options.include[].as] The alias of the relation, in case the model you want to eagerly load is aliased. For `hasOne` / `belongsTo`, this should be the singular name, and for `hasMany`, it should be the plural * @param {Association} [options.include[].association] The association you want to eagerly load. (This can be used instead of providing a model/as pair) @@ -1708,6 +1734,7 @@ class Model { * @param {string} [options.searchPath=DEFAULT] An optional parameter to specify the schema search_path (Postgres only) * @param {boolean|Error} [options.rejectOnEmpty=false] Throws an error when no records found * @param {boolean} [options.dotNotation] Allows including tables having the same attribute/column names - which have a dot in them. + * @param {boolean} [options.nest=false] If true, transforms objects with `.` separated property names into nested objects. * * @see * {@link Sequelize#query} @@ -1732,6 +1759,14 @@ class Model { tableNames[this.getTableName(options)] = true; options = Utils.cloneDeep(options); + // Add CLS transaction + if (options.transaction === undefined && this.sequelize.constructor._cls) { + const t = this.sequelize.constructor._cls.get('transaction'); + if (t) { + options.transaction = t; + } + } + _.defaults(options, { hooks: true }); // set rejectOnEmpty option, defaults to model options @@ -1889,10 +1924,10 @@ class Model { /** * Search for a single instance by its primary key._ * - * @param {number|string|Buffer} param The value of the desired instance's primary key. - * @param {object} [options] find options - * @param {Transaction} [options.transaction] Transaction to run query under - * @param {string} [options.searchPath=DEFAULT] An optional parameter to specify the schema search_path (Postgres only) + * @param {number|bigint|string|Buffer} param The value of the desired instance's primary key. + * @param {object} [options] find options + * @param {Transaction} [options.transaction] Transaction to run query under + * @param {string} [options.searchPath=DEFAULT] An optional parameter to specify the schema search_path (Postgres only) * * @see * {@link Model.findAll} for a full explanation of options, Note that options.where is not supported. @@ -1907,7 +1942,7 @@ class Model { options = Utils.cloneDeep(options) || {}; - if (typeof param === 'number' || typeof param === 'string' || Buffer.isBuffer(param)) { + if (typeof param === 'number' || typeof param === 'bigint' || typeof param === 'string' || Buffer.isBuffer(param)) { options.where = { [this.primaryKeyAttribute]: param }; @@ -1938,6 +1973,14 @@ class Model { } options = Utils.cloneDeep(options); + // Add CLS transaction + if (options.transaction === undefined && this.sequelize.constructor._cls) { + const t = this.sequelize.constructor._cls.get('transaction'); + if (t) { + options.transaction = t; + } + } + if (options.limit === undefined) { const uniqueSingleColumns = _.chain(this.uniqueKeys).values().filter(c => c.fields.length === 1).map('column').value(); @@ -2048,6 +2091,15 @@ class Model { static async count(options) { options = Utils.cloneDeep(options); options = _.defaults(options, { hooks: true }); + + // Add CLS transaction + if (options.transaction === undefined && this.sequelize.constructor._cls) { + const t = this.sequelize.constructor._cls.get('transaction'); + if (t) { + options.transaction = t; + } + } + options.raw = true; if (options.hooks) { await this.runHooks('beforeCount', options); @@ -2494,6 +2546,14 @@ class Model { ...Utils.cloneDeep(options) }; + // Add CLS transaction + if (options.transaction === undefined && this.sequelize.constructor._cls) { + const t = this.sequelize.constructor._cls.get('transaction'); + if (t) { + options.transaction = t; + } + } + const createdAtAttr = this._timestampAttributes.createdAt; const updatedAtAttr = this._timestampAttributes.updatedAt; const hasPrimary = this.primaryKeyField in values || this.primaryKeyAttribute in values; @@ -2572,6 +2632,7 @@ class Model { * @param {boolean} [options.individualHooks=false] Run before / after create hooks for each individual Instance? BulkCreate hooks will still be run if options.hooks is true. * @param {boolean} [options.ignoreDuplicates=false] Ignore duplicate values for primary keys? (not supported by MSSQL or Postgres < 9.5) * @param {Array} [options.updateOnDuplicate] Fields to update if row key already exists (on duplicate key update)? (only supported by MySQL, MariaDB, SQLite >= 3.24.0 & Postgres >= 9.5). + * @param {Array} [options.conflictAttributes] Optional override for the conflict fields in the ON CONFLICT part of the query. Only supported in Postgres >= 9.5 and SQLite >= 3.24.0 * @param {Transaction} [options.transaction] Transaction to run query under * @param {Function} [options.logging=false] A function that gets executed while running the query to log the sql. * @param {boolean} [options.benchmark=false] Pass query execution time in milliseconds as second argument to logging function (options.logging). @@ -2589,6 +2650,14 @@ class Model { const now = Utils.now(this.sequelize.options.dialect); options = Utils.cloneDeep(options); + // Add CLS transaction + if (options.transaction === undefined && this.sequelize.constructor._cls) { + const t = this.sequelize.constructor._cls.get('transaction'); + if (t) { + options.transaction = t; + } + } + options.model = this; if (!options.includeValidated) { @@ -2617,8 +2686,8 @@ class Model { options.returning = true; } } - - if (options.ignoreDuplicates && ['mssql', 'db2'].includes(dialect)) { + if (options.ignoreDuplicates && !this.sequelize.dialect.supports.inserts.ignoreDuplicates && + !this.sequelize.dialect.supports.inserts.onConflictDoNothing) { throw new Error(`${dialect} does not support the ignoreDuplicates option.`); } if (options.updateOnDuplicate && (dialect !== 'mysql' && dialect !== 'mariadb' && dialect !== 'sqlite' && dialect !== 'postgres')) { @@ -2749,23 +2818,29 @@ class Model { if (options.updateOnDuplicate) { options.updateOnDuplicate = options.updateOnDuplicate.map(attr => model.rawAttributes[attr].field || attr); - const upsertKeys = []; + if (options.conflictAttributes) { + options.upsertKeys = options.conflictAttributes.map( + attrName => model.rawAttributes[attrName].field || attrName + ); + } else { + const upsertKeys = []; - for (const i of model._indexes) { - if (i.unique && !i.where) { // Don't infer partial indexes - upsertKeys.push(...i.fields); + for (const i of model._indexes) { + if (i.unique && !i.where) { // Don't infer partial indexes + upsertKeys.push(...i.fields); + } } - } - const firstUniqueKey = Object.values(model.uniqueKeys).find(c => c.fields.length > 0); + const firstUniqueKey = Object.values(model.uniqueKeys).find(c => c.fields.length > 0); - if (firstUniqueKey && firstUniqueKey.fields) { - upsertKeys.push(...firstUniqueKey.fields); - } + if (firstUniqueKey && firstUniqueKey.fields) { + upsertKeys.push(...firstUniqueKey.fields); + } - options.upsertKeys = upsertKeys.length > 0 - ? upsertKeys - : Object.values(model.primaryKeys).map(x => x.field); + options.upsertKeys = upsertKeys.length > 0 + ? upsertKeys + : Object.values(model.primaryKeys).map(x => x.field); + } } // Map returning attributes to fields @@ -2851,7 +2926,7 @@ class Model { if (include.association.through.model.rawAttributes[attr]._autoGenerated || attr === include.association.foreignKey || attr === include.association.otherKey || - typeof associationInstance[include.association.through.model.name][attr] === undefined) { + typeof associationInstance[include.association.through.model.name][attr] === 'undefined') { continue; } values[attr] = associationInstance[include.association.through.model.name][attr]; @@ -2945,6 +3020,14 @@ class Model { static async destroy(options) { options = Utils.cloneDeep(options); + // Add CLS transaction + if (options.transaction === undefined && this.sequelize.constructor._cls) { + const t = this.sequelize.constructor._cls.get('transaction'); + if (t) { + options.transaction = t; + } + } + this._injectScope(options); if (!options || !(options.where || options.truncate)) { @@ -3035,6 +3118,14 @@ class Model { ...options }; + // Add CLS transaction + if (options.transaction === undefined && this.sequelize.constructor._cls) { + const t = this.sequelize.constructor._cls.get('transaction'); + if (t) { + options.transaction = t; + } + } + options.type = QueryTypes.RAW; options.model = this; @@ -3100,6 +3191,14 @@ class Model { static async update(values, options) { options = Utils.cloneDeep(options); + // Add CLS transaction + if (options.transaction === undefined && this.sequelize.constructor._cls) { + const t = this.sequelize.constructor._cls.get('transaction'); + if (t) { + options.transaction = t; + } + } + this._injectScope(options); this._optionsMustContainWhere(options); @@ -3890,6 +3989,15 @@ class Model { } options = Utils.cloneDeep(options); + + // Add CLS transaction + if (options.transaction === undefined && this.sequelize.constructor._cls) { + const t = this.sequelize.constructor._cls.get('transaction'); + if (t) { + options.transaction = t; + } + } + options = _.defaults(options, { hooks: true, validate: true @@ -4103,7 +4211,7 @@ class Model { if (include.association.through.model.rawAttributes[attr]._autoGenerated || attr === include.association.foreignKey || attr === include.association.otherKey || - typeof instance[include.association.through.model.name][attr] === undefined) { + typeof instance[include.association.through.model.name][attr] === 'undefined') { continue; } values0[attr] = instance[include.association.through.model.name][attr]; @@ -4210,6 +4318,15 @@ class Model { if (Array.isArray(options)) options = { fields: options }; options = Utils.cloneDeep(options); + + // Add CLS transaction + if (options.transaction === undefined && this.sequelize.constructor._cls) { + const t = this.sequelize.constructor._cls.get('transaction'); + if (t) { + options.transaction = t; + } + } + const setOptions = Utils.cloneDeep(options); setOptions.attributes = options.fields; this.set(values, setOptions); @@ -4244,6 +4361,14 @@ class Model { ...options }; + // Add CLS transaction + if (options.transaction === undefined && this.sequelize.constructor._cls) { + const t = this.sequelize.constructor._cls.get('transaction'); + if (t) { + options.transaction = t; + } + } + // Run before hook if (options.hooks) { await this.constructor.runHooks('beforeDestroy', this, options); @@ -4313,6 +4438,14 @@ class Model { ...options }; + // Add CLS transaction + if (options.transaction === undefined && this.sequelize.constructor._cls) { + const t = this.sequelize.constructor._cls.get('transaction'); + if (t) { + options.transaction = t; + } + } + // Run before hook if (options.hooks) { await this.constructor.runHooks('beforeRestore', this, options); @@ -4495,6 +4628,7 @@ class Model { * @param {Model} [options.through.model] The model used to join both sides of the N:M association. * @param {object} [options.through.scope] A key/value set that will be used for association create and find defaults on the through model. (Remember to add the attributes to the through model) * @param {boolean} [options.through.unique=true] If true a unique key will be generated from the foreign keys used (might want to turn this off and create specific unique keys when using scopes) + * @param {boolean} [options.through.paranoid=false] If true the generated join table will be paranoid * @param {string|object} [options.as] The alias of this association. If you provide a string, it should be plural, and will be singularized using node.inflection. If you want to control the singular version yourself, provide an object with `plural` and `singular` keys. See also the `name` option passed to `sequelize.define`. If you create multiple associations between the same tables, you should provide an alias to be able to distinguish between them. If you provide an alias when creating the association, you should provide the same alias when eager loading and when getting associated models. Defaults to the pluralized name of target * @param {string|object} [options.foreignKey] The name of the foreign key in the join table (representing the source model) or an object representing the type definition for the foreign column (see `Sequelize.define` for syntax). When using an object, you can add a `name` property to set the name of the column. Defaults to the name of source + primary key of source * @param {string|object} [options.otherKey] The name of the foreign key in the join table (representing the target model) or an object representing the type definition for the other column (see `Sequelize.define` for syntax). When using an object, you can add a `name` property to set the name of the column. Defaults to the name of target + primary key of target @@ -4562,6 +4696,58 @@ class Model { static belongsTo(target, options) {} // eslint-disable-line } +/** + * Unpacks an object that only contains a single Op.and key to the value of Op.and + * + * Internal method used by {@link combineWheresWithAnd} + * + * @param {WhereOptions} where The object to unpack + * @example `{ [Op.and]: [a, b] }` becomes `[a, b]` + * @example `{ [Op.and]: { key: val } }` becomes `{ key: val }` + * @example `{ [Op.or]: [a, b] }` remains as `{ [Op.or]: [a, b] }` + * @example `{ [Op.and]: [a, b], key: c }` remains as `{ [Op.and]: [a, b], key: c }` + * @private + */ +function unpackAnd(where) { + if (!_.isObject(where)) { + return where; + } + + const keys = Utils.getComplexKeys(where); + + // object is empty, remove it. + if (keys.length === 0) { + return; + } + + // we have more than just Op.and, keep as-is + if (keys.length !== 1 || keys[0] !== Op.and) { + return where; + } + + const andParts = where[Op.and]; + + return andParts; +} + +function combineWheresWithAnd(whereA, whereB) { + const unpackedA = unpackAnd(whereA); + + if (unpackedA === undefined) { + return whereB; + } + + const unpackedB = unpackAnd(whereB); + + if (unpackedB === undefined) { + return whereA; + } + + return { + [Op.and]: _.flatten([unpackedA, unpackedB]) + }; +} + Object.assign(Model, associationsMixin); Hooks.applyTo(Model, true); diff --git a/lib/operators.ts b/src/operators.ts similarity index 95% rename from lib/operators.ts rename to src/operators.ts index a6e581d96e9c..a3a30b0b971a 100644 --- a/lib/operators.ts +++ b/src/operators.ts @@ -478,7 +478,12 @@ interface OpTypes { readonly values: unique symbol; } -const Op: OpTypes = { +// Note: These symbols are registered in the Global Symbol Registry +// to counter bugs when two different versions of this library are loaded +// Source issue: https://github.com/sequelize/sequelize/issues/8663 +// This is not an endorsement of having two different versions of the library loaded at the same time, +// a lot more is going to silently break if you do this. +export const Op: OpTypes = { eq: Symbol.for('eq'), ne: Symbol.for('ne'), gte: Symbol.for('gte'), diff --git a/types/lib/query-types.d.ts b/src/query-types.d.ts similarity index 100% rename from types/lib/query-types.d.ts rename to src/query-types.d.ts diff --git a/lib/query-types.js b/src/query-types.js similarity index 100% rename from lib/query-types.js rename to src/query-types.js diff --git a/src/query.d.ts b/src/query.d.ts new file mode 100644 index 000000000000..2d7fa50eeefa --- /dev/null +++ b/src/query.d.ts @@ -0,0 +1,3 @@ +// TODO [>=7]: This is a legacy file to avoid introducing a breaking change in v6. Remove me in v7. + +export * from './dialects/abstract/query'; diff --git a/types/lib/sequelize.d.ts b/src/sequelize.d.ts similarity index 92% rename from types/lib/sequelize.d.ts rename to src/sequelize.d.ts index 12e98b40adb4..8f28ef43cc6d 100644 --- a/types/lib/sequelize.d.ts +++ b/src/sequelize.d.ts @@ -1,4 +1,4 @@ -import * as DataTypes from './data-types'; +import type { Options as RetryAsPromisedOptions } from 'retry-as-promised'; import { HookReturn, Hooks, SequelizeHooks } from './hooks'; import { ValidationOptions } from './instance-validator'; import { @@ -16,20 +16,23 @@ import { ModelOptions, OrOperator, UpdateOptions, - WhereAttributeHash, WhereOperators, ModelCtor, Hookable, ModelType, CreationAttributes, Attributes, + ColumnReference, WhereAttributeHashValue, } from './model'; import { ModelManager } from './model-manager'; -import { QueryInterface, QueryOptions, QueryOptionsWithModel, QueryOptionsWithType, ColumnsDescription } from './query-interface'; +import { QueryInterface, QueryOptions, QueryOptionsWithModel, QueryOptionsWithType, ColumnsDescription } from './dialects/abstract/query-interface'; import QueryTypes = require('./query-types'); import { Transaction, TransactionOptions } from './transaction'; +import { Op } from './index'; import { Cast, Col, DeepWriteable, Fn, Json, Literal, Where } from './utils'; -import { ConnectionManager } from './connection-manager'; +import { Connection, ConnectionManager, GetConnectionOptions } from './dialects/abstract/connection-manager'; + +export type RetryOptions = RetryAsPromisedOptions; /** * Additional options for table altering during sync @@ -160,7 +163,7 @@ export interface Config { readonly protocol: 'tcp'; readonly native: boolean; readonly ssl: boolean; - readonly replication: boolean; + readonly replication: ReplicationOptions | false; readonly dialectModulePath: null | string; readonly keepDefaultTimezone?: boolean; readonly dialectOptions?: { @@ -169,12 +172,7 @@ export interface Config { }; } -export type Dialect = 'mysql' | 'postgres' | 'sqlite' | 'mariadb' | 'mssql'; - -export interface RetryOptions { - match?: (RegExp | string | Function)[]; - max?: number; -} +export type Dialect = 'mysql' | 'postgres' | 'sqlite' | 'mariadb' | 'mssql' | 'db2' | 'snowflake' | 'oracle'; /** * Options for the constructor of Sequelize main class @@ -307,7 +305,7 @@ export interface Options extends Logging { * * @default false */ - replication?: ReplicationOptions; + replication?: ReplicationOptions | false; /** * Connection pool options @@ -400,6 +398,13 @@ export interface Options extends Logging { * If defined the connection will use the provided schema instead of the default ("public"). */ schema?: string; + + /** + * Sequelize had to introduce a breaking change to fix vulnerability CVE-2023-22578. + * This option allows you to revert to the old behavior (unsafe-legacy), or to opt in to the new behavior (escape). + * The default behavior throws an error to warn you about the change (throw). + */ + attributeBehavior?: 'escape' | 'throw' | 'unsafe-legacy'; } export interface QueryOptionsTransactionRequired { } @@ -432,6 +437,7 @@ export class Sequelize extends Hooks { * username: self.sequelize.fn('upper', self.sequelize.col('username')) * }) * ``` + * * @param fn The function you want to call * @param args All further arguments will be passed as arguments to the function */ @@ -714,6 +720,26 @@ export class Sequelize extends Hooks { public static afterDisconnect(name: string, fn: (connection: unknown) => void): void; public static afterDisconnect(fn: (connection: unknown) => void): void; + + /** + * A hook that is run before attempting to acquire a connection from the pool + * + * @param name + * @param fn A callback function that is called with options + */ + public static beforePoolAcquire(name: string, fn: (options: GetConnectionOptions) => void): void; + public static beforePoolAcquire(fn: (options: GetConnectionOptions) => void): void; + + /** + * A hook that is run after successfully acquiring a connection from the pool + * + * @param name + * @param fn A callback function that is called with options + */ + public static afterPoolAcquire(name: string, fn: (connection: Connection, options: GetConnectionOptions) => void): void; + public static afterPoolAcquire(fn: (connection: Connection, options: GetConnectionOptions) => void): void; + + /** * A hook that is run before a find (select) query, after any { include: {all: ...} } options are expanded * @@ -789,6 +815,7 @@ export class Sequelize extends Hooks { /** * A hook that is run before sequelize.sync call + * * @param fn A callback function that is called with options passed to sequelize.sync */ public static beforeBulkSync(dname: string, fn: (options: SyncOptions) => HookReturn): void; @@ -796,6 +823,7 @@ export class Sequelize extends Hooks { /** * A hook that is run after sequelize.sync call + * * @param fn A callback function that is called with options passed to sequelize.sync */ public static afterBulkSync(name: string, fn: (options: SyncOptions) => HookReturn): void; @@ -803,6 +831,7 @@ export class Sequelize extends Hooks { /** * A hook that is run before Model.sync call + * * @param fn A callback function that is called with options passed to Model.sync */ public static beforeSync(name: string, fn: (options: SyncOptions) => HookReturn): void; @@ -810,6 +839,7 @@ export class Sequelize extends Hooks { /** * A hook that is run after Model.sync call + * * @param fn A callback function that is called with options passed to Model.sync */ public static afterSync(name: string, fn: (options: SyncOptions) => HookReturn): void; @@ -880,6 +910,7 @@ export class Sequelize extends Hooks { /** * Instantiate sequelize with an URI + * * @param uri A full database URI * @param options See above for possible options */ @@ -1088,6 +1119,7 @@ export class Sequelize extends Hooks { /** * A hook that is run before sequelize.sync call + * * @param fn A callback function that is called with options passed to sequelize.sync */ public beforeBulkSync(name: string, fn: (options: SyncOptions) => HookReturn): void; @@ -1095,6 +1127,7 @@ export class Sequelize extends Hooks { /** * A hook that is run after sequelize.sync call + * * @param fn A callback function that is called with options passed to sequelize.sync */ public afterBulkSync(name: string, fn: (options: SyncOptions) => HookReturn): void; @@ -1102,6 +1135,7 @@ export class Sequelize extends Hooks { /** * A hook that is run before Model.sync call + * * @param fn A callback function that is called with options passed to Model.sync */ public beforeSync(name: string, fn: (options: SyncOptions) => HookReturn): void; @@ -1109,6 +1143,7 @@ export class Sequelize extends Hooks { /** * A hook that is run after Model.sync call + * * @param fn A callback function that is called with options passed to Model.sync */ public afterSync(name: string, fn: (options: SyncOptions) => HookReturn): void; @@ -1421,6 +1456,7 @@ export class Sequelize extends Hooks { * username: self.sequelize.fn('upper', self.sequelize.col('username')) * }) * ``` + * * @param fn The function you want to call * @param args All further arguments will be passed as arguments to the function */ @@ -1454,14 +1490,14 @@ export function literal(val: string): Literal; * * @param args Each argument will be joined by AND */ -export function and(...args: (WhereOperators | WhereAttributeHash | Where)[]): AndOperator; +export function and>(...args: T): { [Op.and]: T }; /** * An OR query * * @param args Each argument will be joined by OR */ -export function or(...args: (WhereOperators | WhereAttributeHash | Where)[]): OrOperator; +export function or>(...args: T): { [Op.or]: T }; /** * Creates an object representing nested where conditions for postgres's json data-type. @@ -1473,28 +1509,57 @@ export function or(...args: (WhereOperators | WhereAttributeHash | Where)[] */ export function json(conditionsOrPath: string | object, value?: string | number | boolean): Json; -export type AttributeType = Fn | Col | Literal | ModelAttributeColumnOptions | string; +export type WhereLeftOperand = Fn | ColumnReference | Literal | Cast | ModelAttributeColumnOptions; + +// TODO [>6]: Remove +/** + * @deprecated use {@link WhereLeftOperand} instead. + */ +export type AttributeType = WhereLeftOperand; + +// TODO [>6]: Remove +/** + * @deprecated this is not used anymore, typing definitions for {@link where} have changed to more accurately reflect reality. + */ export type LogicType = Fn | Col | Literal | OrOperator | AndOperator | WhereOperators | string | symbol | null; /** - * A way of specifying attr = condition. + * A way of specifying "attr = condition". + * Can be used as a replacement for the POJO syntax (e.g. `where: { name: 'Lily' }`) when you need to compare a column that the POJO syntax cannot represent. + * + * @param leftOperand The left side of the comparison. + * - A value taken from YourModel.rawAttributes, to reference an attribute. + * The attribute must be defined in your model definition. + * - A Literal (using {@link Sequelize#literal}) + * - A SQL Function (using {@link Sequelize#fn}) + * - A Column name (using {@link Sequelize#col}) + * Note that simple strings to reference an attribute are not supported. You can use the POJO syntax instead. + * @param operator The comparison operator to use. If unspecified, defaults to {@link Op.eq}. + * @param rightOperand The right side of the comparison. Its value depends on the used operator. + * See {@link WhereOperators} for information about what value is valid for each operator. + * + * @example + * // Using an attribute as the left operand. + * // Equal to: WHERE first_name = 'Lily' + * where(User.rawAttributes.firstName, Op.eq, 'Lily'); * - * The attr can either be an object taken from `Model.rawAttributes` (for example `Model.rawAttributes.id` - * or - * `Model.rawAttributes.name`). The attribute should be defined in your model definition. The attribute can - * also be an object from one of the sequelize utility functions (`sequelize.fn`, `sequelize.col` etc.) + * @example + * // Using a column name as the left operand. + * // Equal to: WHERE first_name = 'Lily' + * where(col('first_name'), Op.eq, 'Lily'); * - * For string attributes, use the regular `{ where: { attr: something }}` syntax. If you don't want your - * string to be escaped, use `sequelize.literal`. + * @example + * // Using a SQL function on the left operand. + * // Equal to: WHERE LOWER(first_name) = 'lily' + * where(fn('LOWER', col('first_name')), Op.eq, 'lily'); * - * @param attr The attribute, which can be either an attribute object from `Model.rawAttributes` or a - * sequelize object, for example an instance of `sequelize.fn`. For simple string attributes, use the - * POJO syntax - * @param comparator Comparator - * @param logic The condition. Can be both a simply type, or a further condition (`.or`, `.and`, `.literal` - * etc.) + * @example + * // Using raw SQL as the left operand. + * // Equal to: WHERE 'Lily' = 'Lily' + * where(literal(`'Lily'`), Op.eq, 'Lily'); */ -export function where(attr: AttributeType, comparator: string | symbol, logic: LogicType): Where; -export function where(attr: AttributeType, logic: LogicType): Where; +export function where(leftOperand: WhereLeftOperand | Where, operator: Op, rightOperand: WhereOperators[Op]): Where; +export function where(leftOperand: any, operator: string, rightOperand: any): Where; +export function where(leftOperand: WhereLeftOperand, rightOperand: WhereAttributeHashValue): Where; export default Sequelize; diff --git a/lib/sequelize.js b/src/sequelize.js similarity index 90% rename from lib/sequelize.js rename to src/sequelize.js index a68facc8ecf1..3098dd0c81ea 100644 --- a/lib/sequelize.js +++ b/src/sequelize.js @@ -3,7 +3,7 @@ const url = require('url'); const path = require('path'); const pgConnectionString = require('pg-connection-string'); -const retry = require('retry-as-promised'); +const retry = require('retry-as-promised').default; const _ = require('lodash'); const Utils = require('./utils'); @@ -26,6 +26,8 @@ const { BelongsTo } = require('./associations/belongs-to'); const HasOne = require('./associations/has-one'); const { BelongsToMany } = require('./associations/belongs-to-many'); const { HasMany } = require('./associations/has-many'); +const { withSqliteForeignKeysOff } = require('./dialects/sqlite/sqlite-utils'); +const { injectReplacements } = require('./utils/sql'); /** * This is the main class, the entry point to sequelize. @@ -95,6 +97,10 @@ class Sequelize { * // - default: false * native: true, * + * // A flag that defines if connection should be over ssl or not + * // - default: undefined + * ssl: true, + * * // Specify options, which are used when sequelize.define is called. * // The following example: * // define: { timestamps: false } @@ -154,6 +160,7 @@ class Sequelize { * @param {boolean} [options.benchmark=false] Pass query execution time in milliseconds as second argument to logging function (options.logging). * @param {boolean} [options.omitNull=false] A flag that defines if null values should be passed as values to CREATE/UPDATE SQL queries or not. * @param {boolean} [options.native=false] A flag that defines if native library shall be used or not. Currently only has an effect for postgres + * @param {boolean} [options.ssl=undefined] A flag that defines if connection should be over ssl or not * @param {boolean} [options.replication=false] Use read / write replication. To enable replication, pass an object, with two properties, read and write. Write should be an object (a single server for handling writes), and read an array of object (several servers to handle reads). Each read/write server can have the following properties: `host`, `port`, `username`, `password`, `database` * @param {object} [options.pool] sequelize connection pool configuration * @param {number} [options.pool.max=5] Maximum number of connection in pool @@ -285,6 +292,7 @@ class Sequelize { benchmark: false, minifyAliases: false, logQueryParameters: false, + attributeBehavior: 'throw', ...options }; @@ -338,6 +346,9 @@ class Sequelize { case 'mysql': Dialect = require('./dialects/mysql'); break; + case 'oracle': + Dialect = require('./dialects/oracle'); + break; case 'postgres': Dialect = require('./dialects/postgres'); break; @@ -351,7 +362,7 @@ class Sequelize { Dialect = require('./dialects/snowflake'); break; default: - throw new Error(`The dialect ${this.getDialect()} is not supported. Supported dialects: mssql, mariadb, mysql, postgres, db2 and sqlite.`); + throw new Error(`The dialect ${this.getDialect()} is not supported. Supported dialects: mssql, mariadb, mysql, oracle, postgres, db2 and sqlite.`); } this.dialect = new Dialect(this); @@ -519,6 +530,7 @@ class Sequelize { * @param {boolean} [options.supportsSearchPath] If false do not prepend the query with the search_path (Postgres only) * @param {boolean} [options.mapToModel=false] Map returned fields to model's fields if `options.model` or `options.instance` is present. Mapping will occur before building the model instance. * @param {object} [options.fieldMap] Map returned fields to arbitrary names for `SELECT` query type. + * @param {boolean} [options.rawErrors=false] Set to `true` to cause errors coming from the underlying connection/database library to be propagated unmodified and unformatted. Else, the default behavior (=false) is to reinterpret errors as sequelize.errors.BaseError objects. * * @returns {Promise} * @@ -597,11 +609,7 @@ class Sequelize { } if (options.replacements) { - if (Array.isArray(options.replacements)) { - sql = Utils.format([sql].concat(options.replacements), this.options.dialect); - } else { - sql = Utils.formatNamedParameters(sql, options.replacements, this.options.dialect); - } + sql = injectReplacements(sql, this.dialect, options.replacements); } let bindParameters; @@ -628,7 +636,7 @@ class Sequelize { checkTransaction(); const connection = await (options.transaction ? options.transaction.connection : this.connectionManager.getConnection(options)); - + if (this.options.dialect === 'db2' && options.alter) { if (options.alter.drop === false) { connection.dropTable = false; @@ -643,7 +651,7 @@ class Sequelize { } finally { await this.runHooks('afterQuery', options, query); if (!options.transaction) { - await this.connectionManager.releaseConnection(connection); + this.connectionManager.releaseConnection(connection); } } }, retryOptions); @@ -794,33 +802,66 @@ class Sequelize { if (options.hooks) { await this.runHooks('beforeBulkSync', options); } + if (options.force) { await this.drop(options); } - const models = []; - - // Topologically sort by foreign key constraints to give us an appropriate - // creation order - this.modelManager.forEachModel(model => { - if (model) { - models.push(model); - } else { - // DB should throw an SQL error if referencing non-existent table - } - }); // no models defined, just authenticate - if (!models.length) { + if (this.modelManager.models.length === 0) { await this.authenticate(options); } else { - for (const model of models) await model.sync(options); + const models = this.modelManager.getModelsTopoSortedByForeignKey(); + if (models == null) { + return this._syncModelsWithCyclicReferences(options); + } + + // reverse to start with the one model that does not depend on anything + models.reverse(); + + // Topologically sort by foreign key constraints to give us an appropriate + // creation order + for (const model of models) { + await model.sync(options); + } } + if (options.hooks) { await this.runHooks('afterBulkSync', options); } + return this; } + /** + * Used instead of sync() when two models reference each-other, so their foreign keys cannot be created immediately. + * + * @param {object} options - sync options + * @private + */ + async _syncModelsWithCyclicReferences(options) { + if (this.dialect.name === 'sqlite') { + // Optimisation: no need to do this in two passes in SQLite because we can temporarily disable foreign keys + await withSqliteForeignKeysOff(this, options, async () => { + for (const model of this.modelManager.models) { + await model.sync(options); + } + }); + + return; + } + + // create all tables, but don't create foreign key constraints + for (const model of this.modelManager.models) { + await model.sync({ ...options, withoutForeignKeyConstraints: true }); + } + + // add foreign key constraints + for (const model of this.modelManager.models) { + await model.sync({ ...options, force: false, alter: true }); + } + } + /** * Truncate all tables defined through the sequelize models. * This is done by calling `Model.truncate()` on each model. @@ -833,13 +874,23 @@ class Sequelize { * {@link Model.truncate} for more information */ async truncate(options) { - const models = []; + const sortedModels = this.modelManager.getModelsTopoSortedByForeignKey(); + const models = sortedModels || this.modelManager.models; + const hasCyclicDependencies = sortedModels == null; - this.modelManager.forEachModel(model => { - if (model) { - models.push(model); - } - }, { reverse: false }); + // we have cyclic dependencies, cascade must be enabled. + if (hasCyclicDependencies && (!options || !options.cascade)) { + throw new Error('Sequelize#truncate: Some of your models have cyclic references (foreign keys). You need to use the "cascade" option to be able to delete rows from models that have cyclic references.'); + } + + // TODO [>=7]: throw if options.cascade is specified but unsupported in the given dialect. + if (hasCyclicDependencies && this.dialect.name === 'sqlite') { + // Workaround: SQLite does not support options.cascade, but we can disable its foreign key constraints while we + // truncate all tables. + return withSqliteForeignKeysOff(this, options, async () => { + await Promise.all(models.map(model => model.truncate(options))); + }); + } if (options && options.cascade) { for (const model of models) await model.truncate(options); @@ -861,15 +912,46 @@ class Sequelize { * @returns {Promise} */ async drop(options) { - const models = []; + // if 'cascade' is specified, we don't have to worry about cyclic dependencies. + if (options && options.cascade) { + for (const model of this.modelManager.models) { + await model.drop(options); + } + } + + const sortedModels = this.modelManager.getModelsTopoSortedByForeignKey(); - this.modelManager.forEachModel(model => { - if (model) { - models.push(model); + // no cyclic dependency between models, we can delete them in an order that will not cause an error. + if (sortedModels) { + for (const model of sortedModels) { + await model.drop(options); } - }, { reverse: false }); + } - for (const model of models) await model.drop(options); + if (this.dialect.name === 'sqlite') { + // Optimisation: no need to do this in two passes in SQLite because we can temporarily disable foreign keys + await withSqliteForeignKeysOff(this, options, async () => { + for (const model of this.modelManager.models) { + await model.drop(options); + } + }); + + return; + } + + // has cyclic dependency: we first remove each foreign key, then delete each model. + for (const model of this.modelManager.models) { + const tableName = model.getTableName(); + const foreignKeys = await this.queryInterface.getForeignKeyReferencesForTable(tableName, options); + + await Promise.all(foreignKeys.map(foreignKey => { + return this.queryInterface.removeConstraint(tableName, foreignKey.constraintName, options); + })); + } + + for (const model of this.modelManager.models) { + await model.drop(options); + } } /** @@ -887,7 +969,7 @@ class Sequelize { ...options }; - await this.query('SELECT 1+1 AS result', options); + await this.query(this.dialect.queryGenerator.authTestQuery(), options); return; } @@ -1087,6 +1169,7 @@ class Sequelize { * @param {string} [options.type='DEFERRED'] See `Sequelize.Transaction.TYPES` for possible options. Sqlite only. * @param {string} [options.isolationLevel] See `Sequelize.Transaction.ISOLATION_LEVELS` for possible options * @param {string} [options.deferrable] Sets the constraints to be deferred or immediately checked. See `Sequelize.Deferrable`. PostgreSQL Only + * @param {boolean} [options.readOnly] Whether this transaction will only be used to read data. Used to determine whether sequelize is allowed to use a read replication server. * @param {Function} [options.logging=false] A function that gets executed while running the query to log the sql. * @param {Function} [autoCallback] The callback is called with the transaction object, and should return a promise. If the promise is resolved, the transaction commits; if the promise rejects, the transaction rolls back * @@ -1101,30 +1184,29 @@ class Sequelize { const transaction = new Transaction(this, options); if (!autoCallback) { - await transaction.prepareEnvironment(false); + await transaction.prepareEnvironment(/* cls */ false); return transaction; } // autoCallback provided return Sequelize._clsRun(async () => { + await transaction.prepareEnvironment(/* cls */ true); + + let result; try { - await transaction.prepareEnvironment(); - const result = await autoCallback(transaction); - await transaction.commit(); - return await result; + result = await autoCallback(transaction); } catch (err) { try { - if (!transaction.finished) { - await transaction.rollback(); - } else { - // release the connection, even if we don't need to rollback - await transaction.cleanup(); - } - } catch (err0) { - // ignore + await transaction.rollback(); + } catch (ignore) { + // ignore, because 'rollback' will already print the error before killing the connection } + throw err; } + + await transaction.commit(); + return result; }); } @@ -1286,7 +1368,7 @@ Sequelize.prototype.validate = Sequelize.prototype.authenticate; Object.defineProperty(Sequelize, 'version', { enumerable: true, get() { - return require('../../package.json').version; + return require('../package.json').version; } }); diff --git a/types/lib/sql-string.d.ts b/src/sql-string.d.ts similarity index 89% rename from types/lib/sql-string.d.ts rename to src/sql-string.d.ts index bf2d068acd98..310402495179 100644 --- a/types/lib/sql-string.d.ts +++ b/src/sql-string.d.ts @@ -1,5 +1,5 @@ export type Escapable = undefined | null | boolean | number | string | Date; export function escapeId(val: string, forbidQualified?: boolean): string; -export function escape(val: Escapable | Escapable[], timeZone?: string, dialect?: string, format?: string): string; +export function escape(val: Escapable | Escapable[], timeZone?: string, dialect?: string, format?: boolean): string; export function format(sql: string, values: unknown[], timeZone?: string, dialect?: string): string; export function formatNamedParameters(sql: string, values: unknown[], timeZone?: string, dialect?: string): string; diff --git a/src/sql-string.js b/src/sql-string.js new file mode 100644 index 000000000000..1ce2828483ba --- /dev/null +++ b/src/sql-string.js @@ -0,0 +1,192 @@ +'use strict'; + +const moment = require('moment'); +const dataTypes = require('./data-types'); +const { logger } = require('./utils/logger'); + +function arrayToList(array, timeZone, dialect, format) { + return array.reduce((sql, val, i) => { + if (i !== 0) { + sql += ', '; + } + if (Array.isArray(val)) { + sql += `(${arrayToList(val, timeZone, dialect, format)})`; + } else { + sql += escape(val, timeZone, dialect, format); + } + return sql; + }, ''); +} +exports.arrayToList = arrayToList; + +function escape(val, timeZone, dialect, format) { + let prependN = false; + if (val === undefined || val === null) { + return 'NULL'; + } + switch (typeof val) { + case 'boolean': + // SQLite doesn't have true/false support. MySQL aliases true/false to 1/0 + // for us. Postgres actually has a boolean type with true/false literals, + // but sequelize doesn't use it yet. + if (['sqlite', 'mssql', 'oracle'].includes(dialect)) { + return +!!val; + } + return (!!val).toString(); + case 'number': + case 'bigint': + return val.toString(); + case 'string': + // In mssql, prepend N to all quoted vals which are originally a string (for + // unicode compatibility) + prependN = dialect === 'mssql'; + break; + } + + if (val instanceof Date) { + val = dataTypes[dialect].DATE.prototype.stringify(val, { timezone: timeZone }); + } + + if (Buffer.isBuffer(val)) { + if (dataTypes[dialect].BLOB) { + return dataTypes[dialect].BLOB.prototype.stringify(val); + } + + return dataTypes.BLOB.prototype.stringify(val); + } + + if (Array.isArray(val)) { + const partialEscape = escVal => escape(escVal, timeZone, dialect, format); + if (dialect === 'postgres' && !format) { + return dataTypes.ARRAY.prototype.stringify(val, { escape: partialEscape }); + } + return arrayToList(val, timeZone, dialect, format); + } + + if (!val.replace) { + throw new Error(`Invalid value ${logger.inspect(val)}`); + } + + if (['postgres', 'sqlite', 'mssql', 'snowflake', 'db2'].includes(dialect)) { + // http://www.postgresql.org/docs/8.2/static/sql-syntax-lexical.html#SQL-SYNTAX-STRINGS + // http://stackoverflow.com/q/603572/130598 + val = val.replace(/'/g, "''"); + + if (dialect === 'postgres') { + // null character is not allowed in Postgres + val = val.replace(/\0/g, '\\0'); + } + } else if (dialect === 'oracle' && typeof val === 'string') { + if (val.startsWith('TO_TIMESTAMP_TZ') || val.startsWith('TO_DATE')) { + // Split the string using parentheses to isolate the function name, parameters, and potential extra parts + const splitVal = val.split(/\(|\)/); + + // Validate that the split result has exactly three parts (function name, parameters, and an empty string) + // and that there are no additional SQL commands after the function call (indicated by the last empty string). + if (splitVal.length !== 3 || splitVal[2] !== '') { + throw new Error('Invalid SQL function call.'); // Error if function call has unexpected format + } + + // Extract the function name (either 'TO_TIMESTAMP_TZ' or 'TO_DATE') and the contents inside the parentheses + const functionName = splitVal[0].trim(); // Function name should be 'TO_TIMESTAMP_TZ' or 'TO_DATE' + const insideParens = splitVal[1].trim(); // This contains the parameters (date value and format string) + + if (functionName !== 'TO_TIMESTAMP_TZ' && functionName !== 'TO_DATE') { + throw new Error('Invalid SQL function call. Expected TO_TIMESTAMP_TZ or TO_DATE.'); + } + + // Split the parameters inside the parentheses by commas (should contain exactly two: date and format) + const params = insideParens.split(','); + + // Validate that the parameters contain exactly two parts (date value and format string) + if (params.length !== 2) { + throw new Error('Unexpected input received.\nSequelize supports TO_TIMESTAMP_TZ or TO_DATE exclusively with a combination of value and format.'); + } + + // Extract the date value (first parameter) and remove single quotes around it + const dateValue = params[0].trim().replace(/'/g, ''); + const formatValue = params[1].trim(); + + if (functionName === 'TO_TIMESTAMP_TZ') { + const expectedFormat = "'YYYY-MM-DD HH24:MI:SS.FFTZH:TZM'"; + // Validate that the formatValue is equal to expectedFormat since that is the only format used within sequelize + if (formatValue !== expectedFormat) { + throw new Error(`Invalid format string for TO_TIMESTAMP_TZ. Expected format: ${expectedFormat}`); + } + + // Validate the date value using Moment.js with the expected format + const formattedDate = moment(dateValue).format('YYYY-MM-DD HH:mm:ss.SSS Z'); + + // If the formatted date doesn't match the input date value, throw an error + if (formattedDate !== dateValue) { + throw new Error("Invalid date value for TO_TIMESTAMP_TZ. Expected format: 'YYYY-MM-DD HH:mm:ss.SSS Z'"); + } + } else if (functionName === 'TO_DATE') { + const expectedFormat = "'YYYY/MM/DD'"; + // Validate that the formatValue is equal to expectedFormat since that is the only format used within sequelize + if (formatValue !== expectedFormat) { + throw new Error(`Invalid format string for TO_DATE. Expected format: ${expectedFormat}`); + } + + // Validate the date value using Moment.js with the expected format + const formattedDate = moment(dateValue).format('YYYY-MM-DD'); + + // If the formatted date doesn't match the input date value, throw an error + if (formattedDate !== dateValue) { + throw new Error("Invalid date value for TO_DATE. Expected format: 'YYYY-MM-DD'"); + } + } + + return val; + } + + val = val.replace(/'/g, "''"); + } else { + + // eslint-disable-next-line no-control-regex + val = val.replace(/[\0\n\r\b\t\\'"\x1a]/g, s => { + switch (s) { + case '\0': return '\\0'; + case '\n': return '\\n'; + case '\r': return '\\r'; + case '\b': return '\\b'; + case '\t': return '\\t'; + case '\x1a': return '\\Z'; + default: return `\\${s}`; + } + }); + } + return `${(prependN ? "N'" : "'") + val}'`; +} +exports.escape = escape; + +function format(sql, values, timeZone, dialect) { + values = [].concat(values); + + if (typeof sql !== 'string') { + throw new Error(`Invalid SQL string provided: ${sql}`); + } + + return sql.replace(/\?/g, match => { + if (!values.length) { + return match; + } + + return escape(values.shift(), timeZone, dialect, true); + }); +} +exports.format = format; + +function formatNamedParameters(sql, values, timeZone, dialect) { + return sql.replace(/:+(?!\d)(\w+)/g, (value, key) => { + if ('postgres' === dialect && '::' === value.slice(0, 2)) { + return value; + } + + if (values[key] !== undefined) { + return escape(values[key], timeZone, dialect, true); + } + throw new Error(`Named parameter "${value}" has no value in the given object.`); + }); +} +exports.formatNamedParameters = formatNamedParameters; diff --git a/types/lib/table-hints.d.ts b/src/table-hints.d.ts similarity index 100% rename from types/lib/table-hints.d.ts rename to src/table-hints.d.ts diff --git a/lib/table-hints.js b/src/table-hints.js similarity index 100% rename from lib/table-hints.js rename to src/table-hints.js diff --git a/types/lib/transaction.d.ts b/src/transaction.d.ts similarity index 95% rename from types/lib/transaction.d.ts rename to src/transaction.d.ts index 0ebc2cad0933..64255fab15bb 100644 --- a/types/lib/transaction.d.ts +++ b/src/transaction.d.ts @@ -29,14 +29,14 @@ export class Transaction { /** * Returns possible options for row locking */ - static get LOCK(): LOCK; + static get LOCK(): typeof LOCK; /** * Same as its static version, but can also be called on instances of * transactions to get possible options for row locking directly from the * instance. */ - get LOCK(): LOCK; + get LOCK(): typeof LOCK; } // tslint:disable-next-line no-namespace @@ -131,13 +131,6 @@ export enum LOCK { NO_KEY_UPDATE = 'NO KEY UPDATE', } -interface LOCK { - UPDATE: LOCK.UPDATE; - SHARE: LOCK.SHARE; - KEY_SHARE: LOCK.KEY_SHARE; - NO_KEY_UPDATE: LOCK.NO_KEY_UPDATE; -} - /** * Options provided when the transaction is created */ @@ -146,6 +139,7 @@ export interface TransactionOptions extends Logging { isolationLevel?: Transaction.ISOLATION_LEVELS; type?: Transaction.TYPES; deferrable?: string | Deferrable; + readOnly?: boolean; /** * Parent transaction. */ diff --git a/lib/transaction.js b/src/transaction.js similarity index 83% rename from lib/transaction.js rename to src/transaction.js index f8e32f18df92..f4a97ce7f3f7 100644 --- a/lib/transaction.js +++ b/src/transaction.js @@ -17,6 +17,7 @@ class Transaction { * @param {string} [options.type] Sets the type of the transaction. Sqlite only * @param {string} [options.isolationLevel] Sets the isolation level of the transaction. * @param {string} [options.deferrable] Sets the constraints to be deferred or immediately checked. PostgreSQL only + * @param {boolean} [options.readOnly] Whether this transaction will only be used to read data. Used to determine whether sequelize is allowed to use a read replication server. */ constructor(sequelize, options) { this.sequelize = sequelize; @@ -57,10 +58,15 @@ class Transaction { } try { - return await this.sequelize.getQueryInterface().commitTransaction(this, this.options); + await this.sequelize.getQueryInterface().commitTransaction(this, this.options); + this.cleanup(); + } catch (e) { + console.warn(`Committing transaction ${this.id} failed with error ${JSON.stringify(e.message)}. We are killing its connection as it is now in an undetermined state.`); + await this.forceCleanup(); + + throw e; } finally { this.finished = 'commit'; - this.cleanup(); for (const hook of this._afterCommitHooks) { await hook.apply(this, [this]); } @@ -82,12 +88,17 @@ class Transaction { } try { - return await this + await this .sequelize .getQueryInterface() .rollbackTransaction(this, this.options); - } finally { + this.cleanup(); + } catch (e) { + console.warn(`Rolling back transaction ${this.id} failed with error ${JSON.stringify(e.message)}. We are killing its connection as it is now in an undetermined state.`); + await this.forceCleanup(); + + throw e; } } @@ -98,13 +109,9 @@ class Transaction { * @param {boolean} useCLS Defaults to true: Use CLS (Continuation Local Storage) with Sequelize. With CLS, all queries within the transaction callback will automatically receive the transaction object. * @returns {Promise} */ - async prepareEnvironment(useCLS) { + async prepareEnvironment(useCLS = true) { let connectionPromise; - if (useCLS === undefined) { - useCLS = true; - } - if (this.parent) { connectionPromise = Promise.resolve(this.parent.connection); } else { @@ -131,6 +138,7 @@ class Transaction { } } + // TODO (@ephys) [>=7.0.0]: move this inside of sequelize.transaction, remove parameter. if (useCLS && this.sequelize.constructor._cls) { this.sequelize.constructor._cls.set('transaction', this); } @@ -163,12 +171,31 @@ class Transaction { cleanup() { // Don't release the connection if there's a parent transaction or // if we've already cleaned up - if (this.parent || this.connection.uuid === undefined) return; + if (this.parent || this.connection.uuid === undefined) { + return; + } + + this._clearCls(); + this.sequelize.connectionManager.releaseConnection(this.connection); + this.connection.uuid = undefined; + } + + /** + * Kills the connection this transaction uses. + * Used as a last resort, for instance because COMMIT or ROLLBACK resulted in an error + * and the transaction is left in a broken state, + * and releasing the connection to the pool would be dangerous. + */ + async forceCleanup() { + // Don't release the connection if there's a parent transaction or + // if we've already cleaned up + if (this.parent || this.connection.uuid === undefined) { + return; + } this._clearCls(); - const res = this.sequelize.connectionManager.releaseConnection(this.connection); + await this.sequelize.connectionManager.destroyConnection(this.connection); this.connection.uuid = undefined; - return res; } _clearCls() { diff --git a/types/lib/utils.d.ts b/src/utils.d.ts similarity index 83% rename from types/lib/utils.d.ts rename to src/utils.d.ts index de1ee23dca2e..92220ab4e768 100644 --- a/types/lib/utils.d.ts +++ b/src/utils.d.ts @@ -1,6 +1,6 @@ import { DataType } from './data-types'; import { Model, ModelCtor, ModelType, WhereOptions, Attributes } from './model'; -import { Optional } from '..'; +import { Optional } from './index'; export type Primitive = 'string' | 'number' | 'boolean'; @@ -127,32 +127,35 @@ export class Where extends SequelizeMethod { export type AnyFunction = (...args: any[]) => any; /** - * Returns all shallow properties that accept `undefined`. - * Does not include Optional properties, only `undefined`. + * Returns all shallow properties that accept `undefined` or `null`. + * Does not include Optional properties, only `undefined` or `null`. * * @example - * type UndefinedProps = UndefinedPropertiesOf<{ + * type UndefinedProps = NullishPropertiesOf<{ * id: number | undefined, * createdAt: string | undefined, - * firstName: string, + * firstName: string | null, // nullable properties are included * lastName?: string, // optional properties are not included. * }>; * * // is equal to * - * type UndefinedProps = 'id' | 'createdAt'; + * type UndefinedProps = 'id' | 'createdAt' | 'firstName'; */ -export type UndefinedPropertiesOf = { - [P in keyof T]-?: undefined extends T[P] ? P : never +export type NullishPropertiesOf = { + [P in keyof T]-?: undefined extends T[P] ? P + : null extends T[P] ? P + : never }[keyof T]; /** - * Makes all shallow properties of an object `optional` if they accept `undefined` as a value. + * Makes all shallow properties of an object `optional` if they accept `undefined` or `null` as a value. * * @example * type MyOptionalType = MakeUndefinedOptional<{ * id: number | undefined, - * name: string, + * firstName: string, + * lastName: string | null, * }>; * * // is equal to @@ -160,7 +163,11 @@ export type UndefinedPropertiesOf = { * type MyOptionalType = { * // this property is optional. * id?: number | undefined, - * name: string, + * firstName: string, + * // this property is optional. + * lastName?: string | null, * }; */ -export type MakeUndefinedOptional = Optional>; +// 'T extends any' is done to support https://github.com/sequelize/sequelize/issues/14129 +// source: https://stackoverflow.com/questions/51691235/typescript-map-union-type-to-another-union-type +export type MakeNullishOptional = T extends any ? Optional> : never; diff --git a/lib/utils.js b/src/utils.js similarity index 97% rename from lib/utils.js rename to src/utils.js index 703fd7d0b628..9bc431002c74 100644 --- a/lib/utils.js +++ b/src/utils.js @@ -114,6 +114,12 @@ function pluralize(str) { } exports.pluralize = pluralize; +/** + * @deprecated use {@link injectReplacements} instead. This method has been removed in v7. + * + * @param {unknown[]} arr - first item is the SQL, following items are the positional replacements. + * @param {AbstractDialect} dialect + */ function format(arr, dialect) { const timeZone = null; // Make a clone of the array beacuse format modifies the passed args @@ -121,6 +127,13 @@ function format(arr, dialect) { } exports.format = format; +/** + * @deprecated use {@link injectReplacements} instead. This method has been removed in v7. + * + * @param {string} sql + * @param {object} parameters + * @param {AbstractDialect} dialect + */ function formatNamedParameters(sql, parameters, dialect) { const timeZone = null; return SqlString.formatNamedParameters(sql, parameters, timeZone, dialect); @@ -323,7 +336,7 @@ function removeNullValuesFromHash(hash, omitNull, options) { } exports.removeNullValuesFromHash = removeNullValuesFromHash; -const dialects = new Set(['mariadb', 'mysql', 'postgres', 'sqlite', 'mssql', 'db2']); +const dialects = new Set(['mariadb', 'mysql', 'postgres', 'sqlite', 'mssql', 'db2', 'oracle']); function now(dialect) { const d = new Date(); diff --git a/lib/utils/class-to-invokable.ts b/src/utils/class-to-invokable.ts similarity index 100% rename from lib/utils/class-to-invokable.ts rename to src/utils/class-to-invokable.ts diff --git a/lib/utils/deprecations.ts b/src/utils/deprecations.ts similarity index 88% rename from lib/utils/deprecations.ts rename to src/utils/deprecations.ts index c5ef8cb746e6..07c040dfe881 100644 --- a/lib/utils/deprecations.ts +++ b/src/utils/deprecations.ts @@ -2,7 +2,6 @@ import { deprecate } from 'util'; const noop = () => { /* noop */ }; -export const noRawAttributes = deprecate(noop, 'Use sequelize.fn / sequelize.literal to construct attributes', 'SEQUELIZE0001'); export const noTrueLogging = deprecate(noop, 'The logging-option should be either a function or false. Default: console.log', 'SEQUELIZE0002'); export const noStringOperators = deprecate(noop, 'String based operators are deprecated. Please use Symbol based operators for better security, read more at https://sequelize.org/master/manual/querying.html#operators', 'SEQUELIZE0003'); export const noBoolOperatorAliases = deprecate(noop, 'A boolean value was passed to options.operatorsAliases. This is a no-op with v5 and should be removed.', 'SEQUELIZE0004'); diff --git a/lib/utils/join-sql-fragments.ts b/src/utils/join-sql-fragments.ts similarity index 100% rename from lib/utils/join-sql-fragments.ts rename to src/utils/join-sql-fragments.ts diff --git a/lib/utils/logger.ts b/src/utils/logger.ts similarity index 100% rename from lib/utils/logger.ts rename to src/utils/logger.ts diff --git a/types/type-helpers/set-required.d.ts b/src/utils/set-required.d.ts similarity index 95% rename from types/type-helpers/set-required.d.ts rename to src/utils/set-required.d.ts index db9109189b8a..07768ec73edb 100644 --- a/types/type-helpers/set-required.d.ts +++ b/src/utils/set-required.d.ts @@ -1,16 +1,16 @@ -/** - * Full credits to sindresorhus/type-fest - * - * https://github.com/sindresorhus/type-fest/blob/v0.8.1/source/set-required.d.ts - * - * Thank you! - */ -export type SetRequired = - // Pick just the keys that are not required from the base type. - Pick> & - // Pick the keys that should be required from the base type and make them required. - Required> extends - // If `InferredType` extends the previous, then for each key, use the inferred type key. - infer InferredType - ? {[KeyType in keyof InferredType]: InferredType[KeyType]} - : never; \ No newline at end of file +/** + * Full credits to sindresorhus/type-fest + * + * https://github.com/sindresorhus/type-fest/blob/v0.8.1/source/set-required.d.ts + * + * Thank you! + */ +export type SetRequired = + // Pick just the keys that are not required from the base type. + Pick> & + // Pick the keys that should be required from the base type and make them required. + Required> extends + // If `InferredType` extends the previous, then for each key, use the inferred type key. + infer InferredType + ? {[KeyType in keyof InferredType]: InferredType[KeyType]} + : never; diff --git a/src/utils/sql.ts b/src/utils/sql.ts new file mode 100644 index 000000000000..1e0697ea2b04 --- /dev/null +++ b/src/utils/sql.ts @@ -0,0 +1,256 @@ +import isPlainObject from 'lodash/isPlainObject'; +import type { AbstractDialect } from '../dialects/abstract/index.js'; +import { escape as escapeSqlValue } from '../sql-string'; + +type BindOrReplacements = { [key: string]: unknown } | unknown[]; + +/** + * Inlines replacements in places where they would be valid SQL values. + * + * @param sqlString The SQL that contains the replacements + * @param dialect The dialect of the SQL + * @param replacements if provided, this method will replace ':named' replacements & positional replacements (?) + * + * @returns The SQL with replacements rewritten in their dialect-specific syntax. + */ +export function injectReplacements( + sqlString: string, + dialect: AbstractDialect, + replacements: BindOrReplacements +): string { + if (replacements == null) { + return sqlString; + } + + if (!Array.isArray(replacements) && !isPlainObject(replacements)) { + throw new TypeError(`"replacements" must be an array or a plain object, but received ${JSON.stringify(replacements)} instead.`); + } + + const isNamedReplacements = isPlainObject(replacements); + const isPositionalReplacements = Array.isArray(replacements); + let lastConsumedPositionalReplacementIndex = -1; + + let output = ''; + + let currentDollarStringTagName = null; + let isString = false; + let isColumn = false; + let previousSliceEnd = 0; + let isSingleLineComment = false; + let isCommentBlock = false; + let stringIsBackslashEscapable = false; + + for (let i = 0; i < sqlString.length; i++) { + const char = sqlString[i]; + + if (isColumn) { + if (char === dialect.TICK_CHAR_RIGHT) { + isColumn = false; + } + + continue; + } + + if (isString) { + if ( + char === '\'' && + (!stringIsBackslashEscapable || !isBackslashEscaped(sqlString, i - 1)) + ) { + isString = false; + stringIsBackslashEscapable = false; + } + + continue; + } + + if (currentDollarStringTagName !== null) { + if (char !== '$') { + continue; + } + + const remainingString = sqlString.slice(i, sqlString.length); + + const dollarStringStartMatch = remainingString.match(/^\$(?[a-z_][0-9a-z_]*)?(\$)/i); + const tagName = dollarStringStartMatch?.groups?.name || ''; + if (currentDollarStringTagName === tagName) { + currentDollarStringTagName = null; + } + + continue; + } + + if (isSingleLineComment) { + if (char === '\n') { + isSingleLineComment = false; + } + + continue; + } + + if (isCommentBlock) { + if (char === '*' && sqlString[i + 1] === '/') { + isCommentBlock = false; + } + + continue; + } + + if (char === dialect.TICK_CHAR_LEFT) { + isColumn = true; + continue; + } + + if (char === '\'') { + isString = true; + + // The following query is supported in almost all dialects, + // SELECT E'test'; + // but postgres interprets it as an E-prefixed string, while other dialects interpret it as + // SELECT E 'test'; + // which selects the type E and aliases it to 'test'. + + stringIsBackslashEscapable = + // all ''-style strings in this dialect can be backslash escaped + dialect.canBackslashEscape() || + // checking if this is a postgres-style E-prefixed string, which also supports backslash escaping + dialect.supports.escapeStringConstants && + // is this a E-prefixed string, such as `E'abc'`, `e'abc'` ? + (sqlString[i - 1] === 'E' || sqlString[i - 1] === 'e') && + // reject things such as `AE'abc'` (the prefix must be exactly E) + canPrecedeNewToken(sqlString[i - 2]); + + continue; + } + + if (char === '-' && sqlString.slice(i, i + 3) === '-- ') { + isSingleLineComment = true; + continue; + } + + if (char === '/' && sqlString.slice(i, i + 2) === '/*') { + isCommentBlock = true; + continue; + } + + // either the start of a $bind parameter, or the start of a $tag$string$tag$ + if (char === '$') { + const previousChar = sqlString[i - 1]; + + // we are part of an identifier + if (/[0-9a-z_]/i.test(previousChar)) { + continue; + } + + const remainingString = sqlString.slice(i, sqlString.length); + + const dollarStringStartMatch = remainingString.match(/^\$(?[a-z_][0-9a-z_]*)?(\$)/i); + if (dollarStringStartMatch) { + currentDollarStringTagName = dollarStringStartMatch.groups?.name ?? ''; + i += dollarStringStartMatch[0].length - 1; + + continue; + } + + continue; + } + + if (isNamedReplacements && char === ':') { + const previousChar = sqlString[i - 1]; + // we want to be conservative with what we consider to be a replacement to avoid risk of conflict with potential operators + // users need to add a space before the bind parameter (except after '(', ',', and '=', '[' (for arrays)) + if (!canPrecedeNewToken(previousChar) && previousChar !== '[') { + continue; + } + + const remainingString = sqlString.slice(i, sqlString.length); + + const match = remainingString.match(/^:(?[a-z_][0-9a-z_]*)(?:\)|,|$|\s|::|;|])/i); + const replacementName = match?.groups?.name; + if (!replacementName) { + continue; + } + + // @ts-expect-error -- isPlainObject does not tell typescript that replacements is a plain object, not an array + const replacementValue = replacements[replacementName]; + if (!Object.prototype.hasOwnProperty.call(replacements, replacementName) || replacementValue === undefined) { + throw new Error(`Named replacement ":${replacementName}" has no entry in the replacement map.`); + } + + const escapedReplacement = escapeSqlValue(replacementValue, undefined, dialect.name, true); + + // add everything before the bind parameter name + output += sqlString.slice(previousSliceEnd, i); + // continue after the bind parameter name + previousSliceEnd = i + replacementName.length + 1; + + output += escapedReplacement; + + continue; + } + + if (isPositionalReplacements && char === '?') { + const previousChar = sqlString[i - 1]; + + // we want to be conservative with what we consider to be a replacement to avoid risk of conflict with potential operators + // users need to add a space before the bind parameter (except after '(', ',', and '=', '[' (for arrays)) + // -> [ is temporarily added to allow 'ARRAY[:name]' to be replaced + // https://github.com/sequelize/sequelize/issues/14410 will make this obsolete. + if (!canPrecedeNewToken(previousChar) && previousChar !== '[') { + continue; + } + + // don't parse ?| and ?& operators as replacements + const nextChar = sqlString[i + 1]; + if (nextChar === '|' || nextChar === '&') { + continue; + } + + const replacementIndex = ++lastConsumedPositionalReplacementIndex; + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore -- ts < 4.4 loses the information that 'replacements' is an array when using 'isPositionalReplacements' instead of 'Array.isArray' + // but performance matters here. + const replacementValue = replacements[lastConsumedPositionalReplacementIndex]; + + if (replacementValue === undefined) { + throw new Error(`Positional replacement (?) ${replacementIndex} has no entry in the replacement map (replacements[${replacementIndex}] is undefined).`); + } + + const escapedReplacement = escapeSqlValue(replacementValue as any, undefined, dialect.name, true); + + // add everything before the bind parameter name + output += sqlString.slice(previousSliceEnd, i); + // continue after the bind parameter name + previousSliceEnd = i + 1; + + output += escapedReplacement; + } + } + + if (isString) { + throw new Error( + `The following SQL query includes an unterminated string literal:\n${sqlString}` + ); + } + + output += sqlString.slice(previousSliceEnd, sqlString.length); + + return output; +} + +function canPrecedeNewToken(char: string | undefined): boolean { + return char === undefined || /[\s(>,=]/.test(char); +} + +function isBackslashEscaped(string: string, pos: number): boolean { + let escaped = false; + for (let i = pos; i >= 0; i--) { + const char = string[i]; + if (char !== '\\') { + break; + } + + escaped = !escaped; + } + + return escaped; +} diff --git a/types/lib/utils/validator-extras.d.ts b/src/utils/validator-extras.d.ts similarity index 100% rename from types/lib/utils/validator-extras.d.ts rename to src/utils/validator-extras.d.ts diff --git a/lib/utils/validator-extras.js b/src/utils/validator-extras.js similarity index 100% rename from lib/utils/validator-extras.js rename to src/utils/validator-extras.js diff --git a/test/config/config.js b/test/config/config.js index f914d04e8efd..20796e26c9be 100644 --- a/test/config/config.js +++ b/test/config/config.js @@ -81,5 +81,17 @@ module.exports = { max: process.env.SEQ_DB2_POOL_MAX || process.env.SEQ_POOL_MAX || 5, idle: process.env.SEQ_DB2_POOL_IDLE || process.env.SEQ_POOL_IDLE || 3000 } + }, + + oracle: { + database: env.SEQ_ORACLE_DB || env.SEQ_DB || 'XEPDB1', + username: env.SEQ_ORACLE_USER || env.SEQ_USER || 'sequelizetest', + password: env.SEQ_ORACLE_PW || env.SEQ_PW || 'sequelizepassword', + host: env.SEQ_ORACLE_HOST || env.SEQ_HOST || '127.0.0.1', + port: env.SEQ_ORACLE_PORT || env.SEQ_PORT || 1521, + pool: { + max: env.SEQ_ORACLE_POOL_MAX || env.SEQ_POOL_MAX || 5, + idle: env.SEQ_ORACLE_POOL_IDLE || env.SEQ_POOL_IDLE || 3000 + } } }; diff --git a/test/integration/associations/belongs-to-many.test.js b/test/integration/associations/belongs-to-many.test.js index 0425e06c2397..c88c2962efe9 100644 --- a/test/integration/associations/belongs-to-many.test.js +++ b/test/integration/associations/belongs-to-many.test.js @@ -1417,7 +1417,12 @@ describe(Support.getTestDialectTeaser('BelongsToMany'), () => { describe('hasAssociations with binary key', () => { beforeEach(function() { - const keyDataType = ['mysql', 'mariadb', 'db2'].includes(dialect) ? 'BINARY(255)' : DataTypes.BLOB('tiny'); + let keyDataType = DataTypes.BLOB('tiny'); + if (['mysql', 'mariadb', 'db2'].includes(dialect)) { + keyDataType = 'BINARY(255)'; + } else if (dialect === 'oracle') { + keyDataType = DataTypes.STRING(255, true); + } this.Article = this.sequelize.define('Article', { id: { type: keyDataType, @@ -3115,7 +3120,7 @@ describe(Support.getTestDialectTeaser('BelongsToMany'), () => { await this.sequelize.sync({ force: true }); let result = await this.sequelize.getQueryInterface().showAllTables(); - if (['mssql', 'mariadb', 'db2'].includes(dialect)) { + if (['mssql', 'mariadb', 'db2', 'oracle'].includes(dialect)) { result = result.map(v => v.tableName); } @@ -3132,7 +3137,7 @@ describe(Support.getTestDialectTeaser('BelongsToMany'), () => { await this.sequelize.sync({ force: true }); let result = await this.sequelize.getQueryInterface().showAllTables(); - if (['mssql', 'mariadb', 'db2'].includes(dialect)) { + if (['mssql', 'mariadb', 'db2', 'oracle'].includes(dialect)) { result = result.map(v => v.tableName); } diff --git a/test/integration/associations/belongs-to.test.js b/test/integration/associations/belongs-to.test.js index 6c4506f3e06e..011d7ac18cfb 100644 --- a/test/integration/associations/belongs-to.test.js +++ b/test/integration/associations/belongs-to.test.js @@ -625,8 +625,7 @@ describe(Support.getTestDialectTeaser('BelongsTo'), () => { } // NOTE: mssql does not support changing an autoincrement primary key - if (Support.getTestDialect() !== 'mssql' && - Support.getTestDialect() !== 'db2') { + if (!['mssql', 'db2', 'oracle'].includes(Support.getTestDialect())) { it('can cascade updates', async function() { const Task = this.sequelize.define('Task', { title: DataTypes.STRING }), User = this.sequelize.define('User', { username: DataTypes.STRING }); diff --git a/test/integration/associations/has-many.test.js b/test/integration/associations/has-many.test.js index 340fa3494bc9..114ebe596708 100644 --- a/test/integration/associations/has-many.test.js +++ b/test/integration/associations/has-many.test.js @@ -1102,7 +1102,7 @@ describe(Support.getTestDialectTeaser('HasMany'), () => { }); // NOTE: mssql does not support changing an autoincrement primary key - if (dialect !== 'mssql' && dialect !== 'db2') { + if (!['mssql', 'db2', 'oracle'].includes(dialect)) { it('can cascade updates', async function() { const Task = this.sequelize.define('Task', { title: DataTypes.STRING }), User = this.sequelize.define('User', { username: DataTypes.STRING }); diff --git a/test/integration/associations/has-one.test.js b/test/integration/associations/has-one.test.js index e68cf25539a6..3f4a430fe574 100644 --- a/test/integration/associations/has-one.test.js +++ b/test/integration/associations/has-one.test.js @@ -453,8 +453,7 @@ describe(Support.getTestDialectTeaser('HasOne'), () => { }); // NOTE: mssql does not support changing an autoincrement primary key - if (Support.getTestDialect() !== 'mssql' && - Support.getTestDialect() !== 'db2') { + if (!['mssql', 'db2', 'oracle'].includes(Support.getTestDialect())) { it('can cascade updates', async function() { const Task = this.sequelize.define('Task', { title: Sequelize.STRING }), User = this.sequelize.define('User', { username: Sequelize.STRING }); diff --git a/test/integration/cls.test.js b/test/integration/cls.test.js index 746d43996842..1a2f2b7bce56 100644 --- a/test/integration/cls.test.js +++ b/test/integration/cls.test.js @@ -136,13 +136,261 @@ if (current.dialect.supports.transactions) { }); }); + describe('Model Hook integration', () => { + + function testHooks({ method, hooks: hookNames, optionPos, execute, getModel }) { + it(`passes the transaction to hooks {${hookNames.join(',')}} when calling ${method}`, async function() { + await this.sequelize.transaction(async transaction => { + const hooks = Object.create(null); + + for (const hookName of hookNames) { + hooks[hookName] = sinon.spy(); + } + + const User = Reflect.apply(getModel, this, []); + + for (const [hookName, spy] of Object.entries(hooks)) { + User[hookName](spy); + } + + await Reflect.apply(execute, this, [User]); + + const spyMatcher = []; + // ignore all arguments until we get to the option bag. + for (let i = 0; i < optionPos; i++) { + spyMatcher.push(sinon.match.any); + } + + // find the transaction in the option bag + spyMatcher.push(sinon.match.has('transaction', transaction)); + + for (const [hookName, spy] of Object.entries(hooks)) { + expect( + spy, + `hook ${hookName} did not receive the transaction from CLS.` + ).to.have.been.calledWith(...spyMatcher); + } + }); + }); + } + + testHooks({ + method: 'Model.bulkCreate', + hooks: ['beforeBulkCreate', 'beforeCreate', 'afterCreate', 'afterBulkCreate'], + optionPos: 1, + async execute(User) { + await User.bulkCreate([{ name: 'bob' }], { individualHooks: true }); + }, + getModel() { + return this.User; + } + }); + + testHooks({ + method: 'Model.findAll', + hooks: ['beforeFind', 'beforeFindAfterExpandIncludeAll', 'beforeFindAfterOptions'], + optionPos: 0, + async execute(User) { + await User.findAll(); + }, + getModel() { + return this.User; + } + }); + + testHooks({ + method: 'Model.findAll', + hooks: ['afterFind'], + optionPos: 1, + async execute(User) { + await User.findAll(); + }, + getModel() { + return this.User; + } + }); + + testHooks({ + method: 'Model.count', + hooks: ['beforeCount'], + optionPos: 0, + async execute(User) { + await User.count(); + }, + getModel() { + return this.User; + } + }); + + testHooks({ + method: 'Model.upsert', + hooks: ['beforeUpsert', 'afterUpsert'], + optionPos: 1, + async execute(User) { + await User.upsert({ + id: 1, + name: 'bob' + }); + }, + getModel() { + return this.User; + } + }); + + testHooks({ + method: 'Model.destroy', + hooks: ['beforeBulkDestroy', 'afterBulkDestroy'], + optionPos: 0, + async execute(User) { + await User.destroy({ where: { name: 'bob' } }); + }, + getModel() { + return this.User; + } + }); + + testHooks({ + method: 'Model.destroy with individualHooks', + hooks: ['beforeDestroy', 'beforeDestroy'], + optionPos: 1, + async execute(User) { + await User.create({ name: 'bob' }); + await User.destroy({ where: { name: 'bob' }, individualHooks: true }); + }, + getModel() { + return this.User; + } + }); + + testHooks({ + method: 'Model#destroy', + hooks: ['beforeDestroy', 'beforeDestroy'], + optionPos: 1, + async execute(User) { + const user = await User.create({ name: 'bob' }); + await user.destroy(); + }, + getModel() { + return this.User; + } + }); + + testHooks({ + method: 'Model.update', + hooks: ['beforeBulkUpdate', 'afterBulkUpdate'], + optionPos: 0, + async execute(User) { + await User.update({ name: 'alice' }, { where: { name: 'bob' } }); + }, + getModel() { + return this.User; + } + }); + + testHooks({ + method: 'Model.update with individualHooks', + hooks: ['beforeUpdate', 'afterUpdate'], + optionPos: 1, + async execute(User) { + await User.create({ name: 'bob' }); + await User.update({ name: 'alice' }, { where: { name: 'bob' }, individualHooks: true }); + }, + getModel() { + return this.User; + } + }); + + testHooks({ + method: 'Model#save (isNewRecord)', + hooks: ['beforeCreate', 'afterCreate'], + optionPos: 1, + async execute(User) { + const user = User.build({ name: 'bob' }); + user.name = 'alice'; + await user.save(); + }, + getModel() { + return this.User; + } + }); + + testHooks({ + method: 'Model#save (!isNewRecord)', + hooks: ['beforeUpdate', 'afterUpdate'], + optionPos: 1, + async execute(User) { + const user = await User.create({ name: 'bob' }); + user.name = 'alice'; + await user.save(); + }, + getModel() { + return this.User; + } + }); + + describe('paranoid restore', () => { + beforeEach(async function() { + this.ParanoidUser = this.sequelize.define('ParanoidUser', { + name: Sequelize.STRING + }, { paranoid: true }); + + await this.ParanoidUser.sync({ force: true }); + }); + + testHooks({ + method: 'Model.restore', + hooks: ['beforeBulkRestore', 'afterBulkRestore'], + optionPos: 0, + async execute() { + const User = this.ParanoidUser; + await User.restore({ where: { name: 'bob' } }); + }, + getModel() { + return this.ParanoidUser; + } + }); + + testHooks({ + method: 'Model.restore with individualHooks', + hooks: ['beforeRestore', 'afterRestore'], + optionPos: 1, + async execute() { + const User = this.ParanoidUser; + + await User.create({ name: 'bob' }); + await User.destroy({ where: { name: 'bob' } }); + await User.restore({ where: { name: 'bob' }, individualHooks: true }); + }, + getModel() { + return this.ParanoidUser; + } + }); + + testHooks({ + method: 'Model#restore', + hooks: ['beforeRestore', 'afterRestore'], + optionPos: 1, + async execute() { + const User = this.ParanoidUser; + + const user = await User.create({ name: 'bob' }); + await user.destroy(); + await user.restore(); + }, + getModel() { + return this.ParanoidUser; + } + }); + }); + }); + it('CLS namespace is stored in Sequelize._cls', function() { expect(Sequelize._cls).to.equal(this.ns); }); it('promises returned by sequelize.query are correctly patched', async function() { await this.sequelize.transaction(async t => { - await this.sequelize.query('select 1', { type: Sequelize.QueryTypes.SELECT }); + await this.sequelize.query(`select 1${ Support.addDualInSelect()}`, { type: Sequelize.QueryTypes.SELECT }); return expect(this.ns.get('transaction')).to.equal(t); } ); @@ -160,12 +408,12 @@ if (current.dialect.supports.transactions) { const result = this.ns.runPromise(async () => { this.ns.set('value', 1); await delay(500); - return sequelize.query('select 1;'); + return sequelize.query(`select 1${ Support.addDualInSelect() };`); }); await this.ns.runPromise(() => { this.ns.set('value', 2); - return sequelize.query('select 2;'); + return sequelize.query(`select 2${ Support.addDualInSelect() };`); }); await result; diff --git a/test/integration/configuration.test.js b/test/integration/configuration.test.js index 4a7fa5cd11d5..888066e86605 100644 --- a/test/integration/configuration.test.js +++ b/test/integration/configuration.test.js @@ -60,13 +60,11 @@ describe(Support.getTestDialectTeaser('Configuration'), () => { if (dialect === 'sqlite') { // SQLite doesn't require authentication and `select 1 as hello` is a valid query, so this should be fulfilled not rejected for it. await expect(seq.query('select 1 as hello')).to.eventually.be.fulfilled; - } - - else if (dialect === 'db2') { + } else if (dialect === 'db2') { await expect(seq.query('select 1 as hello')).to.eventually.be.rejectedWith(...willBeRejectedWithArgs); - } - - else { + } else if (dialect === 'oracle') { + await expect(seq.query('select 1 as hello FROM DUAL')).to.eventually.be.rejectedWith(Sequelize.HostNotReachableError); + } else { await expect(seq.query('select 1 as hello')).to.eventually.be.rejectedWith(Sequelize.ConnectionRefusedError, 'connect ECONNREFUSED'); } }); @@ -74,7 +72,7 @@ describe(Support.getTestDialectTeaser('Configuration'), () => { it('when we don\'t have a valid dialect.', () => { expect(() => { new Sequelize(config[dialect].database, config[dialect].username, config[dialect].password, { host: '0.0.0.1', port: config[dialect].port, dialect: 'some-fancy-dialect' }); - }).to.throw(Error, 'The dialect some-fancy-dialect is not supported. Supported dialects: mssql, mariadb, mysql, postgres, db2 and sqlite.'); + }).to.throw(Error, 'The dialect some-fancy-dialect is not supported. Supported dialects: mssql, mariadb, mysql, oracle, postgres, db2 and sqlite.'); }); }); diff --git a/test/integration/data-types.test.js b/test/integration/data-types.test.js index 6899d26e2b59..c20666a0b844 100644 --- a/test/integration/data-types.test.js +++ b/test/integration/data-types.test.js @@ -33,6 +33,22 @@ describe(Support.getTestDialectTeaser('DataTypes'), () => { return value.format('YYYY-MM-DD HH:mm:ss'); }); + // oracle has a _bindParam function that checks if DATE was created with + // the boolean param (if so it outputs a Buffer bind param). This override + // isn't needed for other dialects + let bindParam; + if (dialect === 'oracle') { + bindParam = Sequelize.DATE.prototype.bindParam = sinon.spy(function(value, options) { + if (!moment.isMoment(value)) { + value = this._applyTimezone(value, options); + } + // For the Oracle dialect, use TO_DATE() + const formatedDate = value.format('YYYY-MM-DD HH:mm:ss'); + const format = 'YYYY-MM-DD HH24:mi:ss'; + return `TO_DATE('${formatedDate}', '${format}')`; + }); + } + current.refreshTypes(); const User = current.define('user', { @@ -50,7 +66,9 @@ describe(Support.getTestDialectTeaser('DataTypes'), () => { const obj = await User.findAll(); const user = obj[0]; expect(parse).to.have.been.called; - expect(stringify).to.have.been.called; + // For the Oracle dialect we check if bindParam was called + // for other dalects we check if stringify was called + dialect === 'oracle' ? expect(bindParam).to.have.been.called : expect(stringify).to.have.been.called; expect(moment.isMoment(user.dateField)).to.be.ok; @@ -115,7 +133,14 @@ describe(Support.getTestDialectTeaser('DataTypes'), () => { it('calls parse and stringify for JSON', async () => { const Type = new Sequelize.JSON(); - await testSuccess(Type, { test: 42, nested: { foo: 'bar' } }); + // oracle has a _bindParam function that checks if JSON was created with + // the boolean param (if so it outputs a Buffer bind param). This override + // isn't needed for other dialects + if (dialect === 'oracle') { + await testSuccess(Type, { test: 42, nested: { foo: 'bar' } }, { useBindParam: true }); + } else { + await testSuccess(Type, { test: 42, nested: { foo: 'bar' } }); + } }); } @@ -146,19 +171,38 @@ describe(Support.getTestDialectTeaser('DataTypes'), () => { it('calls parse and stringify for DATE', async () => { const Type = new Sequelize.DATE(); - await testSuccess(Type, new Date()); + // oracle has a _bindParam function that checks if DATE was created with + // the boolean param (if so it outputs a Buffer bind param). This override + // isn't needed for other dialects + if (dialect === 'oracle') { + await testSuccess(Type, new Date(), { useBindParam: true }); + } else { + await testSuccess(Type, new Date()); + } }); it('calls parse and stringify for DATEONLY', async () => { const Type = new Sequelize.DATEONLY(); - await testSuccess(Type, moment(new Date()).format('YYYY-MM-DD')); + // oracle has a _bindParam function that checks if DATEONLY was created with + // the boolean param (if so it outputs a Buffer bind param). This override + // isn't needed for other dialects + if (dialect === 'oracle') { + await testSuccess(Type, moment(new Date()).format('YYYY-MM-DD'), { useBindParam: true }); + } else { + await testSuccess(Type, moment(new Date()).format('YYYY-MM-DD')); + } }); it('calls parse and stringify for TIME', async () => { const Type = new Sequelize.TIME(); - await testSuccess(Type, moment(new Date()).format('HH:mm:ss')); + // TIME Datatype isn't supported by the oracle dialect + if (dialect === 'oracle') { + testFailure(Type); + } else { + await testSuccess(Type, moment(new Date()).format('HH:mm:ss')); + } }); it('calls parse and stringify for BLOB', async () => { @@ -170,16 +214,23 @@ describe(Support.getTestDialectTeaser('DataTypes'), () => { it('calls parse and stringify for CHAR', async () => { const Type = new Sequelize.CHAR(); - await testSuccess(Type, 'foobar'); + // oracle has a _bindParam function that checks if STRING was created with + // the boolean param (if so it outputs a Buffer bind param). This override + // isn't needed for other dialects + if (dialect === 'oracle') { + await testSuccess(Type, 'foobar', { useBindParam: true }); + } else { + await testSuccess(Type, 'foobar'); + } }); it('calls parse and stringify/bindParam for STRING', async () => { const Type = new Sequelize.STRING(); - // mssql has a _bindParam function that checks if STRING was created with + // mssql/oracle has a _bindParam function that checks if STRING was created with // the boolean param (if so it outputs a Buffer bind param). This override // isn't needed for other dialects - if (dialect === 'mssql' || dialect === 'db2') { + if (['mssql', 'db2', 'oracle'].includes(dialect)) { await testSuccess(Type, 'foobar', { useBindParam: true }); } else { await testSuccess(Type, 'foobar'); @@ -237,12 +288,19 @@ describe(Support.getTestDialectTeaser('DataTypes'), () => { const user = await User.create({ age }); expect(BigInt(user.age).toString()).to.equal(age.toString()); + // cover also bulkCreate + // adds two records + await User.bulkCreate([{ age }, { age }]); + const users = await User.findAll({ where: { age } }); - expect(users).to.have.lengthOf(1); - expect(BigInt(users[0].age).toString()).to.equal(age.toString()); + expect(users).to.have.lengthOf(3); + for (const usr of users) { + expect(BigInt(usr.age).toString()).to.equal(age.toString()); + } + }); if (dialect === 'mysql') { @@ -308,7 +366,7 @@ describe(Support.getTestDialectTeaser('DataTypes'), () => { const Type = new Sequelize.UUID(); // there is no dialect.supports.UUID yet - if (['postgres', 'sqlite', 'db2'].includes(dialect)) { + if (['postgres', 'sqlite', 'oracle', 'db2'].includes(dialect)) { await testSuccess(Type, uuid.v4()); } else { // No native uuid type @@ -377,7 +435,7 @@ describe(Support.getTestDialectTeaser('DataTypes'), () => { it('calls parse and stringify for ENUM', async () => { const Type = new Sequelize.ENUM('hat', 'cat'); - if (['postgres', 'db2'].includes(dialect)) { + if (['postgres', 'oracle', 'db2'].includes(dialect)) { await testSuccess(Type, 'hat'); } else { testFailure(Type); @@ -462,7 +520,7 @@ describe(Support.getTestDialectTeaser('DataTypes'), () => { }); } - if (['postgres', 'sqlite'].includes(dialect)) { + if (['postgres', 'sqlite', 'oracle'].includes(dialect)) { // postgres actively supports IEEE floating point literals, and sqlite doesn't care what we throw at it it('should store and parse IEEE floating point literals (NaN and Infinity)', async function() { const Model = this.sequelize.define('model', { diff --git a/test/integration/dialects/oracle/connection-manager.test.js b/test/integration/dialects/oracle/connection-manager.test.js new file mode 100644 index 000000000000..a63ec8e421f1 --- /dev/null +++ b/test/integration/dialects/oracle/connection-manager.test.js @@ -0,0 +1,18 @@ +'use strict'; + +const chai = require('chai'); +const expect = chai.expect; +const config = require('../../../config/config.js').oracle; +const Support = require('../../support'); +const dialect = Support.getTestDialect(); +const Sequelize = Support.Sequelize; + +if (dialect === 'oracle') { + describe('[Oracle Specific] Connection Manager', () => { + it('connect string authentication using connection Descriptor', async () => { + const connDesc = `(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=${config.host})(PORT=${config.port}))(CONNECT_DATA=(SERVICE_NAME=${config.database})))`; + const sequelize = new Sequelize({ username: config.username, password: config.password, dialect: 'oracle', dialectOptions: { connectString: connDesc } }); + await expect(sequelize.authenticate()).not.to.be.rejected; + }); + }); +} diff --git a/test/integration/dialects/postgres/query.test.js b/test/integration/dialects/postgres/query.test.js index 55085a6ccf6a..27d264e6a128 100644 --- a/test/integration/dialects/postgres/query.test.js +++ b/test/integration/dialects/postgres/query.test.js @@ -4,7 +4,8 @@ const chai = require('chai'), expect = chai.expect, Support = require('../../support'), dialect = Support.getTestDialect(), - DataTypes = require('sequelize/lib/data-types'); + DataTypes = require('sequelize/lib/data-types'), + DatabaseError = require('sequelize/lib/errors/database-error'); if (dialect.match(/^postgres/)) { describe('[POSTGRES] Query', () => { @@ -102,5 +103,135 @@ if (dialect.match(/^postgres/)) { } }); }); + + it('orders by a literal when subquery and minifyAliases are enabled', async () => { + const sequelizeMinifyAliases = Support.createSequelizeInstance({ + logQueryParameters: true, + benchmark: true, + minifyAliases: true, + define: { + timestamps: false + } + }); + + const Foo = sequelizeMinifyAliases.define('Foo', { + name: { + field: 'my_name', + type: DataTypes.TEXT + } + }, { timestamps: false }); + + await sequelizeMinifyAliases.sync({ force: true }); + await Foo.create({ name: 'record1' }); + await Foo.create({ name: 'record2' }); + + const baseTest = (await Foo.findAll({ + subQuery: false, + order: sequelizeMinifyAliases.literal('"Foo".my_name') + })).map(f => f.name); + expect(baseTest[0]).to.equal('record1'); + + const orderByAscSubquery = (await Foo.findAll({ + attributes: { + include: [ + [sequelizeMinifyAliases.literal('"Foo".my_name'), 'customAttribute'] + ] + }, + subQuery: true, + order: [['customAttribute']], + limit: 1 + })).map(f => f.name); + expect(orderByAscSubquery[0]).to.equal('record1'); + + const orderByDescSubquery = (await Foo.findAll({ + attributes: { + include: [ + [sequelizeMinifyAliases.literal('"Foo".my_name'), 'customAttribute'] + ] + }, + subQuery: true, + order: [['customAttribute', 'DESC']], + limit: 1 + })).map(f => f.name); + expect(orderByDescSubquery[0]).to.equal('record2'); + }); + + it('returns the minified aliased attributes', async () => { + const sequelizeMinifyAliases = Support.createSequelizeInstance({ + logQueryParameters: true, + benchmark: true, + minifyAliases: true, + define: { + timestamps: false + } + }); + + const Foo = sequelizeMinifyAliases.define( + 'Foo', + { + name: { + field: 'my_name', + type: DataTypes.TEXT + } + }, + { timestamps: false } + ); + + await sequelizeMinifyAliases.sync({ force: true }); + + await Foo.findAll({ + subQuery: false, + attributes: { + include: [ + [sequelizeMinifyAliases.literal('"Foo".my_name'), 'order_0'] + ] + }, + order: [['order_0', 'DESC']] + }); + }); + + describe('Connection Invalidation', () => { + if (process.env.DIALECT === 'postgres-native') { + // native driver doesn't support statement_timeout or query_timeout + return; + } + + async function setUp(clientQueryTimeoutMs) { + const sequelize = Support.createSequelizeInstance({ + dialectOptions: { + statement_timeout: 500, // ms + query_timeout: clientQueryTimeoutMs + }, + pool: { + max: 1, // having only one helps us know whether the connection was invalidated + idle: 60000 + } + }); + + return { sequelize, originalPid: await getConnectionPid(sequelize) }; + } + + async function getConnectionPid(sequelize) { + const connection = await sequelize.connectionManager.getConnection(); + const pid = connection.processID; + sequelize.connectionManager.releaseConnection(connection); + + return pid; + } + + it('reuses connection after statement timeout', async () => { + // client timeout > statement timeout means that the query should fail with a statement timeout + const { sequelize, originalPid } = await setUp(10000); + await expect(sequelize.query('select pg_sleep(1)')).to.eventually.be.rejectedWith(DatabaseError, 'canceling statement due to statement timeout'); + expect(await getConnectionPid(sequelize)).to.equal(originalPid); + }); + + it('invalidates connection after client-side query timeout', async () => { + // client timeout < statement timeout means that the query should fail with a read timeout + const { sequelize, originalPid } = await setUp(250); + await expect(sequelize.query('select pg_sleep(1)')).to.eventually.be.rejectedWith(DatabaseError, 'Query read timeout'); + expect(await getConnectionPid(sequelize)).to.not.equal(originalPid); + }); + }); }); } diff --git a/test/integration/error.test.js b/test/integration/error.test.js index beba2d3c9583..31ce5fb6020f 100644 --- a/test/integration/error.test.js +++ b/test/integration/error.test.js @@ -374,7 +374,7 @@ describe(Support.getTestDialectTeaser('Sequelize Errors'), () => { await expect(User.create({ name: 'jan' })).to.be.rejectedWith(Sequelize.UniqueConstraintError); // And when the model is not passed at all - if (dialect === 'db2') { + if (['db2', 'oracle'].includes(dialect)) { await expect(this.sequelize.query('INSERT INTO "users" ("name") VALUES (\'jan\')')).to.be.rejectedWith(Sequelize.UniqueConstraintError); } else { await expect(this.sequelize.query('INSERT INTO users (name) VALUES (\'jan\')')).to.be.rejectedWith(Sequelize.UniqueConstraintError); diff --git a/test/integration/hooks/hooks.test.js b/test/integration/hooks/hooks.test.js index d205ccb51776..311effe30d9a 100644 --- a/test/integration/hooks/hooks.test.js +++ b/test/integration/hooks/hooks.test.js @@ -403,4 +403,24 @@ describe(Support.getTestDialectTeaser('Hooks'), () => { expect(narutoHook).to.have.been.calledTwice; }); }); + + describe('Sequelize hooks', () => { + it('should run before/afterPoolAcquire hooks', async function() { + if (dialect === 'sqlite') { + return this.skip(); + } + + const beforeHook = sinon.spy(); + const afterHook = sinon.spy(); + + this.sequelize.addHook('beforePoolAcquire', beforeHook); + this.sequelize.addHook('afterPoolAcquire', afterHook); + + await this.sequelize.authenticate(); + + expect(beforeHook).to.have.been.calledOnce; + expect(afterHook).to.have.been.calledOnce; + + }); + }); }); diff --git a/test/integration/include.test.js b/test/integration/include.test.js index ead06dbb2362..298b9ec18462 100644 --- a/test/integration/include.test.js +++ b/test/integration/include.test.js @@ -656,6 +656,11 @@ describe(Support.getTestDialectTeaser('Include'), () => { Sequelize.literal('EXISTS(SELECT 1 FROM SYSIBM.SYSDUMMY1) AS "PostComments.someProperty"'), [Sequelize.literal('EXISTS(SELECT 1 FROM SYSIBM.SYSDUMMY1)'), 'someProperty2'] ]; + } else if (dialect === 'oracle') { + findAttributes = [ + Sequelize.literal('(CASE WHEN EXISTS(SELECT 1 FROM DUAL) THEN 1 ELSE 0 END) AS "PostComments.someProperty"'), + [Sequelize.literal('(CASE WHEN EXISTS(SELECT 1 FROM DUAL) THEN 1 ELSE 0 END)'), 'someProperty2'] + ]; } else { findAttributes = [ Sequelize.literal('EXISTS(SELECT 1) AS "PostComments.someProperty"'), diff --git a/test/integration/include/findAll.test.js b/test/integration/include/findAll.test.js index 29d9e062a24f..458f1ffc08b7 100644 --- a/test/integration/include/findAll.test.js +++ b/test/integration/include/findAll.test.js @@ -6,6 +6,7 @@ const chai = require('chai'), expect = chai.expect, Support = require('../support'), DataTypes = require('sequelize/lib/data-types'), + dialect = Support.getTestDialect(), _ = require('lodash'), promiseProps = require('p-props'); @@ -122,7 +123,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { { title: 'Pen' }, { title: 'Monitor' } ]); - const products = await Product.findAll(); + const products = await Product.findAll({ order: [['id', 'ASC']] }); const groupMembers = [ { AccUserId: user.id, GroupId: groups[0].id, RankId: ranks[0].id }, { AccUserId: user.id, GroupId: groups[1].id, RankId: ranks[2].id } @@ -359,7 +360,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { Product.bulkCreate([ { title: 'Chair' }, { title: 'Desk' } - ]).then(() => Product.findAll()) + ]).then(() => Product.findAll({ order: [['id', 'ASC']] })) ]); await Promise.all([ GroupMember.bulkCreate([ @@ -1207,7 +1208,7 @@ describe(Support.getTestDialectTeaser('Include'), () => { { title: 'Desk' } ]); - const products = await Product.findAll(); + const products = await Product.findAll({ order: [['id', 'ASC']] }); await Promise.all([ GroupMember.bulkCreate([ { UserId: user.id, GroupId: groups[0].id, RankId: ranks[0].id }, diff --git a/test/integration/include/schema.test.js b/test/integration/include/schema.test.js index 7db23df577d0..b8d7c26bb6a5 100644 --- a/test/integration/include/schema.test.js +++ b/test/integration/include/schema.test.js @@ -127,7 +127,7 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => { { title: 'Bed' }, { title: 'Pen' }, { title: 'Monitor' } - ]).then(() => Product.findAll()) + ]).then(() => Product.findAll({ order: [['id', 'ASC']] })) ]); const groupMembers = [ { AccUserId: user.id, GroupId: groups[0].id, RankId: ranks[0].id }, @@ -248,7 +248,7 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => { Product.bulkCreate([ { title: 'Chair' }, { title: 'Desk' } - ]).then(() => Product.findAll()) + ]).then(() => Product.findAll({ order: [['id', 'ASC']] })) ]); await Promise.all([ GroupMember.bulkCreate([ @@ -936,7 +936,7 @@ describe(Support.getTestDialectTeaser('Includes with schemas'), () => { Product.bulkCreate([ { title: 'Chair' }, { title: 'Desk' } - ]).then(() => Product.findAll()) + ]).then(() => Product.findAll({ order: [['id', 'ASC']] })) ]); await Promise.all([ GroupMember.bulkCreate([ diff --git a/test/integration/instance/save.test.js b/test/integration/instance/save.test.js index 79cbcb9e555a..3dca090c0e23 100644 --- a/test/integration/instance/save.test.js +++ b/test/integration/instance/save.test.js @@ -401,6 +401,14 @@ describe(Support.getTestDialectTeaser('Instance'), () => { expect(userAfterUpdate.username).to.equal('$SEQUELIZE'); }); + it('updates with function that contains multiple escaped dollar symbols', async function() { + const user = await this.User.create({}); + user.username = this.sequelize.fn('upper', '$sequelize and $sequelize2 and some money $42.69'); + await user.save(); + const userAfterUpdate = await this.User.findByPk(user.id); + expect(userAfterUpdate.username).to.equal('$SEQUELIZE AND $SEQUELIZE2 AND SOME MONEY $42.69'); + }); + describe('without timestamps option', () => { it("doesn't update the updatedAt column", async function() { const User2 = this.sequelize.define('User2', { diff --git a/test/integration/instance/values.test.js b/test/integration/instance/values.test.js index 14f24151adc0..402cfaf68045 100644 --- a/test/integration/instance/values.test.js +++ b/test/integration/instance/values.test.js @@ -122,6 +122,8 @@ describe(Support.getTestDialectTeaser('DAO'), () => { let now = dialect === 'sqlite' ? this.sequelize.fn('', this.sequelize.fn('datetime', 'now')) : this.sequelize.fn('NOW'); if (dialect === 'mssql') { now = this.sequelize.fn('', this.sequelize.fn('getdate')); + } else if (dialect === 'oracle') { + now = this.sequelize.fn('', this.sequelize.literal('SYSDATE')); } user.set({ d: now, diff --git a/test/integration/json.test.js b/test/integration/json.test.js index 37a511e5d4db..a71edabd60e2 100644 --- a/test/integration/json.test.js +++ b/test/integration/json.test.js @@ -26,7 +26,10 @@ describe('model', () => { it('should tell me that a column is json', async function() { const table = await this.sequelize.queryInterface.describeTable('Users'); // expected for mariadb 10.4 : https://jira.mariadb.org/browse/MDEV-15558 - if (dialect !== 'mariadb') { + // oracledb 19c doesn't support JSON and the DB datatype is BLOB + if (dialect === 'oracle') { + expect(table.emergency_contact.type).to.equal('BLOB'); + } else if (dialect !== 'mariadb') { expect(table.emergency_contact.type).to.equal('JSON'); } }); @@ -40,6 +43,8 @@ describe('model', () => { logging: sql => { if (dialect.match(/^mysql|mariadb/)) { expect(sql).to.include('?'); + } else if (dialect === 'oracle') { + expect(sql).to.include(':1'); } else { expect(sql).to.include('$1'); } @@ -196,6 +201,19 @@ describe('model', () => { expect(user.username).to.equal('anna'); }); + it('should be able to store strings', async function() { + if (dialect === 'oracle') { + const dbVersion = this.sequelize.options.databaseVersion; + // Oracle DB below 21c doesn't recognize a string as a valid json + if (dbVersion.localeCompare('21.0.0.0') === -1) { + this.skip(); + } + } + await this.User.create({ username: 'swen', emergency_contact: 'joe' }); + const user = await this.User.findOne({ where: { username: 'swen' } }); + expect(user.emergency_contact).to.equal('joe'); + }); + it('should be able to store values that require JSON escaping', async function() { const text = 'Multi-line \'$string\' needing "escaping" for $$ and $1 type values'; @@ -264,6 +282,65 @@ describe('model', () => { }); } + if (current.dialect.supports.JSON) { + describe('json cast type SQL injection', () => { + beforeEach(async function() { + this.User = this.sequelize.define('User', { + username: DataTypes.STRING, + metadata: DataTypes.JSON + }); + + this.Secret = this.sequelize.define('Secret', { + key: DataTypes.STRING, + value: DataTypes.STRING + }); + + await this.sequelize.sync({ force: true }); + + await this.User.bulkCreate([ + { username: 'alice', metadata: { role: 'admin', level: 10 } }, + { username: 'bob', metadata: { role: 'user', level: 5 } } + ]); + + await this.Secret.bulkCreate([ + { key: 'api_key', value: 'sk-secret-12345' } + ]); + }); + + it('should reject WHERE bypass via OR 1=1 injection in JSON cast type', async function() { + await expect(this.User.findAll({ + where: { metadata: { 'role::text) OR 1=1--': 'anything' } } + })).to.be.rejectedWith(Error, /Invalid cast type/); + }); + + it('should reject UNION-based cross-table data exfiltration via JSON cast type', async function() { + await expect(this.User.findAll({ + where: { + metadata: { + ['role::text) AND 0 UNION SELECT id,key,value,null,null FROM Secrets--']: 'x' + } + }, + raw: true + })).to.be.rejectedWith(Error, /Invalid cast type/); + }); + + it('should still allow legitimate JSON queries with valid cast types', async function() { + const users = await this.User.findAll({ + where: { metadata: { level: 10 } } + }); + expect(users).to.have.length(1); + expect(users[0].username).to.equal('alice'); + }); + + it('should still allow legitimate JSON queries with valid :: cast notation', async function() { + const users = await this.User.findAll({ + where: { metadata: { 'level::integer': { [Sequelize.Op.gt]: 3 } } } + }); + expect(users).to.have.length(2); + }); + }); + } + if (current.dialect.supports.JSONB) { describe('jsonb', () => { beforeEach(async function() { diff --git a/test/integration/model.test.js b/test/integration/model.test.js index 120c2124a85b..ad56c5c856f0 100644 --- a/test/integration/model.test.js +++ b/test/integration/model.test.js @@ -239,7 +239,8 @@ describe(Support.getTestDialectTeaser('Model'), () => { title: { type: Sequelize.STRING(50), allowNull: false, - defaultValue: '' + // Oracle dialect doesn't support empty string in a non-null column + defaultValue: dialect === 'oracle' ? 'A' : '' } }, { setterMethods: { @@ -250,7 +251,11 @@ describe(Support.getTestDialectTeaser('Model'), () => { await Task.sync({ force: true }); const record = await Task.build().save(); expect(record.title).to.be.a('string'); - expect(record.title).to.equal(''); + if (dialect === 'oracle') { + expect(record.title).to.equal('A'); + } else { + expect(record.title).to.equal(''); + } expect(titleSetter.notCalled).to.be.ok; // The setter method should not be invoked for default values }); @@ -540,6 +545,24 @@ describe(Support.getTestDialectTeaser('Model'), () => { expect(idx3.fields).to.deep.equal([ { attribute: 'fieldD', length: undefined, order: undefined, collate: undefined } ]); + } else if (dialect === 'oracle') { + primary = args[0]; + idx1 = args[1]; + idx2 = args[2]; + idx3 = args[3]; + + expect(idx1.fields).to.deep.equal([ + { attribute: 'fieldB', length: undefined, order: 'ASC', collate: undefined }, + { attribute: 'fieldA', length: undefined, order: 'ASC', collate: undefined } + ]); + + expect(idx2.fields).to.deep.equal([ + { attribute: 'fieldC', length: undefined, order: 'ASC', collate: undefined } + ]); + + expect(idx3.fields).to.deep.equal([ + { attribute: 'fieldD', length: undefined, order: 'ASC', collate: undefined } + ]); } else { // And finally mysql returns the primary first, and then the rest in the order they were defined primary = args[0]; @@ -989,7 +1012,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { fields: ['secretValue'], logging(sql) { test = true; - if (dialect === 'mssql') { + if (['mssql', 'oracle'].includes(dialect)) { expect(sql).to.not.contain('createdAt'); } else { expect(sql).to.match(/UPDATE\s+[`"]+User1s[`"]+\s+SET\s+[`"]+secretValue[`"]=(\$1|\?),[`"]+updatedAt[`"]+=(\$2|\?)\s+WHERE [`"]+id[`"]+\s=\s(\$3|\?)/); @@ -1627,15 +1650,15 @@ describe(Support.getTestDialectTeaser('Model'), () => { expect(await User.findOne({ where: { username: 'Bob' } })).to.be.null; const tobi = await User.findOne({ where: { username: 'Tobi' } }); await tobi.destroy(); - let sql = dialect === 'db2' ? 'SELECT * FROM "paranoidusers" WHERE "username"=\'Tobi\'' : 'SELECT * FROM paranoidusers WHERE username=\'Tobi\''; + let sql = ['db2', 'oracle'].includes(dialect) ? 'SELECT * FROM "paranoidusers" WHERE "username"=\'Tobi\'' : 'SELECT * FROM paranoidusers WHERE username=\'Tobi\''; let result = await this.sequelize.query(sql, { plain: true }); expect(result.username).to.equal('Tobi'); await User.destroy({ where: { username: 'Tony' } }); - sql = dialect === 'db2' ? 'SELECT * FROM "paranoidusers" WHERE "username"=\'Tony\'' : 'SELECT * FROM paranoidusers WHERE username=\'Tony\''; + sql = ['db2', 'oracle'].includes(dialect) ? 'SELECT * FROM "paranoidusers" WHERE "username"=\'Tony\'' : 'SELECT * FROM paranoidusers WHERE username=\'Tony\''; result = await this.sequelize.query(sql, { plain: true }); expect(result.username).to.equal('Tony'); await User.destroy({ where: { username: ['Tony', 'Max'] }, force: true }); - sql = dialect === 'db2' ? 'SELECT * FROM "paranoidusers"' : 'SELECT * FROM paranoidusers'; + sql = ['db2', 'oracle'].includes(dialect) ? 'SELECT * FROM "paranoidusers"' : 'SELECT * FROM paranoidusers'; const [users] = await this.sequelize.query(sql, { raw: true }); expect(users).to.have.length(1); expect(users[0].username).to.equal('Tobi'); @@ -1813,7 +1836,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { expect(count.find(i => i.data === 'B')).to.deep.equal({ data: 'B', count: 1 }); }); - if (dialect !== 'mssql' && dialect !== 'db2') { + if (!['mssql', 'db2', 'oracle'].includes(dialect)) { describe('aggregate', () => { it('allows grouping by aliased attribute', async function() { await this.User.aggregate('id', 'count', { @@ -2100,6 +2123,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { db2: 10, mariadb: 3, mysql: 1, + oracle: 2, sqlite: 1 }; expect(schemas).to.have.length(expectedLengths[dialect]); @@ -2150,7 +2174,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { test++; expect(sql).to.not.contain('special'); } - else if (['mysql', 'mssql', 'mariadb', 'db2'].includes(dialect)) { + else if (['mysql', 'mssql', 'mariadb', 'db2', 'oracle'].includes(dialect)) { test++; expect(sql).to.not.contain('special'); } @@ -2169,7 +2193,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { test++; expect(sql).to.contain('special'); } - else if (['mysql', 'mssql', 'mariadb', 'db2'].includes(dialect)) { + else if (['mysql', 'mssql', 'mariadb', 'db2', 'oracle'].includes(dialect)) { test++; expect(sql).to.contain('special'); } @@ -2195,7 +2219,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { UserPub.hasMany(ItemPub, { foreignKeyConstraint: true }); - if (['postgres', 'mssql', 'db2', 'mariadb'].includes(dialect)) { + if (['postgres', 'mssql', 'db2', 'mariadb', 'oracle'].includes(dialect)) { await Support.dropTestSchemas(this.sequelize); await this.sequelize.queryInterface.createSchema('prefix'); } @@ -2211,6 +2235,8 @@ describe(Support.getTestDialectTeaser('Model'), () => { expect(sql).to.match(/REFERENCES\s+"prefix"\."UserPubs" \("id"\)/); } else if (dialect === 'mssql') { expect(sql).to.match(/REFERENCES\s+\[prefix\]\.\[UserPubs\] \(\[id\]\)/); + } else if (dialect === 'oracle') { + expect(sql).to.match(/REFERENCES\s+"prefix"."UserPubs" \("id"\)/); } else if (dialect === 'mariadb') { expect(sql).to.match(/REFERENCES\s+`prefix`\.`UserPubs` \(`id`\)/); } else { @@ -2241,6 +2267,9 @@ describe(Support.getTestDialectTeaser('Model'), () => { } else if (dialect === 'mariadb') { expect(this.UserSpecialSync.getTableName().toString()).to.equal('`special`.`UserSpecials`'); expect(UserPublic.indexOf('INSERT INTO `UserPublics`')).to.be.above(-1); + } else if (dialect === 'oracle') { + expect(this.UserSpecialSync.getTableName().toString()).to.equal('"special"."UserSpecials"'); + expect(UserPublic.indexOf('INSERT INTO "UserPublics"')).to.be.above(-1); } else { expect(this.UserSpecialSync.getTableName().toString()).to.equal('`special.UserSpecials`'); expect(UserPublic).to.include('INSERT INTO `UserPublics`'); @@ -2257,6 +2286,8 @@ describe(Support.getTestDialectTeaser('Model'), () => { expect(UserSpecial).to.include('INSERT INTO `special.UserSpecials`'); } else if (dialect === 'mssql') { expect(UserSpecial).to.include('INSERT INTO [special].[UserSpecials]'); + } else if (dialect === 'oracle') { + expect(UserSpecial).to.include('INSERT INTO "special"."UserSpecials"'); } else if (dialect === 'mariadb') { expect(UserSpecial).to.include('INSERT INTO `special`.`UserSpecials`'); } else { @@ -2272,6 +2303,8 @@ describe(Support.getTestDialectTeaser('Model'), () => { expect(user).to.include('UPDATE "special"."UserSpecials"'); } else if (dialect === 'mssql') { expect(user).to.include('UPDATE [special].[UserSpecials]'); + } else if (dialect === 'oracle') { + expect(user).to.include('UPDATE "special"."UserSpecials"'); } else if (dialect === 'mariadb') { expect(user).to.include('UPDATE `special`.`UserSpecials`'); } else { @@ -2306,21 +2339,14 @@ describe(Support.getTestDialectTeaser('Model'), () => { Post.belongsTo(this.Author); // The posts table gets dropped in the before filter. - await Post.sync({ logging: _.once(sql => { - if (dialect === 'postgres') { - expect(sql).to.match(/"authorId" INTEGER REFERENCES "authors" \("id"\)/); - } else if (['mysql', 'mariadb'].includes(dialect)) { - expect(sql).to.match(/FOREIGN KEY \(`authorId`\) REFERENCES `authors` \(`id`\)/); - } else if (dialect === 'db2') { - expect(sql).to.match(/FOREIGN KEY \("authorId"\) REFERENCES "authors" \("id"\)/); - } else if (dialect === 'mssql') { - expect(sql).to.match(/FOREIGN KEY \(\[authorId\]\) REFERENCES \[authors\] \(\[id\]\)/); - } else if (dialect === 'sqlite') { - expect(sql).to.match(/`authorId` INTEGER REFERENCES `authors` \(`id`\)/); - } else { - throw new Error('Undefined dialect!'); - } - }) }); + await Post.sync(); + + const foreignKeys = await this.sequelize.queryInterface.getForeignKeyReferencesForTable(Post.getTableName()); + + expect(foreignKeys.length).to.eq(1); + expect(foreignKeys[0].columnName).to.eq('authorId'); + expect(foreignKeys[0].referencedTableName).to.eq('authors'); + expect(foreignKeys[0].referencedColumnName).to.eq('id'); }); it('uses a table name as a string and references the author table', async function() { @@ -2332,21 +2358,14 @@ describe(Support.getTestDialectTeaser('Model'), () => { Post.belongsTo(this.Author); // The posts table gets dropped in the before filter. - await Post.sync({ logging: _.once(sql => { - if (dialect === 'postgres') { - expect(sql).to.match(/"authorId" INTEGER REFERENCES "authors" \("id"\)/); - } else if (['mysql', 'mariadb'].includes(dialect)) { - expect(sql).to.match(/FOREIGN KEY \(`authorId`\) REFERENCES `authors` \(`id`\)/); - } else if (dialect === 'db2') { - expect(sql).to.match(/FOREIGN KEY \("authorId"\) REFERENCES "authors" \("id"\)/); - } else if (dialect === 'sqlite') { - expect(sql).to.match(/`authorId` INTEGER REFERENCES `authors` \(`id`\)/); - } else if (dialect === 'mssql') { - expect(sql).to.match(/FOREIGN KEY \(\[authorId\]\) REFERENCES \[authors\] \(\[id\]\)/); - } else { - throw new Error('Undefined dialect!'); - } - }) }); + await Post.sync(); + + const foreignKeys = await this.sequelize.queryInterface.getForeignKeyReferencesForTable(Post.getTableName()); + + expect(foreignKeys.length).to.eq(1); + expect(foreignKeys[0].columnName).to.eq('authorId'); + expect(foreignKeys[0].referencedTableName).to.eq('authors'); + expect(foreignKeys[0].referencedColumnName).to.eq('id'); }); it('emits an error event as the referenced table name is invalid', async function() { @@ -2387,6 +2406,8 @@ describe(Support.getTestDialectTeaser('Model'), () => { expect(err.message).to.match(/Could not create constraint/); } else if (dialect === 'db2') { expect(err.message).to.match(/ is an undefined name/); + } else if (dialect === 'oracle') { + expect(err.message).to.match(/^ORA-00942:/); } else { throw new Error('Undefined dialect!'); } diff --git a/test/integration/model/attributes/field.test.js b/test/integration/model/attributes/field.test.js index 15a0f9afca8d..fb9221a01a47 100644 --- a/test/integration/model/attributes/field.test.js +++ b/test/integration/model/attributes/field.test.js @@ -468,6 +468,11 @@ describe(Support.getTestDialectTeaser('Model'), () => { Sequelize.literal('1 AS "someProperty"'), [Sequelize.literal('1'), 'someProperty2'] ]; + } else if (dialect === 'oracle') { + findAttributes = [ + Sequelize.literal('(CASE WHEN EXISTS(SELECT 1 FROM DUAL) THEN 1 ELSE 0 END) AS "someProperty"'), + [Sequelize.literal('(CASE WHEN EXISTS(SELECT 1 FROM DUAL) THEN 1 ELSE 0 END)'), 'someProperty2'] + ]; } else { findAttributes = [ Sequelize.literal('EXISTS(SELECT 1) AS "someProperty"'), diff --git a/test/integration/model/attributes/types.test.js b/test/integration/model/attributes/types.test.js index 4ee1dc16774f..7267dbbd71a2 100644 --- a/test/integration/model/attributes/types.test.js +++ b/test/integration/model/attributes/types.test.js @@ -103,6 +103,8 @@ describe(Support.getTestDialectTeaser('Model'), () => { boolQuery = 'CAST(CASE WHEN EXISTS(SELECT 1) THEN 1 ELSE 0 END AS BIT) AS "someBoolean"'; } else if (dialect === 'db2') { boolQuery = '1 AS "someBoolean"'; + } else if (dialect === 'oracle') { + boolQuery = '(CASE WHEN EXISTS(SELECT 1 FROM DUAL) THEN 1 ELSE 0 END) AS "someBoolean"'; } const post = await Post.findOne({ attributes: ['id', 'text', Sequelize.literal(boolQuery)] }); diff --git a/test/integration/model/bulk-create.test.js b/test/integration/model/bulk-create.test.js index 4a40ca992312..76394a13da94 100644 --- a/test/integration/model/bulk-create.test.js +++ b/test/integration/model/bulk-create.test.js @@ -64,7 +64,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { await transaction.rollback(); }); } - + it('should not alter options', async function() { const User = this.sequelize.define('User'); await User.sync({ force: true }); @@ -158,7 +158,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { style: 'ipa' }], { logging(sql) { - if (dialect === 'postgres') { + if (['postgres', 'oracle'].includes(dialect)) { expect(sql).to.include('INSERT INTO "Beers" ("id","style","createdAt","updatedAt") VALUES (DEFAULT'); } else if (dialect === 'db2') { expect(sql).to.include('INSERT INTO "Beers" ("style","createdAt","updatedAt") VALUES'); @@ -732,6 +732,364 @@ describe(Support.getTestDialectTeaser('Model'), () => { this.User.bulkCreate(data, { updateOnDuplicate: [] }) ).to.be.rejectedWith('updateOnDuplicate option only supports non-empty array.'); }); + + if (current.dialect.supports.inserts.conflictFields) { + it('should respect the conflictAttributes option', async function() { + const Permissions = this.sequelize.define( + 'permissions', + { + userId: { + type: DataTypes.INTEGER, + allowNull: false, + field: 'user_id' + }, + permissions: { + type: new DataTypes.ENUM('owner', 'admin', 'member'), + allowNull: false, + default: 'member' + } + }, + { + timestamps: false + } + ); + + await Permissions.sync({ force: true }); + + // We don't want to create this index with the table, since we don't want our sequelize instance + // to know it exists. This prevents it from being inferred. + await this.sequelize.queryInterface.addIndex( + 'permissions', + ['user_id'], + { + unique: true + } + ); + + const initialPermissions = [ + { + userId: 1, + permissions: 'member' + }, + { + userId: 2, + permissions: 'admin' + }, + { + userId: 3, + permissions: 'owner' + } + ]; + + const initialResults = await Permissions.bulkCreate(initialPermissions, { + conflictAttributes: ['userId'], + updateOnDuplicate: ['permissions'] + }); + + expect(initialResults.length).to.eql(3); + + for (let i = 0; i < 3; i++) { + const result = initialResults[i]; + const exp = initialPermissions[i]; + + expect(result).to.not.eql(null); + expect(result.userId).to.eql(exp.userId); + expect(result.permissions).to.eql(exp.permissions); + } + + const newPermissions = [ + { + userId: 1, + permissions: 'owner' + }, + { + userId: 2, + permissions: 'member' + }, + { + userId: 3, + permissions: 'admin' + } + ]; + + const newResults = await Permissions.bulkCreate(newPermissions, { + conflictAttributes: ['userId'], + updateOnDuplicate: ['permissions'] + }); + + expect(newResults.length).to.eql(3); + + for (let i = 0; i < 3; i++) { + const result = newResults[i]; + const exp = newPermissions[i]; + + expect(result).to.not.eql(null); + expect(result.id).to.eql(initialResults[i].id); + expect(result.userId).to.eql(exp.userId); + expect(result.permissions).to.eql(exp.permissions); + } + }); + + describe('conflictWhere', () => { + const Memberships = current.define( + 'memberships', + { + // ID of the member (no foreign key constraint for testing purposes) + user_id: DataTypes.INTEGER, + // ID of what the member is a member of + foreign_id: DataTypes.INTEGER, + time_deleted: DataTypes.DATE + }, + { + createdAt: false, + updatedAt: false, + deletedAt: 'time_deleted', + indexes: [ + { + fields: ['user_id', 'foreign_id'], + unique: true, + where: { time_deleted: null } + } + ] + } + ); + + const options = { + conflictWhere: { time_deleted: null }, + conflictAttributes: ['user_id', 'foreign_id'], + updateOnDuplicate: ['user_id', 'foreign_id', 'time_deleted'] + }; + + beforeEach(() => Memberships.sync({ force: true })); + + it('should insert items with conflictWhere', async () => { + const memberships = new Array(10).fill().map((_, i) => ({ + user_id: i + 1, + foreign_id: i + 20, + time_deleted: null + })); + + const results = await Memberships.bulkCreate( + memberships, + options + ); + + for (let i = 0; i < 10; i++) { + expect(results[i].user_id).to.eq(memberships[i].user_id); + expect(results[i].team_id).to.eq(memberships[i].team_id); + expect(results[i].time_deleted).to.eq(null); + } + }); + + it('should not conflict with soft deleted memberships', async () => { + const memberships = new Array(10).fill().map((_, i) => ({ + user_id: i + 1, + foreign_id: i + 20, + time_deleted: new Date() + })); + + let results = await Memberships.bulkCreate(memberships, options); + + for (let i = 0; i < 10; i++) { + expect(results[i].user_id).to.eq(memberships[i].user_id); + expect(results[i].team_id).to.eq(memberships[i].team_id); + expect(results[i].time_deleted).to.not.eq(null); + } + + results = await Memberships.bulkCreate( + memberships.map(membership => ({ + ...membership, + time_deleted: null + })), + options + ); + + for (let i = 0; i < 10; i++) { + expect(results[i].user_id).to.eq(memberships[i].user_id); + expect(results[i].team_id).to.eq(memberships[i].team_id); + expect(results[i].time_deleted).to.eq(null); + } + + const count = await Memberships.count(); + + expect(count).to.eq(20); + }); + + it('should upsert existing memberships', async () => { + const memberships = new Array(10).fill().map((_, i) => ({ + user_id: i + 1, + foreign_id: i + 20, + time_deleted: i % 2 ? new Date() : null + })); + + let results = await Memberships.bulkCreate(memberships, options); + + for (let i = 0; i < 10; i++) { + expect(results[i].user_id).to.eq(memberships[i].user_id); + expect(results[i].team_id).to.eq(memberships[i].team_id); + if (i % 2) { + expect(results[i].time_deleted).to.not.eq(null); + } else { + expect(results[i].time_deleted).to.eq(null); + } + } + + for (const membership of memberships) { + membership.time_deleted; + } + + results = await Memberships.bulkCreate( + memberships.map(membership => ({ + ...membership, + time_deleted: null + })), + options + ); + + for (let i = 0; i < 10; i++) { + expect(results[i].user_id).to.eq(memberships[i].user_id); + expect(results[i].team_id).to.eq(memberships[i].team_id); + expect(results[i].time_deleted).to.eq(null); + } + + const count = await Memberships.count({ paranoid: false }); + + expect(count).to.eq(15); + }); + }); + + if ( + current.dialect.supports.inserts.onConflictWhere + ) { + describe('conflictWhere', () => { + const Memberships = current.define( + 'memberships', + { + // ID of the member (no foreign key constraint for testing purposes) + user_id: DataTypes.INTEGER, + // ID of what the member is a member of + foreign_id: DataTypes.INTEGER, + time_deleted: DataTypes.DATE + }, + { + createdAt: false, + updatedAt: false, + deletedAt: 'time_deleted', + indexes: [ + { + fields: ['user_id', 'foreign_id'], + unique: true, + where: { time_deleted: null } + } + ] + } + ); + + const options = { + conflictWhere: { time_deleted: null }, + conflictAttributes: ['user_id', 'foreign_id'], + updateOnDuplicate: ['user_id', 'foreign_id', 'time_deleted'] + }; + + beforeEach(() => Memberships.sync({ force: true })); + + it('should insert items with conflictWhere', async () => { + const memberships = new Array(10).fill().map((_, i) => ({ + user_id: i + 1, + foreign_id: i + 20, + time_deleted: null + })); + + const results = await Memberships.bulkCreate( + memberships, + options + ); + + for (let i = 0; i < 10; i++) { + expect(results[i].user_id).to.eq(memberships[i].user_id); + expect(results[i].team_id).to.eq(memberships[i].team_id); + expect(results[i].time_deleted).to.eq(null); + } + }); + + it('should not conflict with soft deleted memberships', async () => { + const memberships = new Array(10).fill().map((_, i) => ({ + user_id: i + 1, + foreign_id: i + 20, + time_deleted: new Date() + })); + + let results = await Memberships.bulkCreate(memberships, options); + + for (let i = 0; i < 10; i++) { + expect(results[i].user_id).to.eq(memberships[i].user_id); + expect(results[i].team_id).to.eq(memberships[i].team_id); + expect(results[i].time_deleted).to.not.eq(null); + } + + results = await Memberships.bulkCreate( + memberships.map(membership => ({ + ...membership, + time_deleted: null + })), + options + ); + + for (let i = 0; i < 10; i++) { + expect(results[i].user_id).to.eq(memberships[i].user_id); + expect(results[i].team_id).to.eq(memberships[i].team_id); + expect(results[i].time_deleted).to.eq(null); + } + + const count = await Memberships.count(); + + expect(count).to.eq(20); + }); + + it('should upsert existing memberships', async () => { + const memberships = new Array(10).fill().map((_, i) => ({ + user_id: i + 1, + foreign_id: i + 20, + time_deleted: i % 2 ? new Date() : null + })); + + let results = await Memberships.bulkCreate(memberships, options); + + for (let i = 0; i < 10; i++) { + expect(results[i].user_id).to.eq(memberships[i].user_id); + expect(results[i].team_id).to.eq(memberships[i].team_id); + if (i % 2) { + expect(results[i].time_deleted).to.not.eq(null); + } else { + expect(results[i].time_deleted).to.eq(null); + } + } + + for (const membership of memberships) { + membership.time_deleted; + } + + results = await Memberships.bulkCreate( + memberships.map(membership => ({ + ...membership, + time_deleted: null + })), + options + ); + + for (let i = 0; i < 10; i++) { + expect(results[i].user_id).to.eq(memberships[i].user_id); + expect(results[i].team_id).to.eq(memberships[i].team_id); + expect(results[i].time_deleted).to.eq(null); + } + + const count = await Memberships.count({ paranoid: false }); + + expect(count).to.eq(15); + }); + }); + } + } }); } diff --git a/test/integration/model/create.test.js b/test/integration/model/create.test.js index 137812185a2d..c89e8804f882 100644 --- a/test/integration/model/create.test.js +++ b/test/integration/model/create.test.js @@ -450,7 +450,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { }); } - (dialect !== 'sqlite' && dialect !== 'mssql' && dialect !== 'db2' ? it : it.skip)('should not fail silently with concurrency higher than pool, a unique constraint and a create hook resulting in mismatched values', async function() { + (!['sqlite', 'mssql', 'db2', 'oracle'].includes(dialect) ? it : it.skip)('should not fail silently with concurrency higher than pool, a unique constraint and a create hook resulting in mismatched values', async function() { const User = this.sequelize.define('user', { username: { type: DataTypes.STRING, @@ -912,6 +912,15 @@ describe(Support.getTestDialectTeaser('Model'), () => { expect(user0.secretValue).to.equal('$SEQUELIZE'); }); + it('should escape multiple instances of $ in sequelize functions arguments', async function() { + const user = await this.User.create({ + secretValue: this.sequelize.fn('upper', '$sequelize and $sequelize2 and some money $42.69') + }); + + const user0 = await this.User.findByPk(user.id); + expect(user0.secretValue).to.equal('$SEQUELIZE AND $SEQUELIZE2 AND SOME MONEY $42.69'); + }); + it('should work with a non-id named uuid primary key columns', async function() { const Monkey = this.sequelize.define('Monkey', { monkeyId: { type: DataTypes.UUID, primaryKey: true, defaultValue: DataTypes.UUIDV4, allowNull: false } @@ -1218,7 +1227,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { expect(test).to.be.true; }); - it('should only store the values passed in the whitelist', async function() { + it('should only store the values passed in the whitelist', async function() { // A unique column do not accept NULL in Db2. Unique column must have value in insert statement. const data = { username: 'Peter', secretValue: '42', uniqueName: 'name' }; const fields = dialect === 'db2' ? { fields: ['username', 'uniqueName'] } : { fields: ['username'] }; diff --git a/test/integration/model/findAll/order.test.js b/test/integration/model/findAll/order.test.js index 6f48a73e57db..9775f8a0f428 100644 --- a/test/integration/model/findAll/order.test.js +++ b/test/integration/model/findAll/order.test.js @@ -22,7 +22,8 @@ describe(Support.getTestDialectTeaser('Model'), () => { }); }); - if (current.dialect.name !== 'mssql') { + // Oracle doesn't support operators in Order by clause + if (!['mssql', 'oracle'].includes(current.dialect.name)) { const email = current.dialect.name === 'db2' ? '"email"' : 'email'; it('should work with order: literal()', async function() { const users = await this.User.findAll({ @@ -86,7 +87,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { } it('should not throw on a literal', async function() { - if (current.dialect.name === 'db2') { + if (['db2', 'oracle'].includes(current.dialect.name)) { await this.User.findAll({ order: [ ['id', this.sequelize.literal('ASC, "name" DESC')] diff --git a/test/integration/model/findOne.test.js b/test/integration/model/findOne.test.js index 73c499b15b62..805fa2bc5f58 100644 --- a/test/integration/model/findOne.test.js +++ b/test/integration/model/findOne.test.js @@ -223,6 +223,49 @@ describe(Support.getTestDialectTeaser('Model'), () => { expect(u2.name).to.equal('Johnno'); }); + it('finds entries via a bigint primary key called id', async function() { + const UserPrimary = this.sequelize.define('UserWithPrimaryKey', { + id: { type: DataTypes.BIGINT, primaryKey: true }, + name: DataTypes.STRING + }); + + await UserPrimary.sync({ force: true }); + + await UserPrimary.create({ + id: 9007199254740993n, // Number.MAX_SAFE_INTEGER + 2 (cannot be represented exactly as a number in JS) + name: 'Johnno' + }); + + const u2 = await UserPrimary.findByPk(9007199254740993n); + expect(u2.name).to.equal('Johnno'); + + // Getting the value back as bigint is not supported yet: https://github.com/sequelize/sequelize/issues/14296 + // With most dialects we'll receive a string, but in some cases we have to be a bit creative to prove that we did get hold of the right record: + if (dialect === 'db2') { + // ibm_db 2.7.4+ returns BIGINT values as JS numbers, which leads to a loss of precision: + // https://github.com/ibmdb/node-ibm_db/issues/816 + // It means that u2.id comes back as 9007199254740992 here :( + // Hopefully this will be fixed soon. + // For now we can do a separate query where we stringify the value to prove that it did get stored correctly: + const [[{ stringifiedId }]] = await this.sequelize.query(`select "id"::varchar as "stringifiedId" from "${UserPrimary.tableName}" where "id" = 9007199254740993`); + expect(stringifiedId).to.equal('9007199254740993'); + } else if (dialect === 'mariadb') { + // With our current default config, the mariadb driver sends back a Long instance. + // Updating the mariadb dev dep and passing "supportBigInt: true" would get it back as a bigint, + // but that's potentially a big change. + // For now, we'll just stringify the Long and make the comparison: + expect(u2.id.toString()).to.equal('9007199254740993'); + } else if (dialect === 'sqlite') { + // sqlite3 returns a number, so u2.id comes back as 9007199254740992 here: + // https://github.com/TryGhost/node-sqlite3/issues/922 + // For now we can do a separate query where we stringify the value to prove that it did get stored correctly: + const [[{ stringifiedId }]] = await this.sequelize.query(`select cast("id" as text) as "stringifiedId" from "${UserPrimary.tableName}" where "id" = 9007199254740993`); + expect(stringifiedId).to.equal('9007199254740993'); + } else { + expect(u2.id).to.equal('9007199254740993'); + } + }); + it('always honors ZERO as primary key', async function() { const permutations = [ 0, diff --git a/test/integration/model/json.test.js b/test/integration/model/json.test.js index 3eb69501d9fd..b6f26539bd95 100644 --- a/test/integration/model/json.test.js +++ b/test/integration/model/json.test.js @@ -29,22 +29,43 @@ describe(Support.getTestDialectTeaser('Model'), () => { it('findOrCreate supports transactions, json and locks', async function() { const transaction = await current.transaction(); - await this.Event.findOrCreate({ - where: { + const data = { json: { some: { input: 'Hello' } } }, - defaults: { + default_values = { json: { some: { input: 'Hello' }, input: [1, 2, 3] }, data: { some: { input: 'There' }, input: [4, 5, 6] } - }, - transaction, - lock: transaction.LOCK.UPDATE, - logging: sql => { - if (sql.includes('SELECT') && !sql.includes('CREATE')) { - expect(sql.includes('FOR UPDATE')).to.be.true; + }; + + if (current.options.dialect !== 'oracle') { + await this.Event.findOrCreate({ + where: data, + defaults: default_values, + transaction, + lock: transaction.LOCK.UPDATE, + logging: sql => { + if (sql.includes('SELECT') && !sql.includes('CREATE')) { + expect(sql.includes('FOR UPDATE')).to.be.true; + } } + }); + } else { + const events = await this.Event.findAll({ + where: data, + lock: transaction.LOCK.UPDATE, + transaction, + logging: sql => { + if (sql.includes('SELECT') && !sql.includes('CREATE')) { + expect(sql.includes('FOR UPDATE')).to.be.true; + } + } + }); + if (events.length === 0) { + await this.Event.create(default_values, { + transaction + }); } - }); + } const count = await this.Event.count(); expect(count).to.equal(0); diff --git a/test/integration/model/sync.test.js b/test/integration/model/sync.test.js index 09450be58f8d..a7a3ffd918fc 100644 --- a/test/integration/model/sync.test.js +++ b/test/integration/model/sync.test.js @@ -1,11 +1,13 @@ 'use strict'; const chai = require('chai'), - Sequelize = require('sequelize'), + { Sequelize, Deferrable, DataTypes } = require('sequelize'), expect = chai.expect, Support = require('../support'), dialect = Support.getTestDialect(); +const sequelize = Support.sequelize; + describe(Support.getTestDialectTeaser('Model'), () => { describe('sync', () => { beforeEach(async function() { @@ -153,6 +155,7 @@ describe(Support.getTestDialectTeaser('Model'), () => { expect(data.dataValues.name).to.eql('test3'); expect(data.dataValues.age).to.eql('1'); }); + it('should properly create composite index that fails on constraint violation', async function() { const testSync = this.sequelize.define('testSync', { name: Sequelize.STRING, @@ -169,21 +172,118 @@ describe(Support.getTestDialectTeaser('Model'), () => { } }); - it('should properly alter tables when there are foreign keys', async function() { - const foreignKeyTestSyncA = this.sequelize.define('foreignKeyTestSyncA', { - dummy: Sequelize.STRING - }); + it('supports creating tables with cyclic associations', async () => { + const A = sequelize.define('A', {}, { timestamps: false }); + const B = sequelize.define('B', {}, { timestamps: false }); - const foreignKeyTestSyncB = this.sequelize.define('foreignKeyTestSyncB', { - dummy: Sequelize.STRING + // These models both have a foreign key that references the other model. + // Sequelize should be able to create them. + A.belongsTo(B, { foreignKey: { allowNull: false } }); + B.belongsTo(A, { foreignKey: { allowNull: false } }); + + await sequelize.sync(); + + const [aFks, bFks] = await Promise.all([ + sequelize.queryInterface.getForeignKeyReferencesForTable(A.getTableName()), + sequelize.queryInterface.getForeignKeyReferencesForTable(B.getTableName()) + ]); + + expect(aFks.length).to.eq(1); + expect(aFks[0].referencedTableName).to.eq('Bs'); + expect(aFks[0].referencedColumnName).to.eq('id'); + expect(aFks[0].columnName).to.eq('BId'); + + expect(bFks.length).to.eq(1); + expect(bFks[0].referencedTableName).to.eq('As'); + expect(bFks[0].referencedColumnName).to.eq('id'); + expect(bFks[0].columnName).to.eq('AId'); + }); + + it('supports creating two identically named tables in different schemas', async () => { + await sequelize.queryInterface.createSchema('custom_schema'); + + const Model1 = sequelize.define('A1', {}, { schema: 'custom_schema', tableName: 'a', timestamps: false }); + const Model2 = sequelize.define('A2', {}, { tableName: 'a', timestamps: false }); + + await Model1.sync(); + await Model2.sync(); + + await Model1.create(); + await Model2.create(); + }); + + describe('with { alter: true }', () => { + it('should properly alter tables when there are foreign keys', async function() { + const foreignKeyTestSyncA = this.sequelize.define('foreignKeyTestSyncA', { + dummy: Sequelize.STRING + }); + + const foreignKeyTestSyncB = this.sequelize.define('foreignKeyTestSyncB', { + dummy: Sequelize.STRING + }); + + foreignKeyTestSyncA.hasMany(foreignKeyTestSyncB); + foreignKeyTestSyncB.belongsTo(foreignKeyTestSyncA); + + await this.sequelize.sync({ alter: true }); + await this.sequelize.sync({ alter: true }); }); - foreignKeyTestSyncA.hasMany(foreignKeyTestSyncB); - foreignKeyTestSyncB.belongsTo(foreignKeyTestSyncA); + // TODO: sqlite's foreign_key_list pragma does not return the DEFERRABLE status of the column + // so sync({ alter: true }) cannot know whether the column must be updated. + // so for now, deferrableConstraints is disabled for sqlite (as it's only used in tests) + if (sequelize.dialect.supports.deferrableConstraints) { + it('updates the deferrable property of a foreign key', async () => { + const A = sequelize.define('A', { + BId: { + type: DataTypes.INTEGER, + references: { + deferrable: Deferrable.INITIALLY_IMMEDIATE() + } + } + }); + const B = sequelize.define('B'); - await this.sequelize.sync({ alter: true }); + A.belongsTo(B); - await this.sequelize.sync({ alter: true }); + await sequelize.sync(); + + { + const aFks = await sequelize.queryInterface.getForeignKeyReferencesForTable(A.getTableName()); + + expect(aFks.length).to.eq(1); + expect(aFks[0].deferrable).to.eq(Deferrable.INITIALLY_IMMEDIATE); + } + + A.rawAttributes.BId.references.deferrable = Deferrable.INITIALLY_DEFERRED; + await sequelize.sync({ alter: true }); + + { + const aFks = await sequelize.queryInterface.getForeignKeyReferencesForTable(A.getTableName()); + + expect(aFks.length).to.eq(1); + expect(aFks[0].deferrable).to.eq(Deferrable.INITIALLY_DEFERRED); + } + }); + } + + // TODO add support for db2 and mssql dialects + if (!['db2', 'mssql'].includes(dialect)) { + it('does not recreate existing enums (#7649)', async () => { + sequelize.define('Media', { + type: DataTypes.ENUM([ + 'video', 'audio' + ]) + }); + await sequelize.sync({ alter: true }); + sequelize.define('Media', { + type: DataTypes.ENUM([ + 'image', 'video', 'audio' + ]) + }); + await sequelize.sync({ alter: true }); + }); + } }); describe('indexes', () => { diff --git a/test/integration/model/upsert.test.js b/test/integration/model/upsert.test.js index 072f2797e80e..764ffe1fe293 100644 --- a/test/integration/model/upsert.test.js +++ b/test/integration/model/upsert.test.js @@ -760,6 +760,167 @@ describe(Support.getTestDialectTeaser('Model'), () => { expect(otherMembership.id).to.not.eq(originalMembership.id); }); }); + + if (current.dialect.supports.inserts.onConflictWhere) { + describe('conflictWhere', () => { + const Users = current.define( + 'users', + { + name: DataTypes.STRING, + bio: DataTypes.STRING, + isUnique: DataTypes.BOOLEAN + }, + { + indexes: [ + { + unique: true, + fields: ['name'], + where: { isUnique: true } + } + ] + } + ); + + beforeEach(() => Users.sync({ force: true })); + + it('should insert with no other rows', async () => { + const [newRow] = await Users.upsert( + { + name: 'John', + isUnique: true + }, + { + conflictWhere: { + isUnique: true + } + } + ); + + expect(newRow).to.not.eq(null); + expect(newRow.name).to.eq('John'); + }); + + it('should update with another unique user', async () => { + let [newRow] = await Users.upsert( + { + name: 'John', + isUnique: true, + bio: 'before' + }, + { + conflictWhere: { + isUnique: true + } + } + ); + + expect(newRow).to.not.eq(null); + expect(newRow.name).to.eq('John'); + expect(newRow.bio).to.eq('before'); + + [newRow] = await Users.upsert( + { + name: 'John', + isUnique: true, + bio: 'after' + }, + { + conflictWhere: { + isUnique: true + } + } + ); + + expect(newRow).to.not.eq(null); + expect(newRow.name).to.eq('John'); + expect(newRow.bio).to.eq('after'); + + const rowCount = await Users.count(); + + expect(rowCount).to.eq(1); + }); + + it('allows both unique and non-unique users with the same name', async () => { + let [newRow] = await Users.upsert( + { + name: 'John', + isUnique: true, + bio: 'first' + }, + { + conflictWhere: { + isUnique: true + } + } + ); + + expect(newRow).to.not.eq(null); + expect(newRow.name).to.eq('John'); + expect(newRow.bio).to.eq('first'); + + [newRow] = await Users.upsert( + { + name: 'John', + isUnique: false, + bio: 'second' + }, + { + conflictWhere: { + isUnique: true + } + } + ); + + expect(newRow).to.not.eq(null); + expect(newRow.name).to.eq('John'); + expect(newRow.bio).to.eq('second'); + + const rowCount = await Users.count(); + + expect(rowCount).to.eq(2); + }); + + it('allows for multiple unique users with different names', async () => { + let [newRow] = await Users.upsert( + { + name: 'John', + isUnique: true, + bio: 'first' + }, + { + conflictWhere: { + isUnique: true + } + } + ); + + expect(newRow).to.not.eq(null); + expect(newRow.name).to.eq('John'); + expect(newRow.bio).to.eq('first'); + + [newRow] = await Users.upsert( + { + name: 'Bob', + isUnique: false, + bio: 'second' + }, + { + conflictWhere: { + isUnique: true + } + } + ); + + expect(newRow).to.not.eq(null); + expect(newRow.name).to.eq('Bob'); + expect(newRow.bio).to.eq('second'); + + const rowCount = await Users.count(); + + expect(rowCount).to.eq(2); + }); + }); + } } }); } diff --git a/test/integration/pool.test.js b/test/integration/pool.test.js index 98357e7cc679..76bf6a380000 100644 --- a/test/integration/pool.test.js +++ b/test/integration/pool.test.js @@ -14,6 +14,10 @@ function assertSameConnection(newConnection, oldConnection) { expect(oldConnection.processID).to.be.equal(newConnection.processID).and.to.be.ok; break; + case 'oracle': + expect(oldConnection).to.be.equal(newConnection); + break; + case 'mariadb': case 'mysql': expect(oldConnection.threadId).to.be.equal(newConnection.threadId).and.to.be.ok; @@ -48,6 +52,10 @@ function assertNewConnection(newConnection, oldConnection) { expect(oldConnection.connected).to.not.be.ok; break; + case 'oracle': + expect(oldConnection).to.not.be.equal(newConnection); + break; + case 'mssql': // Flaky test expect(newConnection.dummyId).to.not.be.ok; @@ -110,7 +118,7 @@ describe(Support.getTestDialectTeaser('Pooling'), () => { }); it('should obtain new connection when released connection dies inside pool', async () => { - function simulateUnexpectedError(connection) { + async function simulateUnexpectedError(connection) { // should never be returned again if (dialect === 'mssql') { attachMSSQLUniqueId(connection).close(); @@ -118,6 +126,9 @@ describe(Support.getTestDialectTeaser('Pooling'), () => { connection.end(); } else if (dialect === 'db2') { connection.closeSync(); + } else if (dialect === 'oracle') { + // For the Oracle dialect close is an async function + await connection.close(); } else { connection.close(); } @@ -131,7 +142,7 @@ describe(Support.getTestDialectTeaser('Pooling'), () => { const oldConnection = await cm.getConnection(); await cm.releaseConnection(oldConnection); - simulateUnexpectedError(oldConnection); + await simulateUnexpectedError(oldConnection); const newConnection = await cm.getConnection(); assertNewConnection(newConnection, oldConnection); diff --git a/test/integration/query-interface.test.js b/test/integration/query-interface.test.js index d514d192a65a..1bb6ab319e98 100644 --- a/test/integration/query-interface.test.js +++ b/test/integration/query-interface.test.js @@ -38,13 +38,25 @@ describe(Support.getTestDialectTeaser('QueryInterface'), () => { async function cleanup(sequelize) { if (dialect === 'db2') { await sequelize.query('DROP VIEW V_Fail'); + } else if (dialect === 'oracle') { + const plsql = [ + 'BEGIN', + 'EXECUTE IMMEDIATE', + '\'DROP VIEW V_Fail\';', + 'EXCEPTION WHEN OTHERS THEN', + ' IF SQLCODE != -942 THEN', + ' RAISE;', + ' END IF;', + 'END;' + ].join(' '); + await sequelize.query(plsql); } else { await sequelize.query('DROP VIEW IF EXISTS V_Fail'); } } await this.queryInterface.createTable('my_test_table', { name: DataTypes.STRING }); await cleanup(this.sequelize); - const sql = dialect === 'db2' ? 'CREATE VIEW V_Fail AS SELECT 1 Id FROM SYSIBM.SYSDUMMY1' : 'CREATE VIEW V_Fail AS SELECT 1 Id'; + const sql = dialect === 'db2' ? 'CREATE VIEW V_Fail AS SELECT 1 Id FROM SYSIBM.SYSDUMMY1' : `CREATE VIEW V_Fail AS SELECT 1 Id${ Support.addDualInSelect()}`; await this.sequelize.query(sql); let tableNames = await this.queryInterface.showAllTables(); await cleanup(this.sequelize); @@ -54,7 +66,7 @@ describe(Support.getTestDialectTeaser('QueryInterface'), () => { expect(tableNames).to.deep.equal(['my_test_table']); }); - if (dialect !== 'sqlite' && dialect !== 'postgres' && dialect !== 'db2') { + if (!['sqlite', 'postgres', 'db2', 'oracle'].includes(dialect)) { // NOTE: sqlite doesn't allow querying between databases and // postgres requires creating a new connection to create a new table. it('should not show tables in other databases', async function() { @@ -101,7 +113,7 @@ describe(Support.getTestDialectTeaser('QueryInterface'), () => { }); await this.queryInterface.renameTable('my_test_table', 'my_test_table_new'); let tableNames = await this.queryInterface.showAllTables(); - if (['mssql', 'mariadb', 'db2'].includes(dialect)) { + if (['mssql', 'mariadb', 'db2', 'oracle'].includes(dialect)) { tableNames = tableNames.map(v => v.tableName); } expect(tableNames).to.contain('my_test_table_new'); @@ -143,7 +155,7 @@ describe(Support.getTestDialectTeaser('QueryInterface'), () => { }); await this.queryInterface.dropAllTables({ skip: ['skipme'] }); let tableNames = await this.queryInterface.showAllTables(); - if (['mssql', 'mariadb', 'db2'].includes(dialect)) { + if (['mssql', 'mariadb', 'db2', 'oracle'].includes(dialect)) { tableNames = tableNames.map(v => v.tableName); } expect(tableNames).to.contain('skipme'); @@ -463,6 +475,8 @@ describe(Support.getTestDialectTeaser('QueryInterface'), () => { expect(Object.keys(foreignKeys[0])).to.have.length(8); } else if (['mysql', 'mariadb', 'mssql'].includes(dialect)) { expect(Object.keys(foreignKeys[0])).to.have.length(12); + } else if (dialect === 'oracle') { + expect(Object.keys(foreignKeys[0])).to.have.length(6); } else { throw new Error(`This test doesn't support ${dialect}`); } @@ -631,7 +645,7 @@ describe(Support.getTestDialectTeaser('QueryInterface'), () => { field: 'username' }, onDelete: 'cascade', - onUpdate: 'cascade', + onUpdate: dialect !== 'oracle' ? 'cascade' : null, type: 'foreign key' }); let constraints = await this.queryInterface.showConstraint('posts'); @@ -653,8 +667,11 @@ describe(Support.getTestDialectTeaser('QueryInterface'), () => { throw new Error('Error not thrown...'); } catch (error) { expect(error).to.be.instanceOf(Sequelize.UnknownConstraintError); - expect(error.table).to.equal('users'); - expect(error.constraint).to.equal('unknown__constraint__name'); + // The Oracle dialect, error messages doesn't have table and constraint information + if (dialect != 'oracle') { + expect(error.table).to.equal('users'); + expect(error.constraint).to.equal('unknown__constraint__name'); + } } }); }); diff --git a/test/integration/query-interface/changeColumn.test.js b/test/integration/query-interface/changeColumn.test.js index a1e2501d9370..41ec3edd609f 100644 --- a/test/integration/query-interface/changeColumn.test.js +++ b/test/integration/query-interface/changeColumn.test.js @@ -48,6 +48,8 @@ describe(Support.getTestDialectTeaser('QueryInterface'), () => { expect(table.currency.type).to.equal('DOUBLE PRECISION'); } else if (dialect === 'db2') { expect(table.currency.type).to.equal('DOUBLE'); + } else if (dialect === 'oracle') { + expect(table.currency.type).to.equal('BINARY_FLOAT'); } else { expect(table.currency.type).to.equal('FLOAT'); } @@ -82,6 +84,8 @@ describe(Support.getTestDialectTeaser('QueryInterface'), () => { expect(table.currency.type).to.equal('DOUBLE PRECISION'); } else if (dialect === 'db2') { expect(table.currency.type).to.equal('DOUBLE'); + } else if (dialect === 'oracle') { + expect(table.currency.type).to.equal('BINARY_FLOAT'); } else { expect(table.currency.type).to.equal('FLOAT'); } @@ -223,7 +227,8 @@ describe(Support.getTestDialectTeaser('QueryInterface'), () => { expect(describedTable.level_id.allowNull).to.not.equal(firstTable.level_id.allowNull); expect(describedTable.level_id.allowNull).to.be.equal(true); }); - if (dialect !== 'db2') { + // For Oracle, comments are not part of table description and are stored differently. + if (!['db2', 'oracle'].includes(dialect)) { it('should change the comment of column', async function() { const describedTable = await this.queryInterface.describeTable({ tableName: 'users' diff --git a/test/integration/query-interface/createTable.test.js b/test/integration/query-interface/createTable.test.js index b8dd42e19bd6..b9133e2ebe45 100644 --- a/test/integration/query-interface/createTable.test.js +++ b/test/integration/query-interface/createTable.test.js @@ -77,7 +77,8 @@ describe(Support.getTestDialectTeaser('QueryInterface'), () => { break; case 'mariadb': case 'mysql': - case 'db2': + case 'db2': + case 'oracle': // name + email expect(indexes[1].unique).to.be.true; expect(indexes[1].fields[0].attribute).to.equal('name'); diff --git a/test/integration/query-interface/describeTable.test.js b/test/integration/query-interface/describeTable.test.js index 796ce1e10eaa..5c6652784148 100644 --- a/test/integration/query-interface/describeTable.test.js +++ b/test/integration/query-interface/describeTable.test.js @@ -73,6 +73,9 @@ describe(Support.getTestDialectTeaser('QueryInterface'), () => { let assertVal = 'VARCHAR(255)'; switch (dialect) { + case 'oracle': + assertVal = 'NVARCHAR2'; + break; case 'postgres': assertVal = 'CHARACTER VARYING(255)'; break; @@ -87,6 +90,7 @@ describe(Support.getTestDialectTeaser('QueryInterface'), () => { expect(username.allowNull).to.be.true; switch (dialect) { + case 'oracle': case 'sqlite': expect(username.defaultValue).to.be.undefined; break; @@ -102,6 +106,9 @@ describe(Support.getTestDialectTeaser('QueryInterface'), () => { assertVal = 'TINYINT(1)'; switch (dialect) { + case 'oracle': + assertVal = 'CHAR'; + break; case 'postgres': case 'db2': assertVal = 'BOOLEAN'; @@ -113,6 +120,7 @@ describe(Support.getTestDialectTeaser('QueryInterface'), () => { expect(isAdmin.type).to.equal(assertVal); expect(isAdmin.allowNull).to.be.true; switch (dialect) { + case 'oracle': case 'sqlite': expect(isAdmin.defaultValue).to.be.undefined; break; @@ -166,5 +174,16 @@ describe(Support.getTestDialectTeaser('QueryInterface'), () => { expect(metalumni.ctrycod.primaryKey).to.eql(false); expect(metalumni.city.primaryKey).to.eql(false); }); + + it('should correctly return the columns when the table contains a dot in the name', async function() { + const User = this.sequelize.define('my.user', { + name: DataTypes.STRING + }, { freezeTableName: true }); + + await User.sync({ force: true }); + const metadata = await this.queryInterface.describeTable('my.user'); + + expect(metadata).to.haveOwnProperty('name'); + }); }); }); diff --git a/test/integration/sequelize.test.js b/test/integration/sequelize.test.js index 59361493ecd6..b6c91120d292 100644 --- a/test/integration/sequelize.test.js +++ b/test/integration/sequelize.test.js @@ -12,7 +12,7 @@ const sinon = require('sinon'); const current = Support.sequelize; const qq = str => { - if (['postgres', 'mssql', 'db2'].includes(dialect)) { + if (['postgres', 'mssql', 'db2', 'oracle'].includes(dialect)) { return `"${str}"`; } if (['mysql', 'mariadb', 'sqlite'].includes(dialect)) { @@ -123,13 +123,14 @@ describe(Support.getTestDialectTeaser('Sequelize'), () => { .sequelizeWithInvalidConnection .authenticate(); } catch (err) { - console.log(err); expect( err.message.includes('connect ECONNREFUSED') || err.message.includes('invalid port number') || err.message.match(/should be >=? 0 and < 65536/) || err.message.includes('Login failed for user') || err.message.includes('A communication error has been detected') || + err.message.includes('ORA-12545') || + err.message.includes('ORA-12541') || err.message.includes('must be > 0 and < 65536') ).to.be.ok; } @@ -229,6 +230,17 @@ describe(Support.getTestDialectTeaser('Sequelize'), () => { }); }); + describe('modelManager', () => { + it('allows to find a model using a callback', function() { + const project = this.sequelize.define('Project', { + name: DataTypes.STRING + }); + + const model = this.sequelize.modelManager.findModel(m => m.name.toLowerCase() === 'project'); + expect(model).to.equal(project); + }); + }); + describe('set', () => { it('should be configurable with global functions', function() { const defaultSetterMethod = sinon.spy(), @@ -362,7 +374,7 @@ describe(Support.getTestDialectTeaser('Sequelize'), () => { const Photo = this.sequelize.define('Foto', { name: DataTypes.STRING }, { tableName: 'photos' }); await Photo.sync({ force: true }); let tableNames = await this.sequelize.getQueryInterface().showAllTables(); - if (['mssql', 'mariadb', 'db2'].includes(dialect)) { + if (['mssql', 'mariadb', 'db2', 'oracle'].includes(dialect)) { tableNames = tableNames.map(v => v.tableName); } expect(tableNames).to.include('photos'); @@ -452,6 +464,8 @@ describe(Support.getTestDialectTeaser('Sequelize'), () => { expect(err.message).to.equal('Login failed for user \'bar\'.'); } else if (dialect === 'db2') { expect(err.message).to.include('A communication error has been detected'); + } else if (dialect === 'oracle') { + expect(err.message).to.include('NJS-007'); } else { expect(err.message.toString()).to.match(/.*Access denied.*/); } @@ -721,7 +735,7 @@ describe(Support.getTestDialectTeaser('Sequelize'), () => { const TransactionTest = this.sequelizeWithTransaction.define('TransactionTest', { name: DataTypes.STRING }, { timestamps: false }); const count = async transaction => { - const sql = this.sequelizeWithTransaction.getQueryInterface().queryGenerator.selectQuery('TransactionTests', { attributes: [['count(*)', 'cnt']] }); + const sql = this.sequelizeWithTransaction.getQueryInterface().queryGenerator.selectQuery('TransactionTests', { attributes: [[Sequelize.literal('count(*)'), 'cnt']] }); const result = await this.sequelizeWithTransaction.query(sql, { plain: true, transaction }); @@ -744,7 +758,7 @@ describe(Support.getTestDialectTeaser('Sequelize'), () => { const aliasesMapping = new Map([['_0', 'cnt']]); const count = async transaction => { - const sql = this.sequelizeWithTransaction.getQueryInterface().queryGenerator.selectQuery('TransactionTests', { attributes: [['count(*)', 'cnt']] }); + const sql = this.sequelizeWithTransaction.getQueryInterface().queryGenerator.selectQuery('TransactionTests', { attributes: [[Sequelize.literal('count(*)'), 'cnt']] }); const result = await this.sequelizeWithTransaction.query(sql, { plain: true, transaction, aliasesMapping }); diff --git a/test/integration/sequelize.transaction.test.js b/test/integration/sequelize.transaction.test.js index 22d2f03ba72a..f6fef21a3a48 100644 --- a/test/integration/sequelize.transaction.test.js +++ b/test/integration/sequelize.transaction.test.js @@ -1,5 +1,6 @@ 'use strict'; +const sinon = require('sinon'); const chai = require('chai'), expect = chai.expect, Support = require('./support'), @@ -7,135 +8,177 @@ const chai = require('chai'), current = Support.sequelize, delay = require('delay'); -if (current.dialect.supports.transactions) { +const sequelize = Support.sequelize; +const dialectName = sequelize.dialect.name; - describe(Support.getTestDialectTeaser('Sequelize#transaction'), () => { +describe(Support.getTestDialectTeaser('Sequelize#transaction'), () => { + if (!current.dialect.supports.transactions) { + return; + } - describe('then', () => { - it('gets triggered once a transaction has been successfully committed', async function() { - let called = false; + let stubs = []; + + afterEach(() => { + for (const stub of stubs) { + stub.restore(); + } + + stubs = []; + }); + + describe('Transaction#commit', () => { + it('returns a promise that resolves once the transaction has been committed', async function() { + const t = await this + .sequelize + .transaction(); + + await expect(t.commit()).to.eventually.equal(undefined); + }); + + // we cannot close a sqlite connection, but there also cannot be a network error with sqlite. + // so this test is not necessary for that dialect. + if (dialectName !== 'sqlite') { + it('does not pollute the pool with broken connections if commit fails', async function() { + const initialPoolSize = this.sequelize.connectionManager.pool.size; + + stubs.push(sinon.stub(this.sequelize.queryInterface, 'commitTransaction').rejects(new Error('Oh no, an error!'))); const t = await this .sequelize .transaction(); - await t.commit(); - called = 1; - expect(called).to.be.ok; + await expect(t.commit()).to.be.rejectedWith('Oh no, an error!'); + + // connection should have been destroyed + expect(this.sequelize.connectionManager.pool.size).to.eq(Math.max(0, initialPoolSize - 1)); }); + } + }); + + describe('Transaction#rollback', () => { + it('returns a promise that resolves once the transaction has been rolled back', async function() { + const t = await this + .sequelize + .transaction(); + + expect(t.rollback()).to.eventually.equal(undefined); + }); + + // we cannot close a sqlite connection, but there also cannot be a network error with sqlite. + // so this test is not necessary for that dialect. + if (dialectName !== 'sqlite') { + it('does not pollute the pool with broken connections if the rollback fails', async function() { + const initialPoolSize = this.sequelize.connectionManager.pool.size; - it('gets triggered once a transaction has been successfully rolled back', async function() { - let called = false; + stubs.push(sinon.stub(this.sequelize.queryInterface, 'rollbackTransaction').rejects(new Error('Oh no, an error!'))); const t = await this .sequelize .transaction(); - await t.rollback(); - called = 1; - expect(called).to.be.ok; - }); + await expect(t.rollback()).to.be.rejectedWith('Oh no, an error!'); - if (Support.getTestDialect() !== 'sqlite' && - Support.getTestDialect() !== 'db2') { - it('works for long running transactions', async function() { - const sequelize = await Support.prepareTransactionTest(this.sequelize); - this.sequelize = sequelize; - - this.User = sequelize.define('User', { - name: Support.Sequelize.STRING - }, { timestamps: false }); - - await sequelize.sync({ force: true }); - const t = await this.sequelize.transaction(); - let query = 'select sleep(2);'; - - switch (Support.getTestDialect()) { - case 'postgres': - query = 'select pg_sleep(2);'; - break; - case 'sqlite': - query = 'select sqlite3_sleep(2000);'; - break; - case 'mssql': - query = 'WAITFOR DELAY \'00:00:02\';'; - break; - default: - break; - } + // connection should have been destroyed + expect(this.sequelize.connectionManager.pool.size).to.eq(Math.max(0, initialPoolSize - 1)); + }); + } + }); - await this.sequelize.query(query, { transaction: t }); - await this.User.create({ name: 'foo' }); - await this.sequelize.query(query, { transaction: t }); - await t.commit(); - const users = await this.User.findAll(); - expect(users.length).to.equal(1); - expect(users[0].name).to.equal('foo'); - }); + if (Support.getTestDialect() !== 'sqlite' && Support.getTestDialect() !== 'db2') { + it('works for long running transactions', async function() { + const sequelize = await Support.prepareTransactionTest(this.sequelize); + this.sequelize = sequelize; + + this.User = sequelize.define('User', { + name: Support.Sequelize.STRING + }, { timestamps: false }); + + await sequelize.sync({ force: true }); + const t = await this.sequelize.transaction(); + let query = 'select sleep(2);'; + + switch (Support.getTestDialect()) { + case 'postgres': + query = 'select pg_sleep(2);'; + break; + case 'sqlite': + query = 'select sqlite3_sleep(2000);'; + break; + case 'mssql': + query = 'WAITFOR DELAY \'00:00:02\';'; + break; + case 'oracle': + query = 'BEGIN DBMS_SESSION.sleep(2); END;'; + break; + default: + break; } + + await this.sequelize.query(query, { transaction: t }); + await this.User.create({ name: 'foo' }); + await this.sequelize.query(query, { transaction: t }); + await t.commit(); + const users = await this.User.findAll(); + expect(users.length).to.equal(1); + expect(users[0].name).to.equal('foo'); }); + } + + describe('complex long running example', () => { + it('works with promise syntax', async function() { + const sequelize = await Support.prepareTransactionTest(this.sequelize); + const Test = sequelize.define('Test', { + id: { type: Support.Sequelize.INTEGER, primaryKey: true, autoIncrement: true }, + name: { type: Support.Sequelize.STRING } + }); - describe('complex long running example', () => { - it('works with promise syntax', async function() { - const sequelize = await Support.prepareTransactionTest(this.sequelize); - const Test = sequelize.define('Test', { - id: { type: Support.Sequelize.INTEGER, primaryKey: true, autoIncrement: true }, - name: { type: Support.Sequelize.STRING } - }); + await sequelize.sync({ force: true }); + const transaction = await sequelize.transaction(); + expect(transaction).to.be.instanceOf(Transaction); - await sequelize.sync({ force: true }); - const transaction = await sequelize.transaction(); - expect(transaction).to.be.instanceOf(Transaction); + await Test.create({ name: 'Peter' }, { transaction }); - await Test - .create({ name: 'Peter' }, { transaction }); + await delay(1000); - await delay(1000); + await transaction.commit(); - await transaction - .commit(); + const count = await Test.count(); + expect(count).to.equal(1); + }); + }); + + describe('concurrency: having tables with uniqueness constraints', () => { + beforeEach(async function() { + const sequelize = await Support.prepareTransactionTest(this.sequelize); + this.sequelize = sequelize; - const count = await Test.count(); - expect(count).to.equal(1); + this.Model = sequelize.define('Model', { + name: { type: Support.Sequelize.STRING, unique: true } + }, { + timestamps: false }); + + await this.Model.sync({ force: true }); }); - describe('concurrency', () => { - describe('having tables with uniqueness constraints', () => { - beforeEach(async function() { - const sequelize = await Support.prepareTransactionTest(this.sequelize); - this.sequelize = sequelize; - - this.Model = sequelize.define('Model', { - name: { type: Support.Sequelize.STRING, unique: true } - }, { - timestamps: false - }); - - await this.Model.sync({ force: true }); - }); - - it('triggers the error event for the second transactions', async function() { - const t1 = await this.sequelize.transaction(); - const t2 = await this.sequelize.transaction(); - await this.Model.create({ name: 'omnom' }, { transaction: t1 }); - - await Promise.all([ - (async () => { - try { - return await this.Model.create({ name: 'omnom' }, { transaction: t2 }); - } catch (err) { - expect(err).to.be.ok; - return t2.rollback(); - } - })(), - delay(100).then(() => { - return t1.commit(); - }) - ]); - }); - }); + it('triggers the error event for the second transactions', async function() { + const t1 = await this.sequelize.transaction(); + const t2 = await this.sequelize.transaction(); + await this.Model.create({ name: 'omnom' }, { transaction: t1 }); + + await Promise.all([ + (async () => { + try { + return await this.Model.create({ name: 'omnom' }, { transaction: t2 }); + } catch (err) { + expect(err).to.be.ok; + return t2.rollback(); + } + })(), + delay(100).then(() => { + return t1.commit(); + }) + ]); }); }); - -} +}); diff --git a/test/integration/sequelize/drop.test.js b/test/integration/sequelize/drop.test.js new file mode 100644 index 000000000000..0d88f96a16d7 --- /dev/null +++ b/test/integration/sequelize/drop.test.js @@ -0,0 +1,86 @@ +'use strict'; + +const { Deferrable, DataTypes } = require('sequelize'); +const { sequelize } = require('../support'); + +describe('Sequelize#drop', () => { + it('supports dropping cyclic associations', async () => { + const A = sequelize.define('A', { + BId: { + type: DataTypes.INTEGER, + references: { + deferrable: Deferrable.INITIALLY_IMMEDIATE + } + } + }); + + const B = sequelize.define('B', { + AId: { + type: DataTypes.INTEGER, + references: { + deferrable: Deferrable.INITIALLY_IMMEDIATE + } + } + }); + + // These models both have a foreign key that references the other model. + // Sequelize should be able to create them. + A.belongsTo(B, { foreignKey: { allowNull: false } }); + B.belongsTo(A, { foreignKey: { allowNull: false } }); + + await sequelize.sync(); + + // drop both tables + await sequelize.drop(); + }); + + describe('with schemas', () => { + beforeEach(async () => { + await Promise.all([ + sequelize.createSchema('schemaA'), + sequelize.createSchema('schemaB') + ]); + }); + + afterEach(async () => { + await Promise.all([ + sequelize.dropSchema('schemaA'), + sequelize.dropSchema('schemaB') + ]); + }); + + it('supports schemas when dropping foreign keys for a table', async () => { + sequelize.define('schemaA_A', {}, { + tableName: 'A', + schema: 'schemaA' + }); + + + // External tables, use sequelize interface to create them. + const schemaB_A = sequelize.define('schemaB_A', {}, { + tableName: 'A', + schema: 'schemaB' + }); + + const schemaB_B = sequelize.define('schemaB_B', { + BId: { + type: DataTypes.INTEGER + } + }, { + tableName: 'B', + schema: 'schemaB' + }); + + schemaB_A.belongsTo(schemaB_B, { foreignKey: { allowNull: false } }); + + await sequelize.sync(); + + // Assume "schemaB" models were not created by sequelize and already exist in the database. + sequelize.modelManager.removeModel(schemaB_A); + sequelize.modelManager.removeModel(schemaB_B); + + // Try to drop "schemaA" table. + await sequelize.drop(); + }); + }); +}); diff --git a/test/integration/sequelize/query.test.js b/test/integration/sequelize/query.test.js index aeaff34c8a67..f9f994cd57eb 100644 --- a/test/integration/sequelize/query.test.js +++ b/test/integration/sequelize/query.test.js @@ -10,7 +10,7 @@ const moment = require('moment'); const { DatabaseError, UniqueConstraintError, ForeignKeyConstraintError } = Support.Sequelize; const qq = str => { - if (['postgres', 'mssql', 'db2'].includes(dialect)) { + if (['postgres', 'mssql', 'db2', 'oracle'].includes(dialect)) { return `"${str}"`; } if (['mysql', 'mariadb', 'sqlite'].includes(dialect)) { @@ -19,6 +19,13 @@ const qq = str => { return str; }; +const dateLiteral = str => { + if (dialect === 'oracle') { + return `to_date('${str}','YYYY-MM-DD HH24:MI:SS')`; + } + return `'${str}'`; +}; + describe(Support.getTestDialectTeaser('Sequelize'), () => { describe('query', () => { afterEach(function() { @@ -38,9 +45,9 @@ describe(Support.getTestDialectTeaser('Sequelize'), () => { } }); - this.insertQuery = `INSERT INTO ${qq(this.User.tableName)} (username, email_address, ${ + this.insertQuery = `INSERT INTO ${qq(this.User.tableName)} (${qq('username')}, ${qq('email_address')}, ${ qq('createdAt') }, ${qq('updatedAt') - }) VALUES ('john', 'john@gmail.com', '2012-01-01 10:10:10', '2012-01-01 10:10:10')`; + }) VALUES ('john', 'john@gmail.com',${dateLiteral('2012-01-01 10:10:10')},${dateLiteral('2012-01-01 10:10:10')})`; if (dialect === 'db2') { this.insertQuery = `INSERT INTO ${qq(this.User.tableName)} ("username", "email_address", ${ qq('createdAt') }, ${qq('updatedAt')}) VALUES ('john', 'john@gmail.com', '2012-01-01 10:10:10', '2012-01-01 10:10:10')`; @@ -57,13 +64,29 @@ describe(Support.getTestDialectTeaser('Sequelize'), () => { }); it('executes a query if a placeholder value is an array', async function() { - await this.sequelize.query(`INSERT INTO ${qq(this.User.tableName)} (${qq('username')}, ${qq('email_address')}, ` + - `${qq('createdAt')}, ${qq('updatedAt')}) VALUES ?;`, { - replacements: [[ - ['john', 'john@gmail.com', '2012-01-01 10:10:10', '2012-01-01 10:10:10'], - ['michael', 'michael@gmail.com', '2012-01-01 10:10:10', '2012-01-01 10:10:10'] - ]] - }); + if (dialect === 'oracle') { + await this.sequelize.query( + 'INSERT ' + + `INTO ${qq(this.User.tableName)} (${qq('username')}, ${qq('email_address')}, ` + + `${qq('createdAt')}, ${qq('updatedAt')}) ` + + `with p (${qq('username')}, ${qq('email_address')}, ${qq('createdAt')}, ${qq('updatedAt')}) as ( ` + + 'select ? from dual union all ' + + 'select ? from dual ' + + ') select * from p; ', { + replacements: [ + ['john', 'john@gmail.com', new Date('2012-01-01 10:10:10'), new Date('2012-01-01 10:10:10')], + ['michael', 'michael@gmail.com', new Date('2012-01-01 10:10:10'), new Date('2012-01-01 10:10:10')] + ] + }); + } else { + await this.sequelize.query(`INSERT INTO ${qq(this.User.tableName)} (${qq('username')}, ${qq('email_address')}, ` + + `${qq('createdAt')}, ${qq('updatedAt')}) VALUES ?;`, { + replacements: [[ + ['john', 'john@gmail.com', '2012-01-01 10:10:10', '2012-01-01 10:10:10'], + ['michael', 'michael@gmail.com', '2012-01-01 10:10:10', '2012-01-01 10:10:10'] + ]] + }); + } const rows = await this.sequelize.query(`SELECT * FROM ${qq(this.User.tableName)};`, { type: this.sequelize.QueryTypes.SELECT @@ -93,8 +116,8 @@ describe(Support.getTestDialectTeaser('Sequelize'), () => { it('properly bind parameters on extra retries', async function() { const payload = { username: 'test', - createdAt: '2010-10-10 00:00:00', - updatedAt: '2010-10-10 00:00:00' + createdAt: dialect === 'oracle' ? new Date('2010-10-10 00:00:00') : '2010-10-10 00:00:00', + updatedAt: dialect === 'oracle' ? new Date('2010-10-10 00:00:00') : '2010-10-10 00:00:00' }; const spy = sinon.spy(); @@ -125,7 +148,7 @@ describe(Support.getTestDialectTeaser('Sequelize'), () => { benchmark: true }); - await sequelize.query('select 1;'); + await sequelize.query(`select 1${Support.addDualInSelect()};`); expect(logger.calledOnce).to.be.true; expect(logger.args[0][0]).to.be.match(/Executed \((\d*|default)\): select 1/); expect(typeof logger.args[0][1] === 'number').to.be.true; @@ -134,7 +157,7 @@ describe(Support.getTestDialectTeaser('Sequelize'), () => { it('executes a query with benchmarking option and custom logger', async function() { const logger = sinon.spy(); - await this.sequelize.query('select 1;', { + await this.sequelize.query(`select 1${Support.addDualInSelect()};`, { logging: logger, benchmark: true }); @@ -199,7 +222,7 @@ describe(Support.getTestDialectTeaser('Sequelize'), () => { if (dialect === 'db2') { typeCast = '::VARCHAR'; } - await this.sequelize.query(`select $1${typeCast} as foo, $2${typeCast} as bar`, { bind: ['foo', 'bar'], logging: s=>logSql = s }); + await this.sequelize.query(`select $1${typeCast} as foo, $2${typeCast} as bar${Support.addDualInSelect()}`, { bind: ['foo', 'bar'], logging: s=>logSql = s }); expect(logSql).to.match(/; ("foo", "bar"|{"(\$1|0)":"foo","(\$2|1)":"bar"})/); }); }); @@ -342,6 +365,17 @@ describe(Support.getTestDialectTeaser('Sequelize'), () => { await this.UserVisit.sync({ force: true }); }); + it('emits raw errors if requested', async function() { + const sql = 'SELECT 1 FROM NotFoundTable'; + + await expect(this.sequelize.query(sql, { rawErrors: false })) + .to.eventually.be.rejectedWith(DatabaseError); + + await expect(this.sequelize.query(sql, { rawErrors: true })) + .to.eventually.be.rejected + .and.not.be.an.instanceOf(DatabaseError); + }); + it('emits full stacktraces for generic database error', async function() { let error = null; try { @@ -361,7 +395,7 @@ describe(Support.getTestDialectTeaser('Sequelize'), () => { const query = `INSERT INTO ${qq(this.User.tableName)} (username, email_address, ${ qq('createdAt') }, ${qq('updatedAt') }) VALUES ('duplicate', 'duplicate@gmail.com', '2012-01-01 10:10:10', '2012-01-01 10:10:10')`; - if (dialect === 'db2') { + if (['db2', 'oracle'].includes(dialect)) { this.query = `INSERT INTO ${qq(this.User.tableName)} ("username", "email_address", ${ qq('createdAt') }, ${qq('updatedAt') }) VALUES ('duplicate', 'duplicate@gmail.com', '2012-01-01 10:10:10', '2012-01-01 10:10:10')`; @@ -375,7 +409,7 @@ describe(Support.getTestDialectTeaser('Sequelize'), () => { } catch (err) { error = err; } - if (dialect === 'db2') { + if (['db2', 'oracle'].includes(dialect)) { expect(error).to.be.instanceOf(DatabaseError); } else { expect(error).to.be.instanceOf(UniqueConstraintError); @@ -392,7 +426,7 @@ describe(Support.getTestDialectTeaser('Sequelize'), () => { )}, ${qq( 'updatedAt' )}) VALUES (123456789, '2012-01-01 10:10:10', '2012-01-01 10:10:10', '2012-01-01 10:10:10')`; - if (dialect === 'db2') { + if (['db2', 'oracle'].includes(dialect)) { this.query = `INSERT INTO ${qq(this.UserVisit.tableName)} ("user_id", "visited_at", ${qq( 'createdAt' )}, ${qq( @@ -403,7 +437,7 @@ describe(Support.getTestDialectTeaser('Sequelize'), () => { } catch (err) { error = err; } - if (dialect === 'db2') { + if (['db2', 'oracle'].includes(dialect)) { expect(error).to.be.instanceOf(DatabaseError); } else { expect(error).to.be.instanceOf(ForeignKeyConstraintError); @@ -446,27 +480,27 @@ describe(Support.getTestDialectTeaser('Sequelize'), () => { it('reject when key is missing in the passed object', async function() { await this.sequelize.query('select :one as foo, :two as bar, :three as baz', { raw: true, replacements: { one: 1, two: 2 } }) - .should.be.rejectedWith(Error, /Named parameter ":\w+" has no value in the given object\./g); + .should.be.rejectedWith(Error, 'Named replacement ":three" has no entry in the replacement map.'); }); it('reject with the passed number', async function() { await this.sequelize.query('select :one as foo, :two as bar', { raw: true, replacements: 2 }) - .should.be.rejectedWith(Error, /Named parameter ":\w+" has no value in the given object\./g); + .should.be.rejectedWith(Error, '"replacements" must be an array or a plain object, but received 2 instead.'); }); it('reject with the passed empty object', async function() { await this.sequelize.query('select :one as foo, :two as bar', { raw: true, replacements: {} }) - .should.be.rejectedWith(Error, /Named parameter ":\w+" has no value in the given object\./g); + .should.be.rejectedWith(Error, 'Named replacement ":one" has no entry in the replacement map.'); }); it('reject with the passed string', async function() { await this.sequelize.query('select :one as foo, :two as bar', { raw: true, replacements: 'foobar' }) - .should.be.rejectedWith(Error, /Named parameter ":\w+" has no value in the given object\./g); + .should.be.rejectedWith(Error, '"replacements" must be an array or a plain object, but received "foobar" instead.'); }); it('reject with the passed date', async function() { - await this.sequelize.query('select :one as foo, :two as bar', { raw: true, replacements: new Date() }) - .should.be.rejectedWith(Error, /Named parameter ":\w+" has no value in the given object\./g); + await this.sequelize.query('select :one as foo, :two as bar', { raw: true, replacements: new Buffer([1]) }) + .should.be.rejectedWith(Error, '"replacements" must be an array or a plain object, but received {"type":"Buffer","data":[1]} instead.'); }); it('reject when binds passed with object and numeric $1 is also present', async function() { @@ -534,8 +568,8 @@ describe(Support.getTestDialectTeaser('Sequelize'), () => { date.setMilliseconds(0); let sql = 'select ? as number, ? as date,? as string,? as boolean,? as buffer'; - if (dialect === 'db2') { - sql = 'select ? as "number", ? as "date",? as "string",? as "boolean",? as "buffer"'; + if (['db2', 'oracle'].includes(dialect)) { + sql = `select ? as "number", ? as "date",? as "string",? as "boolean",? as "buffer"${ Support.addDualInSelect()}`; } const result = await this.sequelize.query({ query: sql, @@ -550,7 +584,11 @@ describe(Support.getTestDialectTeaser('Sequelize'), () => { const res = result[0] || {}; res.date = res.date && new Date(res.date); res.boolean = res.boolean && true; - if (typeof res.buffer === 'string' && res.buffer.startsWith('\\x')) { + + // For Oracle dialect BLOB data doesn't begin with \\x hence we need to convert whole buffer to hex type + if (typeof res.buffer === 'string' && dialect === 'oracle') { + res.buffer = Buffer.from(res.buffer, 'hex'); + } else if (typeof res.buffer === 'string' && res.buffer.startsWith('\\x')) { res.buffer = Buffer.from(res.buffer.substring(2), 'hex'); } expect(res).to.deep.equal({ @@ -570,8 +608,8 @@ describe(Support.getTestDialectTeaser('Sequelize'), () => { this.values = [1, 2]; } get query() { - if (dialect === 'db2') { - return 'select ? as "foo", ? as "bar"'; + if (['db2', 'oracle'].includes(dialect)) { + return `select ? as "foo", ? as "bar"${ Support.addDualInSelect()}`; } return 'select ? as foo, ? as bar'; } @@ -581,10 +619,10 @@ describe(Support.getTestDialectTeaser('Sequelize'), () => { expect(logSql).to.not.include('?'); }); - const expected = dialect === 'db2' ? [{ FOO: 1, BAR: 2 }] : [{ foo: 1, bar: 2 }]; + const expected = ['db2', 'oracle'].includes(dialect) ? [{ FOO: 1, BAR: 2 }] : [{ foo: 1, bar: 2 }]; it('uses properties `query` and `values` if query is tagged', async function() { let logSql; - const result = await this.sequelize.query({ query: 'select ? as foo, ? as bar', values: [1, 2] }, { type: this.sequelize.QueryTypes.SELECT, logging(s) { logSql = s; } }); + const result = await this.sequelize.query({ query: `select ? as foo, ? as bar${ Support.addDualInSelect()}`, values: [1, 2] }, { type: this.sequelize.QueryTypes.SELECT, logging(s) { logSql = s; } }); expect(result).to.deep.equal(expected); expect(logSql).to.not.include('?'); }); @@ -592,7 +630,7 @@ describe(Support.getTestDialectTeaser('Sequelize'), () => { it('uses properties `query` and `bind` if query is tagged', async function() { const typeCast = dialect === 'postgres' || dialect === 'db2' ? '::int' : ''; let logSql; - const result = await this.sequelize.query({ query: `select $1${typeCast} as foo, $2${typeCast} as bar`, bind: [1, 2] }, { type: this.sequelize.QueryTypes.SELECT, logging(s) { logSql = s; } }); + const result = await this.sequelize.query({ query: `select $1${typeCast} as foo, $2${typeCast} as bar${Support.addDualInSelect()}`, bind: [1, 2] }, { type: this.sequelize.QueryTypes.SELECT, logging(s) { logSql = s; } }); expect(result).to.deep.equal(expected); if (['postgres', 'sqlite'].includes(dialect)) { expect(logSql).to.include('$1'); @@ -606,52 +644,52 @@ describe(Support.getTestDialectTeaser('Sequelize'), () => { }); it('dot separated attributes when doing a raw query without nest', async function() { - const tickChar = ['postgres', 'mssql', 'db2'].includes(dialect) ? '"' : '`', - sql = `select 1 as ${Sequelize.Utils.addTicks('foo.bar.baz', tickChar)}`; + const tickChar = ['postgres', 'mssql', 'db2', 'oracle'].includes(dialect) ? '"' : '`', + sql = `select 1 as ${Sequelize.Utils.addTicks('foo.bar.baz', tickChar)}${Support.addDualInSelect()}`; await expect(this.sequelize.query(sql, { raw: true, nest: false }).then(obj => obj[0])).to.eventually.deep.equal([{ 'foo.bar.baz': 1 }]); }); it('destructs dot separated attributes when doing a raw query using nest', async function() { - const tickChar = ['postgres', 'mssql', 'db2'].includes(dialect) ? '"' : '`', - sql = `select 1 as ${Sequelize.Utils.addTicks('foo.bar.baz', tickChar)}`; + const tickChar = ['postgres', 'mssql', 'db2', 'oracle'].includes(dialect) ? '"' : '`', + sql = `select 1 as ${Sequelize.Utils.addTicks('foo.bar.baz', tickChar)}${Support.addDualInSelect()}`; const result = await this.sequelize.query(sql, { raw: true, nest: true }); expect(result).to.deep.equal([{ foo: { bar: { baz: 1 } } }]); }); it('replaces token with the passed array', async function() { - const result = await this.sequelize.query('select ? as foo, ? as bar', { type: this.sequelize.QueryTypes.SELECT, replacements: [1, 2] }); + const result = await this.sequelize.query(`select ? as foo, ? as bar${ Support.addDualInSelect()}`, { type: this.sequelize.QueryTypes.SELECT, replacements: [1, 2] }); expect(result).to.deep.equal(expected); }); it('replaces named parameters with the passed object', async function() { - await expect(this.sequelize.query('select :one as foo, :two as bar', { raw: true, replacements: { one: 1, two: 2 } }).then(obj => obj[0])) + await expect(this.sequelize.query(`select :one as foo, :two as bar${ Support.addDualInSelect()}`, { raw: true, replacements: { one: 1, two: 2 } }).then(obj => obj[0])) .to.eventually.deep.equal(expected); }); it('replaces named parameters with the passed object and ignore those which does not qualify', async function() { - const expected = dialect === 'db2' ? [{ FOO: 1, BAR: 2, BAZ: '00:00' }] : [{ foo: 1, bar: 2, baz: '00:00' }]; - await expect(this.sequelize.query('select :one as foo, :two as bar, \'00:00\' as baz', { raw: true, replacements: { one: 1, two: 2 } }).then(obj => obj[0])) + const expected = ['db2', 'oracle'].includes(dialect) ? [{ FOO: 1, BAR: 2, BAZ: '00:00' }] : [{ foo: 1, bar: 2, baz: '00:00' }]; + await expect(this.sequelize.query(`select :one as foo, :two as bar, '00:00' as baz${ Support.addDualInSelect()}`, { raw: true, replacements: { one: 1, two: 2 } }).then(obj => obj[0])) .to.eventually.deep.equal(expected); }); it('replaces named parameters with the passed object using the same key twice', async function() { - const expected = dialect === 'db2' ? [{ FOO: 1, BAR: 2, BAZ: 1 }] : [{ foo: 1, bar: 2, baz: 1 }]; - await expect(this.sequelize.query('select :one as foo, :two as bar, :one as baz', { raw: true, replacements: { one: 1, two: 2 } }).then(obj => obj[0])) + const expected = ['db2', 'oracle'].includes(dialect) ? [{ FOO: 1, BAR: 2, BAZ: 1 }] : [{ foo: 1, bar: 2, baz: 1 }]; + await expect(this.sequelize.query(`select :one as foo, :two as bar, :one as baz${ Support.addDualInSelect()}`, { raw: true, replacements: { one: 1, two: 2 } }).then(obj => obj[0])) .to.eventually.deep.equal(expected); }); it('replaces named parameters with the passed object having a null property', async function() { - const expected = dialect === 'db2' ? [{ FOO: 1, BAR: null }] : [{ foo: 1, bar: null }]; - await expect(this.sequelize.query('select :one as foo, :two as bar', { raw: true, replacements: { one: 1, two: null } }).then(obj => obj[0])) + const expected = ['db2', 'oracle'].includes(dialect) ? [{ FOO: 1, BAR: null }] : [{ foo: 1, bar: null }]; + await expect(this.sequelize.query(`select :one as foo, :two as bar${ Support.addDualInSelect()}`, { raw: true, replacements: { one: 1, two: null } }).then(obj => obj[0])) .to.eventually.deep.equal(expected); }); it('binds token with the passed array', async function() { const typeCast = dialect === 'postgres' || dialect === 'db2' ? '::int' : ''; let logSql; - const result = await this.sequelize.query(`select $1${typeCast} as foo, $2${typeCast} as bar`, { type: this.sequelize.QueryTypes.SELECT, bind: [1, 2], logging(s) { logSql = s;} }); + const result = await this.sequelize.query(`select $1${typeCast} as foo, $2${typeCast} as bar${Support.addDualInSelect()}`, { type: this.sequelize.QueryTypes.SELECT, bind: [1, 2], logging(s) { logSql = s;} }); expect(result).to.deep.equal(expected); if (['postgres', 'sqlite'].includes(dialect)) { expect(logSql).to.include('$1'); @@ -661,7 +699,7 @@ describe(Support.getTestDialectTeaser('Sequelize'), () => { it('binds named parameters with the passed object', async function() { const typeCast = dialect === 'postgres' || dialect === 'db2' ? '::int' : ''; let logSql; - const result = await this.sequelize.query(`select $one${typeCast} as foo, $two${typeCast} as bar`, { raw: true, bind: { one: 1, two: 2 }, logging(s) { logSql = s; } }); + const result = await this.sequelize.query(`select $one${typeCast} as foo, $two${typeCast} as bar${Support.addDualInSelect()}`, { raw: true, bind: { one: 1, two: 2 }, logging(s) { logSql = s; } }); expect(result[0]).to.deep.equal(expected); if (dialect === 'postgres') { expect(logSql).to.include('$1'); @@ -675,8 +713,9 @@ describe(Support.getTestDialectTeaser('Sequelize'), () => { it('binds named parameters with the passed object using the same key twice', async function() { const typeCast = dialect === 'postgres' ? '::int' : ''; let logSql; - const result = await this.sequelize.query(`select $one${typeCast} as foo, $two${typeCast} as bar, $one${typeCast} as baz`, { raw: true, bind: { one: 1, two: 2 }, logging(s) { logSql = s; } }); - expect(result[0]).to.deep.equal([{ foo: 1, bar: 2, baz: 1 }]); + const result = await this.sequelize.query(`select $one${typeCast} as foo, $one${typeCast} as bar, $two${typeCast} as baz${Support.addDualInSelect()}`, { raw: true, bind: { one: 1, two: 2 }, logging(s) { logSql = s; } }); + const expected = dialect !== 'oracle' ? [{ foo: 1, bar: 1, baz: 2 }] : [{ FOO: 1, BAR: 1, BAZ: 2 }]; + expect(result[0]).to.deep.equal(expected); if (dialect === 'postgres') { expect(logSql).to.include('$1'); expect(logSql).to.include('$2'); @@ -686,16 +725,16 @@ describe(Support.getTestDialectTeaser('Sequelize'), () => { } it('binds named parameters with the passed object having a null property', async function() { const typeCast = dialect === 'postgres' || dialect === 'db2' ? '::int' : ''; - const result = await this.sequelize.query(`select $one${typeCast} as foo, $two${typeCast} as bar`, { raw: true, bind: { one: 1, two: null } }); - const expected = dialect === 'db2' ? [{ FOO: 1, BAR: null }] : [{ foo: 1, bar: null }]; + const result = await this.sequelize.query(`select $one${typeCast} as foo, $two${typeCast} as bar${Support.addDualInSelect()}`, { raw: true, bind: { one: 1, two: null } }); + const expected = ['db2', 'oracle'].includes(dialect) ? [{ FOO: 1, BAR: null }] : [{ foo: 1, bar: null }]; expect(result[0]).to.deep.equal(expected); }); it('binds named parameters array handles escaped $$', async function() { const typeCast = dialect === 'postgres' || dialect === 'db2' ? '::int' : ''; let logSql; - const result = await this.sequelize.query(`select $1${typeCast} as foo, '$$ / $$1' as bar`, { raw: true, bind: [1], logging(s) { logSql = s;} }); - const expected = dialect === 'db2' ? [{ FOO: 1, BAR: '$ / $1' }] : [{ foo: 1, bar: '$ / $1' }]; + const result = await this.sequelize.query(`select $1${typeCast} as foo, '$$ / $$1' as bar${Support.addDualInSelect()}`, { raw: true, bind: [1], logging(s) { logSql = s;} }); + const expected = ['db2', 'oracle'].includes(dialect) ? [{ FOO: 1, BAR: '$ / $1' }] : [{ foo: 1, bar: '$ / $1' }]; expect(result[0]).to.deep.equal(expected); if (['postgres', 'sqlite', 'db2'].includes(dialect)) { expect(logSql).to.include('$1'); @@ -704,22 +743,23 @@ describe(Support.getTestDialectTeaser('Sequelize'), () => { it('binds named parameters object handles escaped $$', async function() { const typeCast = dialect === 'postgres' || dialect === 'db2' ? '::int' : ''; - const result = await this.sequelize.query(`select $one${typeCast} as foo, '$$ / $$one' as bar`, { raw: true, bind: { one: 1 } }); - const expected = dialect === 'db2' ? [{ FOO: 1, BAR: '$ / $one' }] : [{ foo: 1, bar: '$ / $one' }]; + const result = await this.sequelize.query(`select $one${typeCast} as foo, '$$ / $$one' as bar${Support.addDualInSelect()}`, { raw: true, bind: { one: 1 } }); + const expected = ['db2', 'oracle'].includes(dialect) ? [{ FOO: 1, BAR: '$ / $one' }] : [{ foo: 1, bar: '$ / $one' }]; expect(result[0]).to.deep.equal(expected); }); it('escape where has $ on the middle of characters', async function() { const typeCast = dialect === 'postgres' || dialect === 'db2' ? '::int' : ''; - const result = await this.sequelize.query(`select $one${typeCast} as foo$bar`, { raw: true, bind: { one: 1 } }); - const expected = dialect === 'db2' ? [{ FOO$BAR: 1 }] : [{ foo$bar: 1 }]; + const result = await this.sequelize.query(`select $one${typeCast} as foo$bar${Support.addDualInSelect()}`, { raw: true, bind: { one: 1 } }); + const expected = ['db2', 'oracle'].includes(dialect) ? [{ FOO$BAR: 1 }] : [{ foo$bar: 1 }]; expect(result[0]).to.deep.equal(expected); }); - if (['postgres', 'sqlite', 'mssql'].includes(dialect)) { + if (['postgres', 'sqlite', 'mssql', 'oracle'].includes(dialect)) { it('does not improperly escape arrays of strings bound to named parameters', async function() { - const result = await this.sequelize.query('select :stringArray as foo', { raw: true, replacements: { stringArray: ['"string"'] } }); - expect(result[0]).to.deep.equal([{ foo: '"string"' }]); + const result = await this.sequelize.query(`select :stringArray as foo${ Support.addDualInSelect()}`, { raw: true, replacements: { stringArray: ['"string"'] } }); + const expectedData = dialect !== 'oracle' ? { foo: '"string"' } : { FOO: '"string"' }; + expect(result[0]).to.deep.equal([expectedData]); }); } @@ -727,9 +767,11 @@ describe(Support.getTestDialectTeaser('Sequelize'), () => { let datetime = dialect === 'sqlite' ? 'date(\'now\')' : 'NOW()'; if (dialect === 'mssql') { datetime = 'GETDATE()'; + } else if (dialect === 'oracle') { + datetime = 'SYSDATE'; } - const [result] = await this.sequelize.query(`SELECT ${datetime} AS t`); + const [result] = await this.sequelize.query(`SELECT ${datetime} AS t${Support.addDualInSelect()}`); expect(moment(result[0].t).isValid()).to.be.true; }); diff --git a/test/integration/sequelize/truncate.test.js b/test/integration/sequelize/truncate.test.js new file mode 100644 index 000000000000..8ae4ff79161b --- /dev/null +++ b/test/integration/sequelize/truncate.test.js @@ -0,0 +1,47 @@ +'use strict'; + +const { Deferrable, DataTypes } = require('sequelize'); +const { expect } = require('chai'); +const { sequelize } = require('../support'); + +describe('Sequelize#truncate', () => { + // These dialects do not support the CASCADE option on TRUNCATE, so it's impossible to clear + // tables that reference each-other. + if (!['mysql', 'mariadb', 'mssql', 'db2', 'oracle'].includes(sequelize.dialect.name)) { + it('supports truncating cyclic associations with { cascade: true }', async () => { + const A = sequelize.define('A', { + BId: { type: DataTypes.INTEGER } + }); + + const B = sequelize.define('B', { + AId: { type: DataTypes.INTEGER } + }); + + // These models both have a foreign key that references the other model. + // Sequelize should be able to create them. + A.belongsTo(B, { foreignKey: { allowNull: true } }); + B.belongsTo(A, { foreignKey: { allowNull: false } }); + + await sequelize.sync(); + + await sequelize.transaction({ deferrable: Deferrable.SET_DEFERRED }, async transaction => { + const a = await A.create({ + BId: null + }, { transaction }); + + const b = await B.create({ + AId: a.id + }, { transaction }); + + a.BId = b.id; + await a.save({ transaction }); + }); + + // drop both tables + await sequelize.truncate({ cascade: true }); + + expect(await A.count()).to.eq(0); + expect(await B.count()).to.eq(0); + }); + } +}); diff --git a/test/integration/timezone.test.js b/test/integration/timezone.test.js index 9c17d7b205c2..b8ab03f88eb0 100644 --- a/test/integration/timezone.test.js +++ b/test/integration/timezone.test.js @@ -29,7 +29,10 @@ if (dialect !== 'sqlite') { let query = `SELECT ${now} as now`; if (dialect === 'db2') { query = `SELECT ${now} as "now"`; + } else if (dialect === 'oracle') { + query = 'SELECT sysdate AS "now" FROM DUAL'; } + const [now1, now2] = await Promise.all([ this.sequelize.query(query, { type: this.sequelize.QueryTypes.SELECT }), this.sequelizeWithTimezone.query(query, { type: this.sequelize.QueryTypes.SELECT }) diff --git a/test/integration/transaction.test.js b/test/integration/transaction.test.js index 0d07c136bc05..5e69356c2773 100644 --- a/test/integration/transaction.test.js +++ b/test/integration/transaction.test.js @@ -88,7 +88,7 @@ if (current.dialect.supports.transactions) { await this.sequelize.transaction(t => { transaction = t; transaction.afterCommit(hook); - return this.sequelize.query('SELECT 1+1', { transaction, type: QueryTypes.SELECT }); + return this.sequelize.query(`SELECT 1+1${ Support.addDualInSelect()}`, { transaction, type: QueryTypes.SELECT }); }); expect(hook).to.have.been.calledOnce; @@ -189,24 +189,24 @@ if (current.dialect.supports.transactions) { it('does not allow queries after commit', async function() { const t = await this.sequelize.transaction(); - await this.sequelize.query('SELECT 1+1', { transaction: t, raw: true }); + await this.sequelize.query(`SELECT 1+1${ Support.addDualInSelect()}`, { transaction: t, raw: true }); await t.commit(); - await expect(this.sequelize.query('SELECT 1+1', { transaction: t, raw: true })).to.be.eventually.rejectedWith( + await expect(this.sequelize.query(`SELECT 1+1${ Support.addDualInSelect()}`, { transaction: t, raw: true })).to.be.eventually.rejectedWith( Error, /commit has been called on this transaction\([^)]+\), you can no longer use it\. \(The rejected query is attached as the 'sql' property of this error\)/ - ).and.have.deep.property('sql').that.equal('SELECT 1+1'); + ).and.have.deep.property('sql').that.equal(`SELECT 1+1${ Support.addDualInSelect()}`); }); it('does not allow queries immediately after commit call', async function() { await expect((async () => { const t = await this.sequelize.transaction(); - await this.sequelize.query('SELECT 1+1', { transaction: t, raw: true }); + await this.sequelize.query(`SELECT 1+1${ Support.addDualInSelect()}`, { transaction: t, raw: true }); await Promise.all([ expect(t.commit()).to.eventually.be.fulfilled, - expect(this.sequelize.query('SELECT 1+1', { transaction: t, raw: true })).to.be.eventually.rejectedWith( + expect(this.sequelize.query(`SELECT 1+1${ Support.addDualInSelect()}`, { transaction: t, raw: true })).to.be.eventually.rejectedWith( Error, /commit has been called on this transaction\([^)]+\), you can no longer use it\. \(The rejected query is attached as the 'sql' property of this error\)/ - ).and.have.deep.property('sql').that.equal('SELECT 1+1') + ).and.have.deep.property('sql').that.equal(`SELECT 1+1${ Support.addDualInSelect()}`) ]); })()).to.be.eventually.fulfilled; }); @@ -422,7 +422,11 @@ if (current.dialect.supports.transactions) { }); if (['mysql', 'mariadb'].includes(dialect)) { - describe('deadlock handling', () => { + // Both MariaDB and MySQL (probably innoDB) seem to have changed the way they handle this deadlock + // and the deadlock does not occur anymore. + // We have not managed to recreate this deadlock and, for now, are disabling this test. + // See https://github.com/sequelize/sequelize/issues/14174 + describe.skip('deadlock handling', () => { // Create the `Task` table and ensure it's initialized with 2 rows const getAndInitializeTaskModel = async sequelize => { const Task = sequelize.define('task', { @@ -524,6 +528,15 @@ if (current.dialect.supports.transactions) { }); it('should release the connection for a deadlocked transaction (2/2)', async function() { + // TODO [>=2022-06-01]: The following code is supposed to cause a deadlock in MariaDB, + // but starting with MariaDB 10.5.15, this does not happen anymore. + // We think it may be a bug in MariaDB, so we temporarily disable this test for that specific version + // If this still happens on newer releases, update this check, or look into why this is not working. + // See https://github.com/sequelize/sequelize/issues/14174 + if (dialect === 'mariadb' && this.sequelize.options.databaseVersion === '10.5.15') { + return; + } + const verifyDeadlock = async () => { const User = this.sequelize.define('user', { username: DataTypes.STRING, @@ -767,7 +780,7 @@ if (current.dialect.supports.transactions) { } // PostgreSQL is excluded because it detects Serialization Failure on commit instead of acquiring locks on the read rows - if (!['sqlite', 'postgres', 'postgres-native', 'db2'].includes(dialect)) { + if (!['sqlite', 'postgres', 'postgres-native', 'db2', 'oracle'].includes(dialect)) { it('should block updates after reading a row using SERIALIZABLE', async function() { const User = this.sequelize.define('user', { username: Support.Sequelize.STRING @@ -811,29 +824,41 @@ if (current.dialect.supports.transactions) { t2Spy = sinon.spy(); await this.sequelize.sync({ force: true }); - await User.create({ username: 'jan' }); + const { id } = await User.create({ username: 'jan' }); const t1 = await this.sequelize.transaction(); - const t1Jan = await User.findOne({ - where: { - username: 'jan' - }, - lock: t1.LOCK.UPDATE, - transaction: t1 - }); + // SQL constructs 'FOR UPDATE' with 'FETCH'/'ORDER BY' throws error, + // ORA-02014 for Oracle dialect. Hence using findByPk to test + // the lock behaviour. + let t1Jan; + if (dialect === 'oracle') { + t1Jan = await User.findByPk(id, { transaction: t1, lock: t1.LOCK.UPDATE }); + } else { + t1Jan = await User.findOne({ + where: { + username: 'jan' + }, + lock: t1.LOCK.UPDATE, + transaction: t1 + }); + } const t2 = await this.sequelize.transaction({ isolationLevel: Transaction.ISOLATION_LEVELS.READ_COMMITTED }); await Promise.all([(async () => { - await User.findOne({ - where: { - username: 'jan' - }, - lock: t2.LOCK.UPDATE, - transaction: t2 - }); + if (dialect === 'oracle') { + await User.findByPk(id, { transaction: t2, lock: t2.LOCK.UPDATE }); + } else { + await User.findOne({ + where: { + username: 'jan' + }, + lock: t2.LOCK.UPDATE, + transaction: t2 + }); + } t2Spy(); await t2.commit(); @@ -860,7 +885,7 @@ if (current.dialect.supports.transactions) { await this.sequelize.sync({ force: true }); - await Promise.all([ + const [id1, id2] = await Promise.all([ User.create( { username: 'jan' } ), @@ -871,23 +896,45 @@ if (current.dialect.supports.transactions) { const t1 = await this.sequelize.transaction(); - const results = await User.findAll({ - limit: 1, - lock: true, - transaction: t1 - }); + let results; + if (dialect === 'oracle') { + results = await User.findByPk(id1.id, { transaction: t1, lock: true }); + } else { + results = await User.findAll({ + limit: 1, + lock: true, + transaction: t1 + }); + } + + let firstUserId; + if (dialect === 'oracle') { + firstUserId = results.id; + } else { + firstUserId = results[0].id; + } - const firstUserId = results[0].id; const t2 = await this.sequelize.transaction(); - const secondResults = await User.findAll({ - limit: 1, - lock: true, - skipLocked: true, - transaction: t2 - }); + let secondResults; + if (dialect === 'oracle') { + secondResults = await User.findByPk(id2.id, { transaction: t2, lock: true }); + } else { + secondResults = await User.findAll({ + limit: 1, + lock: true, + skipLocked: true, + transaction: t2 + }); + } + let secondUserId; + if (dialect === 'oracle') { + secondUserId = secondResults.id; + } else { + secondUserId = secondResults[0].id; + } - expect(secondResults[0].id).to.not.equal(firstUserId); + expect(secondUserId).to.not.equal(firstUserId); await Promise.all([ t1.commit(), @@ -916,6 +963,13 @@ if (current.dialect.supports.transactions) { if (current.dialect.supports.lockOuterJoinFailure) { + let error; + if (dialect === 'oracle') { + error = 'ORA-02014: cannot select FOR UPDATE from view with DISTINCT, GROUP BY, etc'; + } else { + error = 'FOR UPDATE cannot be applied to the nullable side of an outer join'; + } + return expect(User.findOne({ where: { username: 'John' @@ -923,7 +977,7 @@ if (current.dialect.supports.transactions) { include: [Task], lock: t1.LOCK.UPDATE, transaction: t1 - })).to.be.rejectedWith('FOR UPDATE cannot be applied to the nullable side of an outer join'); + })).to.be.rejectedWith(error); } return User.findOne({ diff --git a/test/integration/utils.test.js b/test/integration/utils.test.js index 0b65c75f4dbe..ea3e09bbbd4c 100644 --- a/test/integration/utils.test.js +++ b/test/integration/utils.test.js @@ -159,8 +159,7 @@ describe(Support.getTestDialectTeaser('Utils'), () => { } ]); }); - - if (Support.getTestDialect() !== 'mssql') { + if (!['mssql', 'oracle'].includes(Support.getTestDialect())) { it('accepts condition object (with cast)', async function() { const type = Support.getTestDialect() === 'mysql' ? 'unsigned' : 'int'; @@ -188,7 +187,7 @@ describe(Support.getTestDialectTeaser('Utils'), () => { }); } - if (Support.getTestDialect() !== 'mssql' && Support.getTestDialect() !== 'postgres') { + if (!['mssql', 'postgres', 'oracle'].includes(Support.getTestDialect())) { it('accepts condition object (auto casting)', async function() { const [airplane] = await Airplane.findAll({ attributes: [ diff --git a/test/registerEsbuild.js b/test/registerEsbuild.js index 43e1078dd167..9cc67ac76d2a 100644 --- a/test/registerEsbuild.js +++ b/test/registerEsbuild.js @@ -15,7 +15,7 @@ if (nodeMajorVersion < 12) { const jsonFile = path.join(__dirname, '..', 'package.json'); moduleAlias.addAlias('sequelize/package.json', jsonFile); - const distDir = path.join(__dirname, '../dist'); + const distDir = path.join(__dirname, '..'); // make imports from `sequelize/` go to `../dist/` moduleAlias.addAlias('sequelize', distDir); } diff --git a/test/support.js b/test/support.js index 220100284d4c..70c0530d3d0c 100644 --- a/test/support.js +++ b/test/support.js @@ -2,19 +2,27 @@ const fs = require('fs'); const path = require('path'); -const { isDeepStrictEqual } = require('util'); +const { inspect, isDeepStrictEqual } = require('util'); const _ = require('lodash'); +const assert = require('assert'); const Sequelize = require('sequelize'); const Config = require('./config/config'); const chai = require('chai'); const expect = chai.expect; const AbstractQueryGenerator = require('sequelize/lib/dialects/abstract/query-generator'); -const distDir = path.resolve(__dirname, '../dist'); +const distDir = path.resolve(__dirname, '../lib'); chai.use(require('chai-datetime')); chai.use(require('chai-as-promised')); chai.use(require('sinon-chai')); + +// Using util.inspect to correctly assert objects with symbols +// Because expect.deep.equal does not test non iterator keys such as symbols (https://github.com/chaijs/chai/issues/1054) +chai.Assertion.addMethod('deepEqual', function(expected, depth = 5) { + expect(inspect(this._obj, { depth })).to.deep.equal(inspect(expected, { depth })); +}); + chai.config.includeStack = true; chai.should(); @@ -97,7 +105,7 @@ const Support = { createSequelizeInstance(options) { options = options || {}; - options.dialect = this.getTestDialect(); + options.dialect = Support.getTestDialect(); const config = Config[options.dialect]; @@ -119,7 +127,7 @@ const Support = { sequelizeOptions.storage = config.storage; } - return this.getSequelizeInstance(config.database, config.username, config.password, sequelizeOptions); + return Support.getSequelizeInstance(config.database, config.username, config.password, sequelizeOptions); }, getConnectionOptionsWithoutPool() { @@ -166,7 +174,8 @@ const Support = { }, getSupportedDialects() { - return fs.readdirSync(path.join(distDir, 'lib/dialects')) + return fs + .readdirSync(path.join(distDir, 'dialects')) .filter(file => !file.includes('.js') && !file.includes('abstract')); }, @@ -214,16 +223,39 @@ const Support = { }, expectsql(query, assertions) { - const expectations = assertions.query || assertions; + const rawExpectationMap = + 'query' in assertions ? assertions.query : assertions; + const expectations = Object.create(null); + + for (const [key, value] of Object.entries(rawExpectationMap)) { + const acceptedDialects = key.split(' '); + + for (const dialect of acceptedDialects) { + if (dialect === 'default' && acceptedDialects.length > 1) { + throw new Error( + 'The \'default\' expectation cannot be combined with other dialects.' + ); + } + + if (expectations[dialect] !== undefined) { + throw new Error( + `The expectation for ${dialect} was already defined.` + ); + } + + expectations[dialect] = value; + } + } let expectation = expectations[Support.sequelize.dialect.name]; + const dialect = Support.sequelize.dialect; if (!expectation) { if (expectations['default'] !== undefined) { expectation = expectations['default']; if (typeof expectation === 'string') { - expectation = expectation - .replace(/\[/g, Support.sequelize.dialect.TICK_CHAR_LEFT) - .replace(/\]/g, Support.sequelize.dialect.TICK_CHAR_RIGHT); + // replace [...] with the proper quote character for the dialect + // except for ARRAY[...] + expectation = expectation.replace(/(? isDeepStrictEqual(actual, expected)); + }, + + /** + * Reduces insignificant whitespace from SQL string. + * + * @param {string} sql the SQL string + * @returns {string} the SQL string with insignificant whitespace removed. + */ + minifySql(sql) { + // replace all consecutive whitespaces with a single plain space character + return sql.replace(/\s+/g, ' ') + // remove space before comma + .replace(/ ,/g, ',') + // remove space before ) + .replace(/ \)/g, ')') + // replace space after ( + .replace(/\( /g, '(') + // remove whitespace at start & end + .trim(); + }, + + addDualInSelect() { + return this.getTestDialect() === 'oracle' ? ' FROM DUAL' : ''; } }; @@ -260,5 +315,119 @@ if (global.beforeEach) { }); } +function expectPerDialect(method, assertions) { + const expectations = Object.create(null); + + for (const [key, value] of Object.entries(assertions)) { + const acceptedDialects = key.split(' '); + + for (const dialect of acceptedDialects) { + if (dialect === 'default' && acceptedDialects.length > 1) { + throw new Error( + 'The \'default\' expectation cannot be combined with other dialects.' + ); + } + + if (expectations[dialect] !== undefined) { + throw new Error(`The expectation for ${dialect} was already defined.`); + } + + expectations[dialect] = value; + } + } + + let result; + + try { + result = method(); + } catch (error) { + assert(error instanceof Error, 'method threw a non-error'); + + result = error; + } + + let expectation = expectations[Support.sequelize.dialect.name]; + expectation = expectation != null ? expectation : expectations.default; + + if (expectation === undefined) { + throw new Error( + `No expectation was defined for ${Support.sequelize.dialect.name} and the 'default' expectation has not been defined.` + ); + } + + if (expectation instanceof Error) { + assert( + result instanceof Error, + `Expected method to error with "${ + expectation.message + }", but it returned ${inspect(result)}.` + ); + + expect(result.message).to.equal(expectation.message); + } else { + assert( + !(result instanceof Error), + `Did not expect query to error, but it errored with ${ + result instanceof Error ? result.message : '' + }` + ); + + assertMatchesExpectation(result, expectation); + } +} + +function assertMatchesExpectation(result, expectation) { + if (expectation instanceof Expectation) { + expectation.assert(result); + } else { + expect(result).to.deep.equal(expectation); + } +} + +class Expectation { + assert(value) {} +} + +class SqlExpectation extends Expectation { + constructor(sql) { + super(); + this.sql = sql; + } + + assert(value) { + expect(Support.minifySql(value)).to.equal(Support.minifySql(this.sql)); + } +} + +function toMatchSql(sql) { + return new SqlExpectation(sql); +} + +class HasPropertiesExpectation extends Expectation { + constructor(properties) { + super(); + this.properties = properties; + } + + assert(value) { + console.log({ + value, + props: this.properties, + keys: Object.keys(this.properties) + }); + for (const key of Object.keys(this.properties)) { + console.log({ key, value: value[key], expected: this.properties[key] }); + assertMatchesExpectation(value[key], this.properties[key]); + } + } +} + +function toHaveProperties(properties) { + return new HasPropertiesExpectation(properties); +} + Support.sequelize = Support.createSequelizeInstance(); +Support.expectPerDialect = expectPerDialect; +Support.toMatchSql = toMatchSql; +Support.toHaveProperties = toHaveProperties; module.exports = Support; diff --git a/test/tsconfig.json b/test/tsconfig.json index c11e94933cbd..d2e4cfe64519 100644 --- a/test/tsconfig.json +++ b/test/tsconfig.json @@ -1,14 +1,16 @@ { "extends": "../tsconfig.json", "compilerOptions": { + "rootDir": ".", "baseUrl": ".", "paths": { - "sequelize/*": ["../dist/*"] + "sequelize": ["../types/index.d.ts"], + "sequelize/lib/*": ["../types/*"], + "sequelize/*": ["../*"] }, "types": ["node", "mocha", "sinon", "chai"], - - "emitDeclarationOnly": false, - "noEmit": true + "noEmit": true, + "emitDeclarationOnly": false }, - "include": ["./**/*"], + "include": ["./types/**/*", "../types/*"] } diff --git a/types/test/attributes.ts b/test/types/attributes.ts similarity index 95% rename from types/test/attributes.ts rename to test/types/attributes.ts index c01ab6274af8..4c2e5b6f4439 100644 --- a/types/test/attributes.ts +++ b/test/types/attributes.ts @@ -1,4 +1,4 @@ -import { Model } from "sequelize/lib/model"; +import { Model } from "sequelize"; interface UserCreationAttributes { name: string; diff --git a/test/types/bulk-create.ts b/test/types/bulk-create.ts new file mode 100644 index 000000000000..cd76fad9eb5e --- /dev/null +++ b/test/types/bulk-create.ts @@ -0,0 +1,60 @@ +import { + Model, + InferAttributes, + CreationOptional, + InferCreationAttributes, +} from 'sequelize'; +import { sequelize } from './connection'; +import type { MakeNullishOptional } from 'sequelize/types/utils'; + +class TestModel extends Model< + InferAttributes, + InferCreationAttributes +> { + declare id: CreationOptional; + declare testString: CreationOptional; + declare testEnum: CreationOptional<'d' | 'e' | 'f' | null>; +} + +type wat = InferCreationAttributes; + +sequelize.transaction(async trx => { + const newItems: Array< + MakeNullishOptional> + > = [ + { + testEnum: 'e', + testString: 'abc', + }, + { + testEnum: null, + testString: undefined, + }, + ]; + + const res1: Array = await TestModel.bulkCreate(newItems, { + benchmark: true, + fields: ['testEnum'], + hooks: true, + logging: true, + returning: true, + transaction: trx, + validate: true, + ignoreDuplicates: true, + }); + + const res2: Array = await TestModel.bulkCreate(newItems, { + benchmark: true, + fields: ['testEnum'], + hooks: true, + logging: true, + returning: false, + transaction: trx, + validate: true, + updateOnDuplicate: ['testEnum', 'testString'], + }); + + const res3: Array = await TestModel.bulkCreate(newItems, { + conflictAttributes: ['testEnum', 'testString'], + }); +}); diff --git a/types/test/connection.ts b/test/types/connection.ts similarity index 93% rename from types/test/connection.ts rename to test/types/connection.ts index 5c2006fb053a..1578b7732563 100644 --- a/types/test/connection.ts +++ b/test/types/connection.ts @@ -1,6 +1,6 @@ import { expectTypeOf } from "expect-type"; import { QueryTypes, Sequelize, SyncOptions } from 'sequelize'; -import { User } from 'models/User'; +import { User } from './models/User'; export const sequelize = new Sequelize('uri'); @@ -11,7 +11,7 @@ sequelize.afterBulkSync((options: SyncOptions) => { async function test() { expectTypeOf( await sequelize.query('SELECT * FROM `test`', { type: QueryTypes.SELECT }) - ).toEqualTypeOf(); + ).toEqualTypeOf(); expectTypeOf( await sequelize.query('INSERT into test set test=1', { type: QueryTypes.INSERT }) diff --git a/types/test/create.ts b/test/types/create.ts similarity index 74% rename from types/test/create.ts rename to test/types/create.ts index ab58c11fd416..0c2d5e3e43a1 100644 --- a/types/test/create.ts +++ b/test/types/create.ts @@ -1,5 +1,7 @@ import { expectTypeOf } from 'expect-type' import { User } from './models/User'; +import { Model } from 'sequelize'; +import { UserGroup } from './models/UserGroup.js'; (async () => { const user = await User.create({ @@ -72,3 +74,30 @@ import { User } from './models/User'; unknown: '', }); })(); + +// reasons for this test: https://github.com/sequelize/sequelize/issues/14129 +(async () => { + interface User2Attributes { + groupId: number; + } + + type User2CreationAttributes = { id: number } & ( + | { groupId: number } + | { group: { id: number } } + ); + + class User2 extends Model { + declare groupId: number; + declare group?: UserGroup; + } + + await User2.create({ + id: 1, + groupId: 1, + }); + + await User2.create({ + id: 2, + group: { id: 1 }, + }, { include: [User2.associations.group] }); +})(); diff --git a/types/test/data-types.ts b/test/types/data-types.ts similarity index 100% rename from types/test/data-types.ts rename to test/types/data-types.ts diff --git a/types/test/define.ts b/test/types/define.ts similarity index 100% rename from types/test/define.ts rename to test/types/define.ts diff --git a/types/test/destroy.ts b/test/types/destroy.ts similarity index 100% rename from types/test/destroy.ts rename to test/types/destroy.ts diff --git a/types/test/e2e/docs-example.ts b/test/types/e2e/docs-example.ts similarity index 100% rename from types/test/e2e/docs-example.ts rename to test/types/e2e/docs-example.ts diff --git a/types/test/errors.ts b/test/types/errors.ts similarity index 80% rename from types/test/errors.ts rename to test/types/errors.ts index 253a379b4d59..9cd292d3ce43 100644 --- a/types/test/errors.ts +++ b/test/types/errors.ts @@ -1,6 +1,5 @@ import { expectTypeOf } from "expect-type"; -import { BaseError, EmptyResultError, Error as AliasedBaseError, UniqueConstraintError } from 'sequelize'; -import { OptimisticLockError } from 'sequelize/lib/errors'; +import { BaseError, EmptyResultError, Error as AliasedBaseError, UniqueConstraintError, OptimisticLockError } from 'sequelize'; expectTypeOf().toEqualTypeOf(); expectTypeOf().toHaveProperty('sql').toBeString(); diff --git a/types/test/findByPk.ts b/test/types/findByPk.ts similarity index 100% rename from types/test/findByPk.ts rename to test/types/findByPk.ts diff --git a/test/types/findOne.ts b/test/types/findOne.ts new file mode 100644 index 000000000000..25f814cd672d --- /dev/null +++ b/test/types/findOne.ts @@ -0,0 +1,24 @@ +import { User } from './models/User'; + +// These attributes exist +User.findOne({ where: { firstName: 'John' } }); +User.findOne({ where: { '$firstName$': 'John' } }); + +// These attributes do not exist +// @ts-expect-error +User.findOne({ where: { blah: 'blah2' } }); +// @ts-expect-error +User.findOne({ where: { '$blah$': 'blah2' } }); + +// $nested.syntax$ is valid +// TODO [2022-05-26]: Remove this ts-ignore once we drop support for TS < 4.4 +// TypeScript < 4.4 does not support using a Template Literal Type as a key. +// note: this *must* be a ts-ignore, as it works in ts >= 4.4 +// @ts-ignore +User.findOne({ where: { '$include1.includeAttr$': 'blah2' } }); +// $nested.nested.syntax$ is valid +// TODO [2022-05-26]: Remove this ts-ignore once we drop support for TS < 4.4 +// TypeScript < 4.4 does not support using a Template Literal Type as a key. +// note: this *must* be a ts-ignore, as it works in ts >= 4.4 +// @ts-ignore +User.findOne({ where: { '$include1.$include2.includeAttr$': 'blah2' } }); diff --git a/types/test/hooks.ts b/test/types/hooks.ts similarity index 61% rename from types/test/hooks.ts rename to test/types/hooks.ts index 474c149b599c..4f3dfff92f50 100644 --- a/types/test/hooks.ts +++ b/test/types/hooks.ts @@ -1,9 +1,8 @@ import { expectTypeOf } from "expect-type"; -import { FindOptions, Model, QueryOptions, SaveOptions, Sequelize, UpsertOptions } from "sequelize"; +import { FindOptions, Model, QueryOptions, SaveOptions, Sequelize, UpsertOptions, Config, Utils } from "sequelize"; +import { Connection, GetConnectionOptions } from "sequelize/lib/dialects/abstract/connection-manager"; import { ModelHooks } from "sequelize/lib/hooks"; import { AbstractQuery } from "sequelize/lib/query"; -import { Config } from 'sequelize/lib/sequelize'; -import { DeepWriteable } from 'sequelize/lib/utils'; import { SemiDeepWritable } from "./type-helpers/deep-writable"; { @@ -63,28 +62,53 @@ import { SemiDeepWritable } from "./type-helpers/deep-writable"; { const hooks: ModelHooks = 0 as any; - hooks.beforeValidate = (...args) => { expectTypeOf(args).toEqualTypeOf>() }; - hooks.beforeCreate = (...args) => { expectTypeOf(args).toEqualTypeOf>() }; - hooks.beforeDestroy = (...args) => { expectTypeOf(args).toEqualTypeOf>() }; - hooks.beforeRestore = (...args) => { expectTypeOf(args).toEqualTypeOf>() }; - hooks.beforeUpdate = (...args) => { expectTypeOf(args).toEqualTypeOf>() }; - hooks.beforeSave = (...args) => { expectTypeOf(args).toEqualTypeOf>() }; - hooks.beforeBulkCreate = (...args) => { expectTypeOf(args).toEqualTypeOf>() }; - hooks.beforeBulkDestroy = (...args) => { expectTypeOf(args).toEqualTypeOf>() }; - hooks.beforeBulkRestore = (...args) => { expectTypeOf(args).toEqualTypeOf>() }; - hooks.beforeBulkUpdate = (...args) => { expectTypeOf(args).toEqualTypeOf>() }; - hooks.beforeFind = (...args) => { expectTypeOf(args).toEqualTypeOf>() }; - hooks.beforeCount = (...args) => { expectTypeOf(args).toEqualTypeOf>() }; - hooks.beforeFindAfterExpandIncludeAll = (...args) => { expectTypeOf(args).toEqualTypeOf>() }; - hooks.beforeFindAfterOptions = (...args) => { expectTypeOf(args).toEqualTypeOf>() }; - hooks.beforeSync = (...args) => { expectTypeOf(args).toEqualTypeOf>() }; - hooks.beforeBulkSync = (...args) => { expectTypeOf(args).toEqualTypeOf>() }; - hooks.beforeQuery = (...args) => { expectTypeOf(args).toEqualTypeOf>() }; - hooks.beforeUpsert = (...args) => { expectTypeOf(args).toEqualTypeOf>() }; + hooks.beforeValidate = (...args) => { expectTypeOf(args).toEqualTypeOf>(); }; + hooks.beforeCreate = (...args) => { expectTypeOf(args).toEqualTypeOf>(); }; + hooks.beforeDestroy = (...args) => { expectTypeOf(args).toEqualTypeOf>(); }; + hooks.beforeRestore = (...args) => { expectTypeOf(args).toEqualTypeOf>(); }; + hooks.beforeUpdate = (...args) => { expectTypeOf(args).toEqualTypeOf>(); }; + hooks.beforeSave = (...args) => { expectTypeOf(args).toEqualTypeOf>(); }; + hooks.beforeBulkCreate = (...args) => { expectTypeOf(args).toEqualTypeOf>(); }; + hooks.beforeBulkDestroy = (...args) => { expectTypeOf(args).toEqualTypeOf>(); }; + hooks.beforeBulkRestore = (...args) => { expectTypeOf(args).toEqualTypeOf>(); }; + hooks.beforeBulkUpdate = (...args) => { expectTypeOf(args).toEqualTypeOf>(); }; + hooks.beforeFind = (...args) => { expectTypeOf(args).toEqualTypeOf>(); }; + hooks.beforeCount = (...args) => { expectTypeOf(args).toEqualTypeOf>(); }; + hooks.beforeFindAfterExpandIncludeAll = (...args) => { expectTypeOf(args).toEqualTypeOf>(); }; + hooks.beforeFindAfterOptions = (...args) => { expectTypeOf(args).toEqualTypeOf>(); }; + hooks.beforeSync = (...args) => { expectTypeOf(args).toEqualTypeOf>(); }; + hooks.beforeBulkSync = (...args) => { expectTypeOf(args).toEqualTypeOf>(); }; + hooks.beforeQuery = (...args) => { expectTypeOf(args).toEqualTypeOf>(); }; + hooks.beforeUpsert = (...args) => { expectTypeOf(args).toEqualTypeOf>(); }; } { - Sequelize.beforeConnect('name', config => expectTypeOf(config).toEqualTypeOf>()); - Sequelize.beforeConnect(config => expectTypeOf(config).toEqualTypeOf>()); - Sequelize.addHook('beforeConnect', (...args) => { expectTypeOf(args).toEqualTypeOf<[DeepWriteable]>(); }) + Sequelize.beforeConnect('name', config => expectTypeOf(config).toEqualTypeOf>()); + Sequelize.beforeConnect(config => expectTypeOf(config).toEqualTypeOf>()); + Sequelize.addHook('beforeConnect', (...args) => { expectTypeOf(args).toEqualTypeOf<[Utils.DeepWriteable]>(); }); + Sequelize.beforePoolAcquire('name', (options?: GetConnectionOptions) => { + expectTypeOf(options).toMatchTypeOf(); + }); + + Sequelize.beforePoolAcquire((options?: GetConnectionOptions) => { + expectTypeOf(options).toMatchTypeOf(); + }); + + Sequelize.addHook('beforePoolAcquire', (...args: [GetConnectionOptions | undefined]) => { + expectTypeOf(args).toMatchTypeOf<[GetConnectionOptions | undefined]>(); + }); + + Sequelize.afterPoolAcquire('name', (connection: Connection, options?: GetConnectionOptions) => { + expectTypeOf(connection).toMatchTypeOf(); + expectTypeOf(options).toMatchTypeOf(); + }); + + Sequelize.afterPoolAcquire((connection: Connection, options?: GetConnectionOptions) => { + expectTypeOf(connection).toMatchTypeOf(); + expectTypeOf(options).toMatchTypeOf(); + }); + + Sequelize.addHook('afterPoolAcquire', (...args: [Connection | GetConnectionOptions | undefined]) => { + expectTypeOf(args).toMatchTypeOf<[Connection | GetConnectionOptions | undefined]>(); + }); } diff --git a/types/test/include.ts b/test/types/include.ts similarity index 100% rename from types/test/include.ts rename to test/types/include.ts diff --git a/types/test/index-hints.ts b/test/types/index-hints.ts similarity index 55% rename from types/test/index-hints.ts rename to test/types/index-hints.ts index e6a9c6aed1b9..339f5835e186 100644 --- a/types/test/index-hints.ts +++ b/test/types/index-hints.ts @@ -1,5 +1,5 @@ -import { User } from 'models/User'; -import { IndexHints } from '..'; +import { User } from './models/User'; +import { IndexHints } from 'sequelize'; User.findAll({ indexHints: [{ diff --git a/test/types/infer-attributes.ts b/test/types/infer-attributes.ts new file mode 100644 index 000000000000..271bbfccd210 --- /dev/null +++ b/test/types/infer-attributes.ts @@ -0,0 +1,143 @@ +import { expectTypeOf } from 'expect-type'; +import { + Attributes, + CreationAttributes, + CreationOptional, + DataTypes, + ForeignKey, + InferAttributes, + InferCreationAttributes, + Model, + NonAttribute, + Sequelize, +} from 'sequelize'; + +class Project extends Model> { + declare id: number; +} + +class User extends Model, + InferCreationAttributes> { + declare optionalAttribute: CreationOptional; + declare mandatoryAttribute: string; + + declare optionalArrayAttribute: CreationOptional; + declare mandatoryArrayAttribute: string[]; + + // note: using CreationOptional here is unnecessary, but we still ensure that it works. + declare nullableOptionalAttribute: CreationOptional; + + declare nonAttribute: NonAttribute; + declare nonAttributeArray: NonAttribute; + declare nonAttributeNestedArray: NonAttribute; + + declare omittedAttribute: number; + declare omittedAttributeArray: number[]; + + declare joinedEntity?: NonAttribute; + declare projectId: CreationOptional>; + + instanceMethod() { + } + + static staticMethod() { + } +} + +User.init({ + mandatoryArrayAttribute: DataTypes.ARRAY(DataTypes.STRING), + mandatoryAttribute: DataTypes.STRING, + // projectId is omitted but still works, because it is branded with 'ForeignKey' + nullableOptionalAttribute: DataTypes.STRING, + optionalArrayAttribute: DataTypes.ARRAY(DataTypes.STRING), + optionalAttribute: DataTypes.INTEGER, +}, { sequelize: new Sequelize() }); + +type UserAttributes = Attributes; +type UserCreationAttributes = CreationAttributes; + +expectTypeOf().not.toBeAny(); +expectTypeOf().not.toBeAny(); + +expectTypeOf().not.toBeNullable(); +expectTypeOf().toBeNullable(); + +expectTypeOf().not.toBeNullable(); +expectTypeOf().not.toBeNullable(); + +expectTypeOf().not.toBeNullable(); +expectTypeOf().toBeNullable(); + +type NonUndefined = T extends undefined ? never : T; + +expectTypeOf().not.toEqualTypeOf>(); + +expectTypeOf().not.toBeNullable(); +expectTypeOf().not.toBeNullable(); + +expectTypeOf().not.toHaveProperty('nonAttribute'); +expectTypeOf().not.toHaveProperty('nonAttribute'); + +expectTypeOf().not.toHaveProperty('nonAttributeArray'); +expectTypeOf().not.toHaveProperty('nonAttributeArray'); + +expectTypeOf().not.toHaveProperty('nonAttributeNestedArray'); +expectTypeOf().not.toHaveProperty('nonAttributeNestedArray'); + +expectTypeOf().not.toHaveProperty('omittedAttribute'); +expectTypeOf().not.toHaveProperty('omittedAttribute'); + +expectTypeOf().not.toHaveProperty('omittedAttributeArray'); +expectTypeOf().not.toHaveProperty('omittedAttributeArray'); + +expectTypeOf().not.toHaveProperty('instanceMethod'); +expectTypeOf().not.toHaveProperty('instanceMethod'); + +expectTypeOf().not.toHaveProperty('staticMethod'); +expectTypeOf().not.toHaveProperty('staticMethod'); + +// brands: + +{ + const user = User.build({ mandatoryArrayAttribute: [], mandatoryAttribute: '' }); + + // ensure branding does not break arrays. + const brandedArray: NonAttribute = user.nonAttributeArray; + const anArray: string[] = user.nonAttributeArray; + const item: boolean = user.nonAttributeArray[0].endsWith(''); +} + +{ + // ensure branding does not break objects + const brandedObject: NonAttribute> = {}; + const anObject: Record = brandedObject; + const item: string = brandedObject.key; +} + +{ + // ensure branding does not break primitives + const brandedString: NonAttribute = ''; + const aString: string = brandedString; +} + +{ + const user = User.build({ mandatoryArrayAttribute: [], mandatoryAttribute: '' }); + const project: Project = user.joinedEntity!; + + // ensure branding does not break objects + const id = project.id; +} + +{ + // ensure branding does not break null + const brandedString: NonAttribute = null; +} + +{ + class User2 extends Model, InferCreationAttributes> { + declare nullableAttribute: string | null; + } + + // this should work, all null attributes are optional in Model.create + User2.create({}); +} diff --git a/types/test/model-count.ts b/test/types/model-count.ts similarity index 100% rename from types/test/model-count.ts rename to test/types/model-count.ts diff --git a/types/test/model.ts b/test/types/model.ts similarity index 77% rename from types/test/model.ts rename to test/types/model.ts index 53294e19f1f3..a05ff9fe0c1c 100644 --- a/types/test/model.ts +++ b/test/types/model.ts @@ -1,6 +1,17 @@ import { expectTypeOf } from "expect-type"; -import { Association, BelongsToManyGetAssociationsMixin, DataTypes, HasOne, Model, Optional, Sequelize } from 'sequelize'; -import { ModelDefined } from 'sequelize/lib/model'; +import { + Association, + BelongsToManyGetAssociationsMixin, + DataTypes, + HasOne, + Model, + Optional, + Sequelize, + ModelDefined, + CreationOptional, + InferAttributes, + InferCreationAttributes, +} from 'sequelize'; expectTypeOf().toMatchTypeOf(); class MyModel extends Model { @@ -69,11 +80,41 @@ MyModel.count({ group: 'type' }).then((result) => { expectTypeOf(result[0]).toMatchTypeOf<{ count: number }>(); }); +MyModel.increment('int', { by: 1 }).then(result => { + expectTypeOf(result).toEqualTypeOf<[affectedRows: MyModel[], affectedCount?: number]>(); +}); + +MyModel.increment({ int: 2 }, {}).then(result => { + expectTypeOf(result).toEqualTypeOf<[affectedRows: MyModel[], affectedCount?: number]>(); +}); + +MyModel.increment(['int'], { by: 3 }).then(result => { + expectTypeOf(result).toEqualTypeOf<[affectedRows: MyModel[], affectedCount?: number]>(); +}); + +MyModel.decrement('int', { by: 1 }).then(result => { + expectTypeOf(result).toEqualTypeOf<[affectedRows: MyModel[], affectedCount?: number]>(); +}); + +MyModel.decrement({ int: 2 }, {}).then(result => { + expectTypeOf(result).toEqualTypeOf<[affectedRows: MyModel[], affectedCount?: number]>(); +}); + +MyModel.decrement(['int'], { by: 3 }).then(result => { + expectTypeOf(result).toEqualTypeOf<[affectedRows: MyModel[], affectedCount?: number]>(); +}); + MyModel.build({ int: 10 }, { include: OtherModel }); MyModel.bulkCreate([{ int: 10 }], { include: OtherModel, searchPath: 'public' }); -MyModel.update({}, { where: { foo: 'bar' }, paranoid: false}); +MyModel.update({}, { where: { foo: 'bar' }, paranoid: false}).then((result) => { + expectTypeOf(result).toEqualTypeOf<[affectedCount: number]>(); +}); + +MyModel.update({}, { where: { foo: 'bar' }, returning: true}).then((result) => { + expectTypeOf(result).toEqualTypeOf<[affectedCount: number, affectedRows: MyModel[]]>(); +}); const sequelize = new Sequelize('mysql://user:user@localhost:3306/mydb'); @@ -104,17 +145,13 @@ const model: typeof MyModel = MyModel.init({ } }); -type UserModelAttributes = { - username: string, - beta_user: boolean, -}; - -type UserCreationAttributes = Optional; - /** * Tests for findCreateFind() type. */ -class UserModel extends Model {} +class UserModel extends Model, InferCreationAttributes> { + declare username: string; + declare beta_user: CreationOptional; +} UserModel.init({ username: { type: DataTypes.STRING, allowNull: false }, @@ -133,7 +170,10 @@ UserModel.findCreateFind({ } }) -UserModel.getAttributes(); +const rawAttributes = UserModel.getAttributes(); +expectTypeOf(rawAttributes).toHaveProperty('username'); +expectTypeOf(rawAttributes).toHaveProperty('beta_user'); +expectTypeOf(rawAttributes).not.toHaveProperty('non_attribute'); /** * Tests for findOrCreate() type. diff --git a/types/test/models/User.ts b/test/types/models/User.ts similarity index 98% rename from types/test/models/User.ts rename to test/types/models/User.ts index e2029fb062f7..bde48a85266e 100644 --- a/types/test/models/User.ts +++ b/test/types/models/User.ts @@ -115,9 +115,9 @@ User.addHook('afterDestroy', async (instance, options) => { }); // Model#addScope -User.addScope('withoutFirstName', { +User.addScope('withoutLastName', { where: { - firstName: { + lastName: { [Op.is]: null } } diff --git a/types/test/models/UserGroup.ts b/test/types/models/UserGroup.ts similarity index 96% rename from types/test/models/UserGroup.ts rename to test/types/models/UserGroup.ts index e50d4ac6eec9..de19a7bec18c 100644 --- a/types/test/models/UserGroup.ts +++ b/test/types/models/UserGroup.ts @@ -13,7 +13,8 @@ import { HasManyRemoveAssociationMixin, HasManyRemoveAssociationsMixin, HasManySetAssociationsMixin, - Model + Model, + NonAttribute, } from 'sequelize'; import { sequelize } from '../connection'; // associate @@ -34,7 +35,7 @@ export class UserGroup extends Model< declare name: string; // mixins for association (optional) - declare users?: User[]; + declare users?: NonAttribute; declare getUsers: HasManyGetAssociationsMixin; declare setUsers: HasManySetAssociationsMixin; declare addUser: HasManyAddAssociationMixin; diff --git a/types/test/models/UserPost.ts b/test/types/models/UserPost.ts similarity index 100% rename from types/test/models/UserPost.ts rename to test/types/models/UserPost.ts diff --git a/types/test/query-interface.ts b/test/types/query-interface.ts similarity index 97% rename from types/test/query-interface.ts rename to test/types/query-interface.ts index 58408c298add..206ab0c752c1 100644 --- a/types/test/query-interface.ts +++ b/test/types/query-interface.ts @@ -1,6 +1,4 @@ -import { DataTypes, Model, fn, literal, col } from 'sequelize'; -// tslint:disable-next-line:no-submodule-imports -import { QueryInterface } from 'sequelize/lib/query-interface'; +import { DataTypes, Model, fn, literal, col, QueryInterface } from 'sequelize'; declare let queryInterface: QueryInterface; @@ -225,7 +223,7 @@ async function test() { class TestModel extends Model {} - await queryInterface.upsert("test", {"a": 1}, {"b": 2}, {"c": 3}, TestModel, {}); + await queryInterface.upsert("test", {"a": 1}, {"b": 2}, {"c": 3}, {model: TestModel}); await queryInterface.insert(null, 'test', {}); } diff --git a/types/test/sequelize.ts b/test/types/sequelize.ts similarity index 90% rename from types/test/sequelize.ts rename to test/types/sequelize.ts index 6ab8df360112..d57a65d80d8c 100644 --- a/types/test/sequelize.ts +++ b/test/types/sequelize.ts @@ -1,5 +1,4 @@ -import { Config, Sequelize, Model, QueryTypes, ModelCtor, Op } from 'sequelize'; -import { Fn } from 'sequelize/lib/utils'; +import { Config, Sequelize, Model, QueryTypes, ModelCtor, Op, Utils } from 'sequelize'; Sequelize.useCLS({ }); @@ -28,6 +27,7 @@ Sequelize.and() Sequelize.or() Sequelize.json('data.id') Sequelize.where(Sequelize.col("ABS"), Op.is, null); +Sequelize.where(Sequelize.col("ABS"), '=', null); // instance members sequelize.fn('max', sequelize.col('age')) @@ -37,6 +37,7 @@ sequelize.and() sequelize.or() sequelize.json('data.id') sequelize.where(sequelize.col("ABS"), Op.is, null); +sequelize.getQueryInterface(); const databaseName = sequelize.getDatabaseName(); @@ -70,7 +71,7 @@ Sequelize.afterConnect(() => { }); -const rnd: Fn = sequelize.random(); +const rnd: Utils.Fn = sequelize.random(); class Model1 extends Model{} class Model2 extends Model{} diff --git a/types/test/transaction.ts b/test/types/transaction.ts similarity index 100% rename from types/test/transaction.ts rename to test/types/transaction.ts diff --git a/types/test/type-helpers/deep-writable.ts b/test/types/type-helpers/deep-writable.ts similarity index 100% rename from types/test/type-helpers/deep-writable.ts rename to test/types/type-helpers/deep-writable.ts diff --git a/types/test/typescriptDocs/Define.ts b/test/types/typescriptDocs/Define.ts similarity index 54% rename from types/test/typescriptDocs/Define.ts rename to test/types/typescriptDocs/Define.ts index 8ea23694d01c..446ad3605082 100644 --- a/types/test/typescriptDocs/Define.ts +++ b/test/types/typescriptDocs/Define.ts @@ -4,37 +4,32 @@ * * Don't include this comment in the md file. */ -import { Sequelize, Model, DataTypes, Optional } from 'sequelize'; +import { Sequelize, Model, DataTypes, CreationOptional, InferAttributes, InferCreationAttributes } from 'sequelize'; const sequelize = new Sequelize('mysql://root:asd123@localhost:3306/mydb'); // We recommend you declare an interface for the attributes, for stricter typechecking -interface UserAttributes { - id: number; + +interface UserModel extends Model, InferCreationAttributes> { + // Some fields are optional when calling UserModel.create() or UserModel.build() + id: CreationOptional; name: string; } -// Some fields are optional when calling UserModel.create() or UserModel.build() -interface UserCreationAttributes extends Optional {} - -// We need to declare an interface for our model that is basically what our class would be -interface UserInstance - extends Model, - UserAttributes {} - -const UserModel = sequelize.define('User', { +const UserModel = sequelize.define('User', { id: { primaryKey: true, type: DataTypes.INTEGER.UNSIGNED, }, name: { type: DataTypes.STRING, - } + }, }); async function doStuff() { const instance = await UserModel.findByPk(1, { rejectOnEmpty: true, }); + console.log(instance.id); } diff --git a/types/test/typescriptDocs/ModelInit.ts b/test/types/typescriptDocs/ModelInit.ts similarity index 94% rename from types/test/typescriptDocs/ModelInit.ts rename to test/types/typescriptDocs/ModelInit.ts index ea7ebe6cd6e3..fd57ae200cb9 100644 --- a/types/test/typescriptDocs/ModelInit.ts +++ b/test/types/typescriptDocs/ModelInit.ts @@ -9,7 +9,7 @@ import { HasManyCreateAssociationMixin, HasManyGetAssociationsMixin, HasManyHasAssociationMixin, HasManySetAssociationsMixin, HasManyAddAssociationsMixin, HasManyHasAssociationsMixin, HasManyRemoveAssociationMixin, HasManyRemoveAssociationsMixin, Model, ModelDefined, Optional, - Sequelize, InferAttributes, InferCreationAttributes, CreationOptional, NonAttribute + Sequelize, InferAttributes, InferCreationAttributes, CreationOptional, NonAttribute, ForeignKey, } from 'sequelize'; const sequelize = new Sequelize('mysql://root:asd123@localhost:3306/mydb'); @@ -62,7 +62,11 @@ class Project extends Model< > { // id can be undefined during creation when using `autoIncrement` declare id: CreationOptional; - declare ownerId: number; + + // foreign keys are automatically added by associations methods (like Project.belongsTo) + // by branding them using the `ForeignKey` type, `Project.init` will know it does not need to + // display an error if ownerId is missing. + declare ownerId: ForeignKey; declare name: string; // `owner` is an eagerly-loaded association. @@ -79,7 +83,7 @@ class Address extends Model< InferAttributes
, InferCreationAttributes
> { - declare userId: number; + declare userId: ForeignKey; declare address: string; // createdAt can be undefined during creation @@ -95,10 +99,6 @@ Project.init( autoIncrement: true, primaryKey: true }, - ownerId: { - type: DataTypes.INTEGER.UNSIGNED, - allowNull: false - }, name: { type: new DataTypes.STRING(128), allowNull: false @@ -138,9 +138,6 @@ User.init( Address.init( { - userId: { - type: DataTypes.INTEGER.UNSIGNED - }, address: { type: new DataTypes.STRING(128), allowNull: false diff --git a/types/test/typescriptDocs/ModelInitNoAttributes.ts b/test/types/typescriptDocs/ModelInitNoAttributes.ts similarity index 86% rename from types/test/typescriptDocs/ModelInitNoAttributes.ts rename to test/types/typescriptDocs/ModelInitNoAttributes.ts index ff8a5c22a22d..a7d634be50c3 100644 --- a/types/test/typescriptDocs/ModelInitNoAttributes.ts +++ b/test/types/typescriptDocs/ModelInitNoAttributes.ts @@ -9,9 +9,9 @@ import { Sequelize, Model, DataTypes } from 'sequelize'; const sequelize = new Sequelize('mysql://root:asd123@localhost:3306/mydb'); class User extends Model { - public id!: number; // Note that the `null assertion` `!` is required in strict mode. - public name!: string; - public preferredName!: string | null; // for nullable fields + declare id: number; + declare name: string; + declare preferredName: string | null; } User.init( diff --git a/types/test/update.ts b/test/types/update.ts similarity index 100% rename from types/test/update.ts rename to test/types/update.ts diff --git a/types/test/upsert.ts b/test/types/upsert.ts similarity index 87% rename from types/test/upsert.ts rename to test/types/upsert.ts index 9870b53b83b4..53877d8a5546 100644 --- a/types/test/upsert.ts +++ b/test/types/upsert.ts @@ -43,4 +43,11 @@ sequelize.transaction(async trx => { validate: true, conflictFields: ['foo', 'bar'] }); + + const res4: [TestModel, boolean | null] = await TestModel.upsert({}, { + conflictWhere: { + foo: 'abc', + bar: 'def', + }, + }); }) diff --git a/types/test/usage.ts b/test/types/usage.ts similarity index 100% rename from types/test/usage.ts rename to test/types/usage.ts diff --git a/types/test/validators.ts b/test/types/validators.ts similarity index 100% rename from types/test/validators.ts rename to test/types/validators.ts diff --git a/test/types/where.ts b/test/types/where.ts new file mode 100644 index 000000000000..8b5d92b00a36 --- /dev/null +++ b/test/types/where.ts @@ -0,0 +1,195 @@ +import { expectTypeOf } from 'expect-type'; +import { + AndOperator, + Model, + Op, + OrOperator, + Sequelize, + WhereOptions, + and, + or, + Attributes, + InferAttributes, + Transaction, +} from 'sequelize'; + +// NOTE: most typing tests for WhereOptions are located in test/unit/sql/where.test.ts + +class MyModel extends Model> { + declare id: number; + declare hi: number; + declare name: string; + declare groupId: number | null; +} + +// Optional values +expectTypeOf<{ needed: number; optional?: number }>().toMatchTypeOf(); + +// { +// // @ts-expect-error -- cannot use column references in Op.any +// const a: WhereOptions = { hi: { [Op.eq]: { [Op.any]: [Sequelize.col('SOME_COL')], } } } +// +// // @ts-expect-error -- cannot use column references in Op.any +// const b: WhereOptions = { hi: { [Op.eq]: { [Op.all]: [Sequelize.col('SOME_COL')], } } } +// } + +expectTypeOf({ + [Op.and]: { a: 5 }, // AND (a = 5) +}).toMatchTypeOf(); +expectTypeOf({ + [Op.and]: { a: 5 }, // AND (a = 5) +}).toMatchTypeOf>(); + +expectTypeOf({ + [Op.or]: [{ a: 5 }, { a: 6 }], // (a = 5 OR a = 6) +}).toMatchTypeOf(); +expectTypeOf({ + [Op.or]: [{ a: 5 }, { a: 6 }], // (a = 5 OR a = 6) +}).toMatchTypeOf>(); + +// Relations / Associations +// Find all projects with a least one task where task.state === project.task +MyModel.findAll({ + include: [ + { + model: MyModel, + where: { state: Sequelize.col('project.state') }, + }, + ], +}); + +{ + const where: WhereOptions> = 0 as any; + MyModel.findOne({ + include: [ + { + include: [{ model: MyModel, where }], + model: MyModel, + where, + }, + ], + where, + }); + MyModel.destroy({ where }); + MyModel.update({ hi: 1 }, { where }); + + // Where as having option + MyModel.findAll({ having: where }); +} + +async function test() { + // find multiple entries + let projects: MyModel[] = await MyModel.findAll(); + + // search for specific attributes - hash usage + projects = await MyModel.findAll({ where: { name: 'A MyModel', groupId: null } }); + + // search within a specific range + projects = await MyModel.findAll({ where: { id: [1, 2, 3] } }); + + // locks + projects = await MyModel.findAll({ lock: Transaction.LOCK.KEY_SHARE }); + + // locks on model + projects = await MyModel.findAll({ lock: { level: Transaction.LOCK.KEY_SHARE, of: MyModel } }); +} + +// From https://sequelize.org/master/en/v4/docs/models-usage/ + +const where: WhereOptions = {}; +MyModel.findAll({ + where: and( + where, + or({ id: 1 }, { id: 2 }), + and({ id: 1 }, { id: 2 }), + Sequelize.where(Sequelize.col('col'), Op.eq, null), + Sequelize.literal('1 = 2'), + ), +}); + +MyModel.findAll({ + where: or( + where, + or({ id: 1 }, { id: 2 }), + and({ id: 1 }, { id: 2 }), + Sequelize.where(Sequelize.col('col'), Op.eq, null), + Sequelize.literal('1 = 2'), + ), +}); + +MyModel.findAll({ + where: { + [Op.and]: [ + where, + or({ id: 1 }, { id: 2 }), + and({ id: 1 }, { id: 2 }), + Sequelize.where(Sequelize.col('col'), Op.eq, null), + Sequelize.literal('1 = 2'), + ], + }, +}); + +MyModel.findAll({ + where: { + [Op.or]: [ + where, + or({ id: 1 }, { id: 2 }), + and({ id: 1 }, { id: 2 }), + Sequelize.where(Sequelize.col('col'), Op.eq, null), + Sequelize.literal('1 = 2'), + ], + }, +}); + +MyModel.findAll({ + // implicit "AND" + where: [ + where, + or({ id: 1 }, { id: 2 }), + and({ id: 1 }, { id: 2 }), + Sequelize.where(Sequelize.col('col'), Op.eq, null), + Sequelize.literal('1 = 2'), + ], +}); + +// // TODO [2022-05-26]: TS < 4.4 reports the error in a different location than 4.4 +// // Uncomment test once we remove support for TS 4.3 +// MyModel.findAll({ +// where: { +// id: { +// [Op.in]: { +// // @ts-expect-error - cannot use Operator inside another one! +// [Op.eq]: [1, 2], +// }, +// }, +// }, +// }); +// +// MyModel.findAll({ +// // @ts-expect-error - no attribute +// where: [1, 2], +// }); +// +// // TODO [2022-05-26]: TS < 4.4 does not detect an error here. Uncomment test once we remove support for TS 4.3 +// MyModel.findAll({ +// // @ts-expect-error - no attribute +// where: { [Op.or]: [1, 2] }, +// }); +// +// // TODO [2022-05-26]: TS < 4.4 does not detect an error here. Uncomment test once we remove support for TS 4.3 +// MyModel.findAll({ +// // @ts-expect-error - no attribute +// where: { [Op.and]: { [Op.or]: [1, 2] } }, +// }); +// +// // TODO [2022-05-26]: TS < 4.4 does not detect an error here. Uncomment test once we remove support for TS 4.3 +// MyModel.findAll({ +// where: { +// id: { +// [Op.eq]: { +// // @ts-expect-error - this is not a valid query +// [Op.or]: [1, 2], +// }, +// }, +// }, +// }); diff --git a/test/unit/dialect-module-configuration.test.js b/test/unit/dialect-module-configuration.test.js index 8758d26cd79b..5d6017a6f031 100644 --- a/test/unit/dialect-module-configuration.test.js +++ b/test/unit/dialect-module-configuration.test.js @@ -33,6 +33,7 @@ describe(Support.getTestDialectTeaser('Sequelize'), () => { case 'mssql': dialectPath = path.join(dialectPath, 'tedious'); break; case 'sqlite': dialectPath = path.join(dialectPath, 'sqlite3'); break; case 'snowflake': dialectPath = path.join(dialectPath, 'snowflake-sdk'); break; + case 'oracle': dialectPath = path.join(dialectPath, 'oracledb'); break; default: throw Error('Unsupported dialect'); } diff --git a/test/unit/dialects/abstract/query-generator.test.js b/test/unit/dialects/abstract/query-generator.test.js index 3ed56dd17ba1..d0d69b000058 100644 --- a/test/unit/dialects/abstract/query-generator.test.js +++ b/test/unit/dialects/abstract/query-generator.test.js @@ -4,7 +4,8 @@ const chai = require('chai'), expect = chai.expect, Op = require('../../../../lib/operators'), Support = require('../../support'), - getAbstractQueryGenerator = Support.getAbstractQueryGenerator; + getAbstractQueryGenerator = Support.getAbstractQueryGenerator, + expectsql = Support.expectsql; const AbstractQueryGenerator = require('sequelize/lib/dialects/abstract/query-generator'); describe('QueryGenerator', () => { @@ -120,10 +121,22 @@ describe('QueryGenerator', () => { .should.be.equal('foo IS NOT NULL'); }); - it('should correctly escape $ in sequelize.fn arguments', function() { + it('should correctly escape a single $ in sequelize.fn arguments', function() { const QG = getAbstractQueryGenerator(this.sequelize); - QG.handleSequelizeMethod(this.sequelize.fn('upper', '$user')) - .should.include('$$user'); + const value = QG.handleSequelizeMethod(this.sequelize.fn('upper', '$user')); + expectsql(value, { + mssql: "upper(N'$$user')", + default: "upper('$$user')" + }); + }); + + it('should correctly escape multiple instances of "$" in sequelize.fn arguments', function() { + const QG = getAbstractQueryGenerator(this.sequelize); + const value = QG.handleSequelizeMethod(this.sequelize.fn('upper', '$user and then another $user and some dollars: $42.69')); + expectsql(value, { + mssql: 'upper(N\'$$user and then another $$user and some dollars: $$42.69\')', + default: 'upper(\'$$user and then another $$user and some dollars: $$42.69\')' + }); }); }); @@ -153,6 +166,7 @@ describe('QueryGenerator', () => { mysql: query => expect(query()).to.equal("json_unquote(json_extract(profile,'$.\\\"id\\\"'))"), mssql: query => expect(query).to.throw(Error), snowflake: query => expect(query).to.throw(Error), + oracle: query => expect(query).to.throw(Error), db2: query => expect(query).to.throw(Error) }); }); @@ -166,6 +180,7 @@ describe('QueryGenerator', () => { mysql: query => expect(query()).to.equal("json_unquote(json_extract(profile,'$.\\\"id\\\"'))"), mssql: query => expect(query).to.throw(Error), snowflake: query => expect(query).to.throw(Error), + oracle: query => expect(query).to.throw(Error), db2: query => expect(query).to.throw(Error) }); }); @@ -179,6 +194,7 @@ describe('QueryGenerator', () => { mysql: query => expect(query()).to.equal("json_unquote(json_extract(profile,'$.\\\"id\\\"'))"), mssql: query => expect(query).to.throw(Error), snowflake: query => expect(query).to.throw(Error), + oracle: query => expect(query).to.throw(Error), db2: query => expect(query).to.throw(Error) }); }); diff --git a/test/unit/dialects/abstract/query-interface.test.d.ts b/test/unit/dialects/abstract/query-interface.test.d.ts new file mode 100644 index 000000000000..cb0ff5c3b541 --- /dev/null +++ b/test/unit/dialects/abstract/query-interface.test.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/test/unit/dialects/abstract/query.test.js b/test/unit/dialects/abstract/query.test.js index 321c31b4abf9..291e02ccda18 100644 --- a/test/unit/dialects/abstract/query.test.js +++ b/test/unit/dialects/abstract/query.test.js @@ -16,6 +16,9 @@ describe('[ABSTRACT]', () => { id: { primaryKey: true, type: current.Sequelize.STRING(1) + }, + name: { + type: current.Sequelize.TEXT } }); @@ -64,6 +67,7 @@ describe('[ABSTRACT]', () => { 'players.created': new Date('2017-03-06T15:47:30.000Z'), 'players.lastModified': new Date('2017-03-06T15:47:30.000Z'), 'agents.uuid': agentOneUuid, + name: 'vansh', 'agents.id': 'p', 'agents.name': 'One' }, @@ -73,6 +77,7 @@ describe('[ABSTRACT]', () => { 'players.created': new Date('2017-03-06T15:47:30.000Z'), 'players.lastModified': new Date('2017-08-22T11:16:44.000Z'), 'agents.uuid': agentTwoUuid, + name: 'joe', 'agents.id': 'z', 'agents.name': 'Two' } @@ -83,6 +88,7 @@ describe('[ABSTRACT]', () => { expect(result.length).to.be.equal(1); expect(result[0]).to.have.property('id').and.be.equal('a'); + expect(result[0]).to.have.property('name').and.be.ok; expect(result[0].agents).to.be.deep.equal([ { id: 'p', diff --git a/test/unit/dialects/db2/query-generator.test.js b/test/unit/dialects/db2/query-generator.test.js index 3eec7a5dd51f..1c2e9fb1e08d 100644 --- a/test/unit/dialects/db2/query-generator.test.js +++ b/test/unit/dialects/db2/query-generator.test.js @@ -197,7 +197,7 @@ if (dialect === 'db2') { }, { arguments: ['foo', { attributes: [['count(*)', 'count']] }], expectation: 'SELECT count(*) AS "count" FROM "foo";', - context: QueryGenerator + context: { options: { attributeBehavior: 'unsafe-legacy' } } }, { arguments: ['myTable', { order: ['id'] }], expectation: 'SELECT * FROM "myTable" ORDER BY "id";', diff --git a/test/unit/dialects/mariadb/query-generator.test.js b/test/unit/dialects/mariadb/query-generator.test.js index 4622add40a58..909d2d4cae32 100644 --- a/test/unit/dialects/mariadb/query-generator.test.js +++ b/test/unit/dialects/mariadb/query-generator.test.js @@ -278,7 +278,7 @@ if (dialect === 'mariadb') { }, { arguments: ['foo', { attributes: [['count(*)', 'count']] }], expectation: 'SELECT count(*) AS `count` FROM `foo`;', - context: QueryGenerator + context: { options: { attributeBehavior: 'unsafe-legacy' } } }, { arguments: ['myTable', { order: ['id'] }], expectation: 'SELECT * FROM `myTable` ORDER BY `id`;', diff --git a/test/unit/dialects/mssql/query.test.js b/test/unit/dialects/mssql/query.test.js index 4e35145ba4d4..b59e1f7dccce 100644 --- a/test/unit/dialects/mssql/query.test.js +++ b/test/unit/dialects/mssql/query.test.js @@ -66,19 +66,30 @@ if (dialect === 'mssql') { describe('getSQLTypeFromJsType', () => { const TYPES = tedious.TYPES; it('should return correct parameter type', () => { - expect(query.getSQLTypeFromJsType(2147483647, TYPES)).to.eql({ type: TYPES.Int, typeOptions: {} }); - expect(query.getSQLTypeFromJsType(-2147483648, TYPES)).to.eql({ type: TYPES.Int, typeOptions: {} }); + expect(query.getSQLTypeFromJsType(2147483647, TYPES)).to.eql({ type: TYPES.Int, typeOptions: {}, value: 2147483647 }); + expect(query.getSQLTypeFromJsType(-2147483648, TYPES)).to.eql({ type: TYPES.Int, typeOptions: {}, value: -2147483648 }); - expect(query.getSQLTypeFromJsType(2147483648, TYPES)).to.eql({ type: TYPES.BigInt, typeOptions: {} }); - expect(query.getSQLTypeFromJsType(-2147483649, TYPES)).to.eql({ type: TYPES.BigInt, typeOptions: {} }); + expect(query.getSQLTypeFromJsType(2147483648, TYPES)).to.eql({ type: TYPES.BigInt, typeOptions: {}, value: 2147483648 }); + expect(query.getSQLTypeFromJsType(-2147483649, TYPES)).to.eql({ type: TYPES.BigInt, typeOptions: {}, value: -2147483649 }); - expect(query.getSQLTypeFromJsType(Buffer.from('abc'), TYPES)).to.eql({ type: TYPES.VarBinary, typeOptions: {} }); + expect(query.getSQLTypeFromJsType(2147483647n, TYPES)).to.eql({ type: TYPES.Int, typeOptions: {}, value: 2147483647 }); + expect(query.getSQLTypeFromJsType(-2147483648n, TYPES)).to.eql({ type: TYPES.Int, typeOptions: {}, value: -2147483648 }); + + expect(query.getSQLTypeFromJsType(BigInt(Number.MAX_SAFE_INTEGER), TYPES)).to.eql({ type: TYPES.BigInt, typeOptions: {}, value: Number.MAX_SAFE_INTEGER }); + expect(query.getSQLTypeFromJsType(BigInt(Number.MIN_SAFE_INTEGER), TYPES)).to.eql({ type: TYPES.BigInt, typeOptions: {}, value: Number.MIN_SAFE_INTEGER }); + + const overMaxSafe = BigInt(Number.MAX_SAFE_INTEGER) + 1n; + expect(query.getSQLTypeFromJsType(overMaxSafe, TYPES)).to.eql({ type: TYPES.VarChar, typeOptions: {}, value: overMaxSafe.toString() }); + const underMinSafe = BigInt(Number.MIN_SAFE_INTEGER) - 1n; + expect(query.getSQLTypeFromJsType(underMinSafe, TYPES)).to.eql({ type: TYPES.VarChar, typeOptions: {}, value: underMinSafe.toString() }); + + expect(query.getSQLTypeFromJsType(Buffer.from('abc'), TYPES)).to.eql({ type: TYPES.VarBinary, typeOptions: {}, value: Buffer.from('abc') }); }); it('should return parameter type correct scale for float', () => { - expect(query.getSQLTypeFromJsType(1.23, TYPES)).to.eql({ type: TYPES.Numeric, typeOptions: { precision: 30, scale: 2 } }); - expect(query.getSQLTypeFromJsType(0.30000000000000004, TYPES)).to.eql({ type: TYPES.Numeric, typeOptions: { precision: 30, scale: 17 } }); - expect(query.getSQLTypeFromJsType(2.5e-15, TYPES)).to.eql({ type: TYPES.Numeric, typeOptions: { precision: 30, scale: 16 } }); + expect(query.getSQLTypeFromJsType(1.23, TYPES)).to.eql({ type: TYPES.Numeric, typeOptions: { precision: 30, scale: 2 }, value: 1.23 }); + expect(query.getSQLTypeFromJsType(0.30000000000000004, TYPES)).to.eql({ type: TYPES.Numeric, typeOptions: { precision: 30, scale: 17 }, value: 0.30000000000000004 }); + expect(query.getSQLTypeFromJsType(2.5e-15, TYPES)).to.eql({ type: TYPES.Numeric, typeOptions: { precision: 30, scale: 16 }, value: 2.5e-15 }); }); }); diff --git a/test/unit/dialects/mysql/query-generator.test.js b/test/unit/dialects/mysql/query-generator.test.js index 29a1fab1a5ab..41cd997b32db 100644 --- a/test/unit/dialects/mysql/query-generator.test.js +++ b/test/unit/dialects/mysql/query-generator.test.js @@ -235,7 +235,7 @@ if (dialect === 'mysql') { }, { arguments: ['foo', { attributes: [['count(*)', 'count']] }], expectation: 'SELECT count(*) AS `count` FROM `foo`;', - context: QueryGenerator + context: { options: { attributeBehavior: 'unsafe-legacy' } } }, { arguments: ['myTable', { order: ['id'] }], expectation: 'SELECT * FROM `myTable` ORDER BY `id`;', diff --git a/test/unit/dialects/oracle/query-generator.test.js b/test/unit/dialects/oracle/query-generator.test.js new file mode 100644 index 000000000000..de56e22c69bd --- /dev/null +++ b/test/unit/dialects/oracle/query-generator.test.js @@ -0,0 +1,64 @@ + +'use strict'; + +const Support = require('../../support'), + DataTypes = require('sequelize/lib/data-types'), + expectsql = Support.expectsql, + current = Support.sequelize, + sql = current.dialect.queryGenerator, + sinon = require('sinon'); + +if (current.dialect.name === 'oracle') { + describe('createTable', () => { + const FooUser = current.define('user', { + intCol: { + type: DataTypes.INTEGER.UNSIGNED, + allowNull: false, + defaultValue: 0 + } + }, + { + schema: 'foo', + timestamps: false + }); + + describe('[Oracle Specific] QueryGenerator', () => { + it('checks for values >=0', () => { + expectsql(sql.createTableQuery(FooUser.getTableName(), sql.attributesToSQL(FooUser.rawAttributes), { }), { + default: 'BEGIN EXECUTE IMMEDIATE \'CREATE TABLE "foo"."users" ("id" NUMBER(*,0) GENERATED BY DEFAULT ON NULL AS IDENTITY, "intCol" INTEGER DEFAULT 0 NOT NULL check("intCol" >= 0),PRIMARY KEY ("id"))\'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -955 THEN RAISE; END IF; END;' }); + }); + }); + }); + + // Alter table for blob tries implicit type conversion if datatype is mentioned in SQL, which leads to failure. + describe('changeColumn', () => { + const Model = current.define('items', { + blobCol: { + type: DataTypes.BLOB + } + }, { timestamps: false }); + + before(function() { + this.stub = sinon.stub(current, 'query').resolvesArg(0); + }); + + beforeEach(function() { + this.stub.resetHistory(); + }); + + after(function() { + this.stub.restore(); + }); + + it('properly generate alter queries for BLOB', () => { + return current.getQueryInterface().changeColumn(Model.getTableName(), 'blobCol', { + type: DataTypes.BLOB, + allowNull: false + }).then(sql => { + expectsql(sql, { + oracle: 'DECLARE CONS_NAME VARCHAR2(200); BEGIN BEGIN EXECUTE IMMEDIATE \'ALTER TABLE "items" MODIFY "blobCol" NOT NULL\'; EXCEPTION WHEN OTHERS THEN IF SQLCODE = -1442 OR SQLCODE = -1451 THEN EXECUTE IMMEDIATE \'ALTER TABLE "items" MODIFY "blobCol" \'; ELSE RAISE; END IF; END; END;' + }); + }); + }); + }); +} diff --git a/test/unit/dialects/postgres/query-generator.test.js b/test/unit/dialects/postgres/query-generator.test.js index b907bdb6bf10..d3c6ed1a19fe 100644 --- a/test/unit/dialects/postgres/query-generator.test.js +++ b/test/unit/dialects/postgres/query-generator.test.js @@ -11,6 +11,10 @@ const chai = require('chai'), current = Support.sequelize, _ = require('lodash'); +const customSequelize = Support.createSequelizeInstance({ + schema: 'custom' +}); + if (dialect.startsWith('postgres')) { describe('[POSTGRES Specific] QueryGenerator', () => { const suites = { @@ -302,7 +306,7 @@ if (dialect.startsWith('postgres')) { col_1: "ENUM('value 1', 'value 2') NOT NULL", col_2: "ENUM('value 3', 'value 4') NOT NULL" }], - expectation: 'ALTER TABLE "myTable" ALTER COLUMN "col_1" SET NOT NULL;ALTER TABLE "myTable" ALTER COLUMN "col_1" DROP DEFAULT;CREATE TYPE "public"."enum_myTable_col_1" AS ENUM(\'value 1\', \'value 2\');ALTER TABLE "myTable" ALTER COLUMN "col_1" TYPE "public"."enum_myTable_col_1" USING ("col_1"::"public"."enum_myTable_col_1");ALTER TABLE "myTable" ALTER COLUMN "col_2" SET NOT NULL;ALTER TABLE "myTable" ALTER COLUMN "col_2" DROP DEFAULT;CREATE TYPE "public"."enum_myTable_col_2" AS ENUM(\'value 3\', \'value 4\');ALTER TABLE "myTable" ALTER COLUMN "col_2" TYPE "public"."enum_myTable_col_2" USING ("col_2"::"public"."enum_myTable_col_2");' + expectation: 'ALTER TABLE "myTable" ALTER COLUMN "col_1" SET NOT NULL;ALTER TABLE "myTable" ALTER COLUMN "col_1" DROP DEFAULT;DO \'BEGIN CREATE TYPE "public"."enum_myTable_col_1" AS ENUM(\'\'value 1\'\', \'\'value 2\'\'); EXCEPTION WHEN duplicate_object THEN null; END\';ALTER TABLE "myTable" ALTER COLUMN "col_1" TYPE "public"."enum_myTable_col_1" USING ("col_1"::"public"."enum_myTable_col_1");ALTER TABLE "myTable" ALTER COLUMN "col_2" SET NOT NULL;ALTER TABLE "myTable" ALTER COLUMN "col_2" DROP DEFAULT;DO \'BEGIN CREATE TYPE "public"."enum_myTable_col_2" AS ENUM(\'\'value 3\'\', \'\'value 4\'\'); EXCEPTION WHEN duplicate_object THEN null; END\';ALTER TABLE "myTable" ALTER COLUMN "col_2" TYPE "public"."enum_myTable_col_2" USING ("col_2"::"public"."enum_myTable_col_2");' } ], @@ -327,7 +331,8 @@ if (dialect.startsWith('postgres')) { expectation: 'SELECT * FROM "myTable" WHERE "myTable"."id" = 2;' }, { arguments: ['foo', { attributes: [['count(*)', 'count']] }], - expectation: 'SELECT count(*) AS "count" FROM "foo";' + expectation: 'SELECT count(*) AS "count" FROM "foo";', + context: { options: { attributeBehavior: 'unsafe-legacy' } } }, { arguments: ['myTable', { order: ['id'] }], expectation: 'SELECT * FROM "myTable" ORDER BY "id";', @@ -522,7 +527,7 @@ if (dialect.startsWith('postgres')) { }, { arguments: ['foo', { attributes: [['count(*)', 'count']] }], expectation: 'SELECT count(*) AS count FROM foo;', - context: { options: { quoteIdentifiers: false } } + context: { options: { quoteIdentifiers: false, attributeBehavior: 'unsafe-legacy' } } }, { arguments: ['myTable', { order: ['id DESC'] }], expectation: 'SELECT * FROM myTable ORDER BY id DESC;', @@ -1201,49 +1206,102 @@ if (dialect.startsWith('postgres')) { } ], + getForeignKeyReferencesQuery: [ + { + arguments: ['myTable', 'myDatabase'], + expectation: 'SELECT ' + + 'DISTINCT tc.constraint_name as constraint_name, ' + + 'tc.constraint_schema as constraint_schema, ' + + 'tc.constraint_catalog as constraint_catalog, ' + + 'tc.table_name as table_name,' + + 'tc.table_schema as table_schema,' + + 'tc.table_catalog as table_catalog,' + + 'tc.initially_deferred as initially_deferred,' + + 'tc.is_deferrable as is_deferrable,' + + 'kcu.column_name as column_name,' + + 'ccu.table_schema AS referenced_table_schema,' + + 'ccu.table_catalog AS referenced_table_catalog,' + + 'ccu.table_name AS referenced_table_name,' + + 'ccu.column_name AS referenced_column_name ' + + 'FROM information_schema.table_constraints AS tc ' + + 'JOIN information_schema.key_column_usage AS kcu ' + + 'ON tc.constraint_name = kcu.constraint_name ' + + 'JOIN information_schema.constraint_column_usage AS ccu ' + + 'ON ccu.constraint_name = tc.constraint_name ' + + 'WHERE constraint_type = \'FOREIGN KEY\' AND tc.table_name = \'myTable\' AND tc.table_catalog = \'myDatabase\'' + }, + { + arguments: ['myTable', 'myDatabase', 'mySchema'], + expectation: 'SELECT ' + + 'DISTINCT tc.constraint_name as constraint_name, ' + + 'tc.constraint_schema as constraint_schema, ' + + 'tc.constraint_catalog as constraint_catalog, ' + + 'tc.table_name as table_name,' + + 'tc.table_schema as table_schema,' + + 'tc.table_catalog as table_catalog,' + + 'tc.initially_deferred as initially_deferred,' + + 'tc.is_deferrable as is_deferrable,' + + 'kcu.column_name as column_name,' + + 'ccu.table_schema AS referenced_table_schema,' + + 'ccu.table_catalog AS referenced_table_catalog,' + + 'ccu.table_name AS referenced_table_name,' + + 'ccu.column_name AS referenced_column_name ' + + 'FROM information_schema.table_constraints AS tc ' + + 'JOIN information_schema.key_column_usage AS kcu ' + + 'ON tc.constraint_name = kcu.constraint_name ' + + 'JOIN information_schema.constraint_column_usage AS ccu ' + + 'ON ccu.constraint_name = tc.constraint_name ' + + 'WHERE constraint_type = \'FOREIGN KEY\' AND tc.table_name = \'myTable\' AND tc.table_catalog = \'myDatabase\' AND tc.table_schema = \'mySchema\'' + } + ], + getForeignKeyReferenceQuery: [ { arguments: ['myTable', 'myColumn'], expectation: 'SELECT ' + - 'DISTINCT tc.constraint_name as constraint_name, ' + - 'tc.constraint_schema as constraint_schema, ' + - 'tc.constraint_catalog as constraint_catalog, ' + - 'tc.table_name as table_name,' + - 'tc.table_schema as table_schema,' + - 'tc.table_catalog as table_catalog,' + - 'kcu.column_name as column_name,' + - 'ccu.table_schema AS referenced_table_schema,' + - 'ccu.table_catalog AS referenced_table_catalog,' + - 'ccu.table_name AS referenced_table_name,' + - 'ccu.column_name AS referenced_column_name ' + + 'DISTINCT tc.constraint_name as constraint_name, ' + + 'tc.constraint_schema as constraint_schema, ' + + 'tc.constraint_catalog as constraint_catalog, ' + + 'tc.table_name as table_name,' + + 'tc.table_schema as table_schema,' + + 'tc.table_catalog as table_catalog,' + + 'tc.initially_deferred as initially_deferred,' + + 'tc.is_deferrable as is_deferrable,' + + 'kcu.column_name as column_name,' + + 'ccu.table_schema AS referenced_table_schema,' + + 'ccu.table_catalog AS referenced_table_catalog,' + + 'ccu.table_name AS referenced_table_name,' + + 'ccu.column_name AS referenced_column_name ' + 'FROM information_schema.table_constraints AS tc ' + - 'JOIN information_schema.key_column_usage AS kcu ' + - 'ON tc.constraint_name = kcu.constraint_name ' + - 'JOIN information_schema.constraint_column_usage AS ccu ' + - 'ON ccu.constraint_name = tc.constraint_name ' + + 'JOIN information_schema.key_column_usage AS kcu ' + + 'ON tc.constraint_name = kcu.constraint_name ' + + 'JOIN information_schema.constraint_column_usage AS ccu ' + + 'ON ccu.constraint_name = tc.constraint_name ' + 'WHERE constraint_type = \'FOREIGN KEY\' AND tc.table_name=\'myTable\' AND kcu.column_name = \'myColumn\'' }, { arguments: [{ schema: 'mySchema', tableName: 'myTable' }, 'myColumn'], expectation: 'SELECT ' + - 'DISTINCT tc.constraint_name as constraint_name, ' + - 'tc.constraint_schema as constraint_schema, ' + - 'tc.constraint_catalog as constraint_catalog, ' + - 'tc.table_name as table_name,' + - 'tc.table_schema as table_schema,' + - 'tc.table_catalog as table_catalog,' + - 'kcu.column_name as column_name,' + - 'ccu.table_schema AS referenced_table_schema,' + - 'ccu.table_catalog AS referenced_table_catalog,' + - 'ccu.table_name AS referenced_table_name,' + - 'ccu.column_name AS referenced_column_name ' + + 'DISTINCT tc.constraint_name as constraint_name, ' + + 'tc.constraint_schema as constraint_schema, ' + + 'tc.constraint_catalog as constraint_catalog, ' + + 'tc.table_name as table_name,' + + 'tc.table_schema as table_schema,' + + 'tc.table_catalog as table_catalog,' + + 'tc.initially_deferred as initially_deferred,' + + 'tc.is_deferrable as is_deferrable,' + + 'kcu.column_name as column_name,' + + 'ccu.table_schema AS referenced_table_schema,' + + 'ccu.table_catalog AS referenced_table_catalog,' + + 'ccu.table_name AS referenced_table_name,' + + 'ccu.column_name AS referenced_column_name ' + 'FROM information_schema.table_constraints AS tc ' + - 'JOIN information_schema.key_column_usage AS kcu ' + - 'ON tc.constraint_name = kcu.constraint_name ' + - 'JOIN information_schema.constraint_column_usage AS ccu ' + - 'ON ccu.constraint_name = tc.constraint_name ' + + 'JOIN information_schema.key_column_usage AS kcu ' + + 'ON tc.constraint_name = kcu.constraint_name ' + + 'JOIN information_schema.constraint_column_usage AS ccu ' + + 'ON ccu.constraint_name = tc.constraint_name ' + 'WHERE constraint_type = \'FOREIGN KEY\' AND tc.table_name=\'myTable\' AND kcu.column_name = \'myColumn\'' + - ' AND tc.table_schema = \'mySchema\'' + ' AND tc.table_schema = \'mySchema\'' } ] }; @@ -1315,5 +1373,40 @@ if (dialect.startsWith('postgres')) { }); }); }); + + describe('With custom schema in Sequelize options', () => { + beforeEach(function() { + this.queryGenerator = new QueryGenerator({ + sequelize: customSequelize, + _dialect: customSequelize.dialect + }); + }); + + const customSchemaSuites = { + showTablesQuery: [ + { + title: 'showTablesQuery defaults to the schema set in Sequelize options', + arguments: [], + expectation: 'SELECT table_name FROM information_schema.tables WHERE table_schema = \'custom\' AND table_type LIKE \'%TABLE\' AND table_name != \'spatial_ref_sys\';' + } + ], + describeTableQuery: [ + { + title: 'describeTableQuery defaults to the schema set in Sequelize options', + arguments: ['myTable', null], + expectation: 'SELECT pk.constraint_type as "Constraint",c.column_name as "Field", c.column_default as "Default",c.is_nullable as "Null", (CASE WHEN c.udt_name = \'hstore\' THEN c.udt_name ELSE c.data_type END) || (CASE WHEN c.character_maximum_length IS NOT NULL THEN \'(\' || c.character_maximum_length || \')\' ELSE \'\' END) as "Type", (SELECT array_agg(e.enumlabel) FROM pg_catalog.pg_type t JOIN pg_catalog.pg_enum e ON t.oid=e.enumtypid WHERE t.typname=c.udt_name) AS "special", (SELECT pgd.description FROM pg_catalog.pg_statio_all_tables AS st INNER JOIN pg_catalog.pg_description pgd on (pgd.objoid=st.relid) WHERE c.ordinal_position=pgd.objsubid AND c.table_name=st.relname) AS "Comment" FROM information_schema.columns c LEFT JOIN (SELECT tc.table_schema, tc.table_name, cu.column_name, tc.constraint_type FROM information_schema.TABLE_CONSTRAINTS tc JOIN information_schema.KEY_COLUMN_USAGE cu ON tc.table_schema=cu.table_schema and tc.table_name=cu.table_name and tc.constraint_name=cu.constraint_name and tc.constraint_type=\'PRIMARY KEY\') pk ON pk.table_schema=c.table_schema AND pk.table_name=c.table_name AND pk.column_name=c.column_name WHERE c.table_name = \'myTable\' AND c.table_schema = \'custom\'' + } + ] + }; + + _.each(customSchemaSuites, (customSchemaTests, customSchemaSuiteTitle) => { + for (const customSchemaTest of customSchemaTests) { + it(customSchemaTest.title, function() { + const convertedText = customSchemaTest.arguments ? this.queryGenerator[customSchemaSuiteTitle](...customSchemaTest.arguments) : this.queryGenerator[customSchemaSuiteTitle](); + expect(convertedText).to.equal(customSchemaTest.expectation); + }); + } + }); + }); }); } diff --git a/test/unit/dialects/snowflake/query-generator.test.js b/test/unit/dialects/snowflake/query-generator.test.js index 18abb64a6132..1104d55512dc 100644 --- a/test/unit/dialects/snowflake/query-generator.test.js +++ b/test/unit/dialects/snowflake/query-generator.test.js @@ -345,7 +345,7 @@ if (dialect === 'snowflake') { arguments: ['myTable'], expectation: 'DROP TABLE IF EXISTS "myTable";' }, - + // Variants when quoteIdentifiers is false { arguments: ['myTable'], @@ -354,6 +354,17 @@ if (dialect === 'snowflake') { } ], + tableExistsQuery: [ + { + arguments: ['myTable'], + expectation: 'SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = \'BASE TABLE\' AND TABLE_SCHEMA = CURRENT_SCHEMA() AND TABLE_NAME = \'myTable\';' + }, + { + arguments: [{ tableName: 'myTable', schema: 'mySchema' }], + expectation: 'SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = \'BASE TABLE\' AND TABLE_SCHEMA = \'mySchema\' AND TABLE_NAME = \'myTable\';' + } + ], + selectQuery: [ { arguments: ['myTable'], @@ -382,7 +393,7 @@ if (dialect === 'snowflake') { }, { arguments: ['foo', { attributes: [['count(*)', 'count']] }], expectation: 'SELECT count(*) AS "count" FROM "foo";', - context: QueryGenerator + context: { options: { attributeBehavior: 'unsafe-legacy' } } }, { arguments: ['myTable', { order: ['id'] }], expectation: 'SELECT * FROM "myTable" ORDER BY "id";', @@ -658,7 +669,7 @@ if (dialect === 'snowflake') { }, { arguments: ['foo', { attributes: [['count(*)', 'count']] }], expectation: 'SELECT count(*) AS count FROM foo;', - context: { options: { quoteIdentifiers: false } } + context: { options: { quoteIdentifiers: false, attributeBehavior: 'unsafe-legacy' } } }, { arguments: ['myTable', { order: ['id'] }], expectation: 'SELECT * FROM myTable ORDER BY id;', diff --git a/test/unit/dialects/sqlite/query-generator.test.js b/test/unit/dialects/sqlite/query-generator.test.js index 3ef8d5305d29..9719319721db 100644 --- a/test/unit/dialects/sqlite/query-generator.test.js +++ b/test/unit/dialects/sqlite/query-generator.test.js @@ -187,7 +187,7 @@ if (dialect === 'sqlite') { }, { arguments: ['foo', { attributes: [['count(*)', 'count']] }], expectation: 'SELECT count(*) AS `count` FROM `foo`;', - context: QueryGenerator + context: { options: { attributeBehavior: 'unsafe-legacy' } } }, { arguments: ['myTable', { order: ['id'] }], expectation: 'SELECT * FROM `myTable` ORDER BY `id`;', diff --git a/test/unit/esm-named-exports.test.js b/test/unit/esm-named-exports.test.js index 7afcd627740d..6d23808363aa 100644 --- a/test/unit/esm-named-exports.test.js +++ b/test/unit/esm-named-exports.test.js @@ -46,6 +46,7 @@ describe('ESM module', () => { 'mariadb', 'sqlite', 'snowflake', + 'oracle', 'db2', 'mssql', '_setupHooks', @@ -90,6 +91,8 @@ describe('ESM module', () => { 'afterAssociate', 'beforeConnect', 'afterConnect', + 'beforePoolAcquire', + 'afterPoolAcquire', 'beforeDisconnect', 'afterDisconnect', 'beforeSync', diff --git a/test/unit/logger.test.d.ts b/test/unit/logger.test.d.ts new file mode 100644 index 000000000000..cb0ff5c3b541 --- /dev/null +++ b/test/unit/logger.test.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/test/unit/model/bulk-create.test.js b/test/unit/model/bulk-create.test.js index e7cfa83b0370..a19d3bbffd8a 100644 --- a/test/unit/model/bulk-create.test.js +++ b/test/unit/model/bulk-create.test.js @@ -15,6 +15,11 @@ describe(Support.getTestDialectTeaser('Model'), () => { type: DataTypes.INTEGER(11).UNSIGNED, allowNull: false, field: 'account_id' + }, + purchaseCount: { + type: DataTypes.INTEGER(11).UNSIGNED, + allowNull: false, + underscored: true } }, { timestamps: false }); @@ -32,13 +37,28 @@ describe(Support.getTestDialectTeaser('Model'), () => { describe('validations', () => { it('should not fail for renamed fields', async function() { await this.Model.bulkCreate([ - { accountId: 42 } + { accountId: 42, purchaseCount: 4 } ], { validate: true }); expect(this.stub.getCall(0).args[1]).to.deep.equal([ - { account_id: 42, id: null } + { account_id: 42, purchaseCount: 4, id: null } ]); }); + + if (current.dialect.supports.inserts.updateOnDuplicate) { + it('should map conflictAttributes to column names', async function() { + // Note that the model also has an id key as its primary key. + await this.Model.bulkCreate([{ accountId: 42, purchaseCount: 3 }], { + conflictAttributes: ['accountId'], + updateOnDuplicate: ['purchaseCount'] + }); + + expect( + // Not worth checking that the reference of the array matches - just the contents. + this.stub.getCall(0).args[2].upsertKeys + ).to.deep.equal(['account_id']); + }); + } }); }); }); diff --git a/test/unit/model/scope.test.js b/test/unit/model/scope.test.js index 5af39e2e4ebc..e539f452750d 100644 --- a/test/unit/model/scope.test.js +++ b/test/unit/model/scope.test.js @@ -242,6 +242,242 @@ describe(Support.getTestDialectTeaser('Model'), () => { }); }); + describe('merging scopes using `and` whereMergeStrategy', () => { + const testModelScopes = { + whereAttributeIs1: { + where: { + field: 1 + } + }, + whereAttributeIs2: { + where: { + field: 2 + } + }, + whereAttributeIs3: { + where: { + field: 3 + } + }, + whereOtherAttributeIs4: { + where: { + otherField: 4 + } + }, + whereOpAnd1: { + where: { + [Op.and]: [{ field: 1 }, { field: 1 }] + } + }, + whereOpAnd2: { + where: { + [Op.and]: [{ field: 2 }, { field: 2 }] + } + }, + whereOpAnd3: { + where: { + [Op.and]: [{ field: 3 }, { field: 3 }] + } + }, + whereOpOr1: { + where: { + [Op.or]: [{ field: 1 }, { field: 1 }] + } + }, + whereOpOr2: { + where: { + [Op.or]: [{ field: 2 }, { field: 2 }] + } + }, + whereOpOr3: { + where: { + [Op.or]: [{ field: 3 }, { field: 3 }] + } + }, + whereSequelizeWhere1: { + where: Sequelize.where('field', Op.is, 1) + }, + whereSequelizeWhere2: { + where: Sequelize.where('field', Op.is, 2) + } + }; + + const TestModel = current.define('testModel', {}, { + whereMergeStrategy: 'and', + scopes: testModelScopes + }); + + describe('attributes', () => { + it('should group 2 similar attributes with an Op.and', () => { + const scope = TestModel.scope(['whereAttributeIs1', 'whereAttributeIs2'])._scope; + const expected = { + where: { + [Op.and]: [ + { field: 1 }, + { field: 2 } + ] + } + }; + expect(scope).to.deepEqual(expected); + }); + + it('should group multiple similar attributes with an unique Op.and', () => { + const scope = TestModel.scope(['whereAttributeIs1', 'whereAttributeIs2', 'whereAttributeIs3'])._scope; + const expected = { + where: { + [Op.and]: [ + { field: 1 }, + { field: 2 }, + { field: 3 } + ] + } + }; + expect(scope).to.deepEqual(expected); + }); + + it('should group different attributes with an Op.and', () => { + const scope = TestModel.scope(['whereAttributeIs1', 'whereOtherAttributeIs4'])._scope; + const expected = { + where: { + [Op.and]: [ + { field: 1 }, + { otherField: 4 } + ] + } + }; + expect(scope).to.deepEqual(expected); + }); + }); + + describe('and operators', () => { + it('should concatenate 2 Op.and into an unique one', () => { + const scope = TestModel.scope(['whereOpAnd1', 'whereOpAnd2'])._scope; + const expected = { + where: { + [Op.and]: [ + { field: 1 }, + { field: 1 }, + { field: 2 }, + { field: 2 } + ] + } + }; + expect(scope).to.deepEqual(expected); + }); + + it('should concatenate multiple Op.and into an unique one', () => { + const scope = TestModel.scope(['whereOpAnd1', 'whereOpAnd2', 'whereOpAnd3'])._scope; + const expected = { + where: { + [Op.and]: [ + { field: 1 }, + { field: 1 }, + { field: 2 }, + { field: 2 }, + { field: 3 }, + { field: 3 } + ] + } + }; + expect(scope).to.deepEqual(expected); + }); + }); + + describe('or operators', () => { + it('should group 2 Op.or with an Op.and', () => { + const scope = TestModel.scope(['whereOpOr1', 'whereOpOr2'])._scope; + const expected = { + where: { + [Op.and]: [ + { [Op.or]: [{ field: 1 }, { field: 1 }] }, + { [Op.or]: [{ field: 2 }, { field: 2 }] } + ] + } + }; + expect(scope).to.deepEqual(expected); + }); + + it('should group multiple Op.or with an unique Op.and', () => { + const scope = TestModel.scope(['whereOpOr1', 'whereOpOr2', 'whereOpOr3'])._scope; + const expected = { + where: { + [Op.and]: [ + { [Op.or]: [{ field: 1 }, { field: 1 }] }, + { [Op.or]: [{ field: 2 }, { field: 2 }] }, + { [Op.or]: [{ field: 3 }, { field: 3 }] } + ] + } + }; + expect(scope).to.deepEqual(expected); + }); + + it('should group multiple Op.or and Op.and with an unique Op.and', () => { + const scope = TestModel.scope(['whereOpOr1', 'whereOpOr2', 'whereOpAnd1', 'whereOpAnd2'])._scope; + const expected = { + where: { + [Op.and]: [ + { [Op.or]: [{ field: 1 }, { field: 1 }] }, + { [Op.or]: [{ field: 2 }, { field: 2 }] }, + { field: 1 }, + { field: 1 }, + { field: 2 }, + { field: 2 } + ] + } + }; + expect(scope).to.deepEqual(expected); + }); + + it('should group multiple Op.and and Op.or with an unique Op.and', () => { + const scope = TestModel.scope(['whereOpAnd1', 'whereOpAnd2', 'whereOpOr1', 'whereOpOr2'])._scope; + const expected = { + where: { + [Op.and]: [ + { field: 1 }, + { field: 1 }, + { field: 2 }, + { field: 2 }, + { [Op.or]: [{ field: 1 }, { field: 1 }] }, + { [Op.or]: [{ field: 2 }, { field: 2 }] } + ] + } + }; + expect(scope).to.deepEqual(expected); + }); + }); + + describe('sequelize where', () => { + it('should group 2 sequelize.where with an Op.and', () => { + const scope = TestModel.scope(['whereSequelizeWhere1', 'whereSequelizeWhere2'])._scope; + const expected = { + where: { + [Op.and]: [ + Sequelize.where('field', Op.is, 1), + Sequelize.where('field', Op.is, 2) + ] + } + }; + expect(scope).to.deepEqual(expected); + }); + + it('should group 2 sequelize.where and other scopes with an Op.and', () => { + const scope = TestModel.scope(['whereAttributeIs1', 'whereOpAnd1', 'whereOpOr1', 'whereSequelizeWhere1'])._scope; + const expected = { + where: { + [Op.and]: [ + { field: 1 }, + { field: 1 }, + { field: 1 }, + { [Op.or]: [{ field: 1 }, { field: 1 }] }, + Sequelize.where('field', Op.is, 1) + ] + } + }; + expect(scope).to.deepEqual(expected); + }); + }); + }); + it('should be able to use raw queries', () => { expect(Company.scope([{ method: ['complexFunction', 'qux'] }])._scope).to.deep.equal({ where: ['qux IN (SELECT foobar FROM some_sql_function(foo.bar))'] @@ -494,6 +730,115 @@ describe(Support.getTestDialectTeaser('Model'), () => { expect(options.include[1]).to.deep.equal({ model: User, where: { something: true } }); }); + describe('using `and` whereMergeStrategy', () => { + before(() => { + Sequelize.Model.options = { whereMergeStrategy: 'and' }; + }); + + after(() => { + Sequelize.Model.options = { whereMergeStrategy: 'overwrite' }; + }); + + it('should be able to merge scope and where', () => { + Sequelize.Model._scope = { + where: { something: true, somethingElse: 42 }, + limit: 15, + offset: 3 + }; + const options = { + where: { + something: false + }, + limit: 9 + }; + + Sequelize.Model._injectScope(options); + + expect(options).to.deepEqual({ + where: { + [Op.and]: [ + { something: true, somethingElse: 42 }, + { something: false } + ] + }, + limit: 9, + offset: 3 + }); + }); + + it('should be able to merge scope and having', () => { + Sequelize.Model._scope = { + having: { something: true, somethingElse: 42 }, + limit: 15, + offset: 3 + }; + const options = { + having: { + something: false + }, + limit: 9 + }; + + Sequelize.Model._injectScope(options); + + expect(options).to.deepEqual({ + having: { + [Op.and]: [ + { something: true, somethingElse: 42 }, + { something: false } + ] + }, + limit: 9, + offset: 3 + }); + }); + + it('should be able to merge scopes with the same include', () => { + Sequelize.Model._scope = { + include: [ + { model: Project, where: { something: false, somethingElse: 99 } }, + { model: Project, where: { something: true }, limit: 1 } + ] + }; + const options = {}; + Sequelize.Model._injectScope(options); + + expect(options.include).to.have.length(1); + expect(options.include[0]).to.deepEqual({ + model: Project, + where: { + [Op.and]: [ + { something: false, somethingElse: 99 }, + { something: true } + ] + }, + limit: 1 + }); + }); + + it('should be able to merge scoped include', () => { + Sequelize.Model._scope = { + include: [{ model: Project, where: { something: false, somethingElse: 99 } }] + }; + const options = { + include: [{ model: Project, where: { something: true }, limit: 1 }] + }; + Sequelize.Model._injectScope(options); + + expect(options.include).to.have.length(1); + expect(options.include[0]).to.deepEqual({ + model: Project, + where: { + [Op.and]: [ + { something: false, somethingElse: 99 }, + { something: true } + ] + }, + limit: 1 + }); + }); + }); + describe('include all', () => { it('scope with all', () => { Sequelize.Model._scope = { diff --git a/test/unit/model/update.test.js b/test/unit/model/update.test.js index f11c554cf057..287a69353fcb 100644 --- a/test/unit/model/update.test.js +++ b/test/unit/model/update.test.js @@ -49,4 +49,51 @@ describe(Support.getTestDialectTeaser('Model'), () => { await expect(this.User.update(this.updates, { where: new Where() })).to.be.rejected; }); }); + + describe('Update with multiple models to the same table', () => { + before(function() { + this.Model1 = current.define('Model1', { + value: DataTypes.INTEGER, + name: DataTypes.STRING, + isModel2: DataTypes.BOOLEAN, + model1ExclusiveData: DataTypes.STRING + }, { + tableName: 'model_table' + }); + + this.Model2 = current.define('Model2', { + value: DataTypes.INTEGER, + name: DataTypes.STRING + }, { + tableName: 'model_table' + }); + }); + + beforeEach(function() { + this.stubQuery = sinon.stub(current, 'query').resolves([]); + }); + + afterEach(function() { + this.stubQuery.restore(); + }); + + it('updates model1 using model1 model', async function() { + await this.Model1.update({ + name: 'other name', + model1ExclusiveData: 'only I can update this field' + }, { + where: { value: 1 } + }); + expect(this.stubQuery.lastCall.lastArg.model).to.eq(this.Model1); + }); + + it('updates model2 using model2 model', async function() { + await this.Model2.update({ + name: 'other name' + }, { + where: { value: 2 } + }); + expect(this.stubQuery.lastCall.lastArg.model).to.eq(this.Model2); + }); + }); }); diff --git a/test/unit/query-interface/bulk-delete.test.js b/test/unit/query-interface/bulk-delete.test.js new file mode 100644 index 000000000000..7d2449bda3c6 --- /dev/null +++ b/test/unit/query-interface/bulk-delete.test.js @@ -0,0 +1,38 @@ +const { DataTypes } = require('sequelize'); +const sinon = require('sinon'); +const { expectsql, sequelize } = require('../../support'); +const { stubQueryRun } = require('./stub-query-run'); + +describe('QueryInterface#bulkDelete', () => { + const User = sequelize.define('User', { + firstName: DataTypes.STRING + }, { timestamps: false }); + + afterEach(() => { + sinon.restore(); + }); + + // you'll find more replacement tests in query-generator tests + it('does not parse replacements outside of raw sql', async () => { + const getSql = stubQueryRun(); + + await sequelize.getQueryInterface().bulkDelete( + User.tableName, + { id: ':id' }, + { + logging: console.log, + replacements: { + limit: 1, + id: '123' + } + }, + User + ); + + expectsql(getSql(), { + default: 'DELETE FROM [Users] WHERE [id] = \':id\'', + mssql: 'DELETE FROM [Users] WHERE [id] = N\':id\'; SELECT @@ROWCOUNT AS AFFECTEDROWS;', + snowflake: 'DELETE FROM "Users" WHERE "id" = \':id\';' + }); + }); +}); diff --git a/test/unit/query-interface/bulk-insert.test.js b/test/unit/query-interface/bulk-insert.test.js new file mode 100644 index 000000000000..b9a77b98df28 --- /dev/null +++ b/test/unit/query-interface/bulk-insert.test.js @@ -0,0 +1,34 @@ +const { DataTypes } = require('sequelize'); +const sinon = require('sinon'); +const { expectsql, sequelize } = require('../../support'); +const dialect = require('../support').getTestDialect(); +const { stubQueryRun } = require('./stub-query-run'); + +describe('QueryInterface#bulkInsert', () => { + const User = sequelize.define('User', { + firstName: DataTypes.STRING + }, { timestamps: false }); + + afterEach(() => { + sinon.restore(); + }); + + // you'll find more replacement tests in query-generator tests + // The Oracle dialect doesn't support replacements for bulkInsert + (dialect !== 'oracle' ? it : it.skip)('does not parse replacements outside of raw sql', async () => { + const getSql = stubQueryRun(); + + await sequelize.getQueryInterface().bulkInsert(User.tableName, [{ + firstName: ':injection' + }], { + replacements: { + injection: 'raw sql' + } + }); + + expectsql(getSql(), { + default: 'INSERT INTO [Users] ([firstName]) VALUES (\':injection\');', + mssql: 'INSERT INTO [Users] ([firstName]) VALUES (N\':injection\');' + }); + }); +}); diff --git a/test/unit/query-interface/decrement.test.js b/test/unit/query-interface/decrement.test.js new file mode 100644 index 000000000000..8a0cb1cba311 --- /dev/null +++ b/test/unit/query-interface/decrement.test.js @@ -0,0 +1,45 @@ +const { DataTypes } = require('sequelize'); +const sinon = require('sinon'); +const { expectsql, sequelize } = require('../../support'); +const { stubQueryRun } = require('./stub-query-run'); + +describe('QueryInterface#decrement', () => { + const User = sequelize.define('User', { + firstName: DataTypes.STRING + }, { timestamps: false }); + + afterEach(() => { + sinon.restore(); + }); + + // you'll find more replacement tests in query-generator tests + it('does not parse replacements outside of raw sql', async () => { + const getSql = stubQueryRun(); + + await sequelize.getQueryInterface().decrement( + User, + User.tableName, + // where + { id: ':id' }, + // incrementAmountsByField + { age: ':age' }, + // extraAttributesToBeUpdated + { name: ':name' }, + // options + { + returning: [':data'], + replacements: { + age: 1, + id: 2, + data: 3 + } + } + ); + + expectsql(getSql(), { + default: 'UPDATE [Users] SET [age]=[age]- \':age\',[name]=\':name\' WHERE [id] = \':id\'', + postgres: 'UPDATE "Users" SET "age"="age"- \':age\',"name"=\':name\' WHERE "id" = \':id\' RETURNING ":data"', + mssql: 'UPDATE [Users] SET [age]=[age]- N\':age\',[name]=N\':name\' OUTPUT INSERTED.[:data] WHERE [id] = N\':id\'' + }); + }); +}); diff --git a/test/unit/query-interface/delete.test.js b/test/unit/query-interface/delete.test.js new file mode 100644 index 000000000000..68469dee8dd4 --- /dev/null +++ b/test/unit/query-interface/delete.test.js @@ -0,0 +1,38 @@ +const { DataTypes } = require('sequelize'); +const sinon = require('sinon'); +const { expectsql, sequelize } = require('../../support'); +const { stubQueryRun } = require('./stub-query-run'); + +describe('QueryInterface#delete', () => { + const User = sequelize.define('User', { + firstName: DataTypes.STRING + }, { timestamps: false }); + + afterEach(() => { + sinon.restore(); + }); + + // you'll find more replacement tests in query-generator tests + it('does not parse replacements outside of raw sql', async () => { + const getSql = stubQueryRun(); + const instance = new User(); + + await sequelize.getQueryInterface().delete( + instance, + User.tableName, + { id: ':id' }, + { + replacements: { + limit: 1, + id: '123' + } + } + ); + + expectsql(getSql(), { + default: 'DELETE FROM [Users] WHERE [id] = \':id\'', + mssql: 'DELETE FROM [Users] WHERE [id] = N\':id\'; SELECT @@ROWCOUNT AS AFFECTEDROWS;', + snowflake: 'DELETE FROM "Users" WHERE "id" = \':id\';' + }); + }); +}); diff --git a/test/unit/query-interface/increment.test.js b/test/unit/query-interface/increment.test.js new file mode 100644 index 000000000000..05ab9bedb726 --- /dev/null +++ b/test/unit/query-interface/increment.test.js @@ -0,0 +1,45 @@ +const { DataTypes } = require('sequelize'); +const sinon = require('sinon'); +const { expectsql, sequelize } = require('../../support'); +const { stubQueryRun } = require('./stub-query-run'); + +describe('QueryInterface#increment', () => { + const User = sequelize.define('User', { + firstName: DataTypes.STRING + }, { timestamps: false }); + + afterEach(() => { + sinon.restore(); + }); + + // you'll find more replacement tests in query-generator tests + it('does not parse replacements outside of raw sql', async () => { + const getSql = stubQueryRun(); + + await sequelize.getQueryInterface().increment( + User, + User.tableName, + // where + { id: ':id' }, + // incrementAmountsByField + { age: ':age' }, + // extraAttributesToBeUpdated + { name: ':name' }, + // options + { + returning: [':data'], + replacements: { + age: 1, + id: 2, + data: 3 + } + } + ); + + expectsql(getSql(), { + default: 'UPDATE [Users] SET [age]=[age]+ \':age\',[name]=\':name\' WHERE [id] = \':id\'', + postgres: 'UPDATE "Users" SET "age"="age"+ \':age\',"name"=\':name\' WHERE "id" = \':id\' RETURNING ":data"', + mssql: 'UPDATE [Users] SET [age]=[age]+ N\':age\',[name]=N\':name\' OUTPUT INSERTED.[:data] WHERE [id] = N\':id\'' + }); + }); +}); diff --git a/test/unit/query-interface/raw-select.test.js b/test/unit/query-interface/raw-select.test.js new file mode 100644 index 000000000000..3ec37ec1cb4e --- /dev/null +++ b/test/unit/query-interface/raw-select.test.js @@ -0,0 +1,36 @@ +const { DataTypes } = require('sequelize'); +const sinon = require('sinon'); +const { expectsql, sequelize } = require('../../support'); +const { stubQueryRun } = require('./stub-query-run'); + +describe('QueryInterface#rawSelect', () => { + const User = sequelize.define('User', { + firstName: DataTypes.STRING + }, { timestamps: false }); + + afterEach(() => { + sinon.restore(); + }); + + // you'll find more replacement tests in query-generator tests + it('does not parse user-provided data as replacements', async () => { + const getSql = stubQueryRun(); + + await sequelize.getQueryInterface().rawSelect(User.tableName, { + // @ts-expect-error -- we'll fix the typings when we migrate query-generator to TypeScript + attributes: ['id'], + where: { + username: 'some :data' + }, + replacements: { + data: 'OR \' = ' + } + }, 'id', User); + + expectsql(getSql(), { + default: 'SELECT [id] FROM [Users] AS [User] WHERE [User].[username] = \'some :data\';', + oracle: 'SELECT "id" FROM "Users" "User" WHERE "User"."username" = \'some :data\';', + mssql: 'SELECT [id] FROM [Users] AS [User] WHERE [User].[username] = N\'some :data\';' + }); + }); +}); diff --git a/test/unit/query-interface/select.test.js b/test/unit/query-interface/select.test.js new file mode 100644 index 000000000000..d3968c9bc210 --- /dev/null +++ b/test/unit/query-interface/select.test.js @@ -0,0 +1,36 @@ +const { DataTypes } = require('sequelize'); +const sinon = require('sinon'); +const { expectsql, sequelize } = require('../../support'); +const { stubQueryRun } = require('./stub-query-run'); + +describe('QueryInterface#select', () => { + const User = sequelize.define('User', { + firstName: DataTypes.STRING + }, { timestamps: false }); + + afterEach(() => { + sinon.restore(); + }); + + // you'll find more replacement tests in query-generator tests + it('does not parse user-provided data as replacements', async () => { + const getSql = stubQueryRun(); + + await sequelize.getQueryInterface().select(User, User.tableName, { + // @ts-expect-error -- we'll fix the typings when we migrate query-generator to TypeScript + attributes: ['id'], + where: { + username: 'some :data' + }, + replacements: { + data: 'OR \' = ' + } + }); + + expectsql(getSql(), { + default: 'SELECT [id] FROM [Users] AS [User] WHERE [User].[username] = \'some :data\';', + oracle: 'SELECT "id" FROM "Users" "User" WHERE "User"."username" = \'some :data\';', + mssql: 'SELECT [id] FROM [Users] AS [User] WHERE [User].[username] = N\'some :data\';' + }); + }); +}); diff --git a/test/unit/query-interface/stub-query-run.js b/test/unit/query-interface/stub-query-run.js new file mode 100644 index 000000000000..faa36779fbd9 --- /dev/null +++ b/test/unit/query-interface/stub-query-run.js @@ -0,0 +1,22 @@ +const sinon = require('sinon'); +const { sequelize } = require('../../support'); + +module.exports.stubQueryRun = function stubQueryRun() { + let lastExecutedSql; + + class FakeQuery { + run(sql) { + lastExecutedSql = sql; + + return []; + } + } + + sinon.stub(sequelize.dialect, 'Query').get(() => FakeQuery); + sinon.stub(sequelize.connectionManager, 'getConnection').returns({}); + sinon.stub(sequelize.connectionManager, 'releaseConnection'); + + return () => { + return lastExecutedSql; + }; +}; diff --git a/test/unit/sequelize.test.d.ts b/test/unit/sequelize.test.d.ts new file mode 100644 index 000000000000..cb0ff5c3b541 --- /dev/null +++ b/test/unit/sequelize.test.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/test/unit/sequelize.test.ts b/test/unit/sequelize.test.ts new file mode 100644 index 000000000000..f88b4423c238 --- /dev/null +++ b/test/unit/sequelize.test.ts @@ -0,0 +1,10 @@ +import { expect } from 'chai'; +import { Sequelize } from 'sequelize'; + +describe('Sequelize', () => { + describe('version', () => { + it('should be a string', () => { + expect(typeof Sequelize.version).to.eq('string'); + }); + }); +}); diff --git a/test/unit/sql/add-column.test.js b/test/unit/sql/add-column.test.js index a13f4d7f077d..0e45cde19856 100644 --- a/test/unit/sql/add-column.test.js +++ b/test/unit/sql/add-column.test.js @@ -1,36 +1,40 @@ 'use strict'; -const Support = require('../support'), - DataTypes = require('sequelize/lib/data-types'), - expectsql = Support.expectsql, - current = Support.sequelize, - sql = current.dialect.queryGenerator; +const Support = require('../support'); +const DataTypes = require('sequelize/lib/data-types'); +const expectsql = Support.expectsql; +const current = Support.sequelize; +const sql = current.dialect.queryGenerator; -if (['mysql', 'mariadb'].includes(current.dialect.name)) { - describe(Support.getTestDialectTeaser('SQL'), () => { - describe('addColumn', () => { +const customSequelize = Support.createSequelizeInstance({ + schema: 'custom' +}); +const customSql = customSequelize.dialect.queryGenerator; - const Model = current.define('users', { - id: { - type: DataTypes.INTEGER, - primaryKey: true, - autoIncrement: true - } - }, { timestamps: false }); +describe(Support.getTestDialectTeaser('SQL'), () => { + describe('addColumn', () => { + const User = current.define('User', { + id: { + type: DataTypes.INTEGER, + primaryKey: true, + autoIncrement: true + } + }, { timestamps: false }); + if (['mysql', 'mariadb'].includes(current.dialect.name)) { it('properly generate alter queries', () => { - return expectsql(sql.addColumnQuery(Model.getTableName(), 'level_id', current.normalizeAttribute({ + return expectsql(sql.addColumnQuery(User.getTableName(), 'level_id', current.normalizeAttribute({ type: DataTypes.FLOAT, allowNull: false })), { - mariadb: 'ALTER TABLE `users` ADD `level_id` FLOAT NOT NULL;', - mysql: 'ALTER TABLE `users` ADD `level_id` FLOAT NOT NULL;' + mariadb: 'ALTER TABLE `Users` ADD `level_id` FLOAT NOT NULL;', + mysql: 'ALTER TABLE `Users` ADD `level_id` FLOAT NOT NULL;' }); }); it('properly generate alter queries for foreign keys', () => { - return expectsql(sql.addColumnQuery(Model.getTableName(), 'level_id', current.normalizeAttribute({ + return expectsql(sql.addColumnQuery(User.getTableName(), 'level_id', current.normalizeAttribute({ type: DataTypes.INTEGER, references: { model: 'level', @@ -39,30 +43,80 @@ if (['mysql', 'mariadb'].includes(current.dialect.name)) { onUpdate: 'cascade', onDelete: 'cascade' })), { - mariadb: 'ALTER TABLE `users` ADD `level_id` INTEGER, ADD CONSTRAINT `users_level_id_foreign_idx` FOREIGN KEY (`level_id`) REFERENCES `level` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;', - mysql: 'ALTER TABLE `users` ADD `level_id` INTEGER, ADD CONSTRAINT `users_level_id_foreign_idx` FOREIGN KEY (`level_id`) REFERENCES `level` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;' + mariadb: 'ALTER TABLE `Users` ADD `level_id` INTEGER, ADD CONSTRAINT `Users_level_id_foreign_idx` FOREIGN KEY (`level_id`) REFERENCES `level` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;', + mysql: 'ALTER TABLE `Users` ADD `level_id` INTEGER, ADD CONSTRAINT `Users_level_id_foreign_idx` FOREIGN KEY (`level_id`) REFERENCES `level` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;' }); }); it('properly generate alter queries with FIRST', () => { - return expectsql(sql.addColumnQuery(Model.getTableName(), 'test_added_col_first', current.normalizeAttribute({ + return expectsql(sql.addColumnQuery(User.getTableName(), 'test_added_col_first', current.normalizeAttribute({ type: DataTypes.STRING, first: true })), { - mariadb: 'ALTER TABLE `users` ADD `test_added_col_first` VARCHAR(255) FIRST;', - mysql: 'ALTER TABLE `users` ADD `test_added_col_first` VARCHAR(255) FIRST;' + mariadb: 'ALTER TABLE `Users` ADD `test_added_col_first` VARCHAR(255) FIRST;', + mysql: 'ALTER TABLE `Users` ADD `test_added_col_first` VARCHAR(255) FIRST;' }); }); it('properly generates alter queries with column level comment', () => { - return expectsql(sql.addColumnQuery(Model.getTableName(), 'column_with_comment', current.normalizeAttribute({ + return expectsql(sql.addColumnQuery(User.getTableName(), 'column_with_comment', current.normalizeAttribute({ type: DataTypes.STRING, comment: 'This is a comment' })), { - mariadb: 'ALTER TABLE `users` ADD `column_with_comment` VARCHAR(255) COMMENT \'This is a comment\';', - mysql: 'ALTER TABLE `users` ADD `column_with_comment` VARCHAR(255) COMMENT \'This is a comment\';' + mariadb: 'ALTER TABLE `Users` ADD `column_with_comment` VARCHAR(255) COMMENT \'This is a comment\';', + mysql: 'ALTER TABLE `Users` ADD `column_with_comment` VARCHAR(255) COMMENT \'This is a comment\';' }); }); + } + + it('DEFAULT VALUE FOR BOOLEAN', () => { + return expectsql(sql.addColumnQuery(User.getTableName(), 'bool_col', current.normalizeAttribute({ + type: DataTypes.BOOLEAN, + allowNull: false, + defaultValue: true + })), { + oracle: 'ALTER TABLE "Users" ADD "bool_col" CHAR(1) DEFAULT 1 NOT NULL CHECK ("bool_col" IN(\'1\', \'0\'))', + mysql: 'ALTER TABLE `Users` ADD `bool_col` TINYINT(1) NOT NULL DEFAULT true;', + mariadb: 'ALTER TABLE `Users` ADD `bool_col` TINYINT(1) NOT NULL DEFAULT true;', + mssql: 'ALTER TABLE [Users] ADD [bool_col] BIT NOT NULL DEFAULT 1;', + postgres: 'ALTER TABLE "public"."Users" ADD COLUMN "bool_col" BOOLEAN NOT NULL DEFAULT true;', + db2: 'ALTER TABLE "Users" ADD "bool_col" BOOLEAN NOT NULL DEFAULT true;', + snowflake: 'ALTER TABLE "Users" ADD "bool_col" BOOLEAN NOT NULL DEFAULT true;', + sqlite: 'ALTER TABLE `Users` ADD `bool_col` TINYINT(1) NOT NULL DEFAULT 1;' + }); + }); + + it('DEFAULT VALUE FOR ENUM', () => { + return expectsql(sql.addColumnQuery(User.getTableName(), 'enum_col', current.normalizeAttribute({ + type: DataTypes.ENUM('happy', 'sad'), + allowNull: false, + defaultValue: 'happy' + })), { + oracle: 'ALTER TABLE "Users" ADD "enum_col" VARCHAR2(512) DEFAULT \'happy\' NOT NULL CHECK ("enum_col" IN(\'happy\', \'sad\'))', + mysql: 'ALTER TABLE `Users` ADD `enum_col` ENUM(\'happy\', \'sad\') NOT NULL DEFAULT \'happy\';', + mariadb: 'ALTER TABLE `Users` ADD `enum_col` ENUM(\'happy\', \'sad\') NOT NULL DEFAULT \'happy\';', + mssql: 'ALTER TABLE [Users] ADD [enum_col] VARCHAR(255) CHECK ([enum_col] IN(N\'happy\', N\'sad\'));', + postgres: 'DO \'BEGIN CREATE TYPE "public"."enum_Users_enum_col" AS ENUM(\'\'happy\'\', \'\'sad\'\'); EXCEPTION WHEN duplicate_object THEN null; END\';ALTER TABLE "public"."Users" ADD COLUMN "enum_col" "public"."enum_Users_enum_col" NOT NULL DEFAULT \'happy\';', + db2: 'ALTER TABLE "Users" ADD "enum_col" VARCHAR(255) CHECK ("enum_col" IN(\'happy\', \'sad\')) NOT NULL DEFAULT \'happy\';', + snowflake: 'ALTER TABLE "Users" ADD "enum_col" ENUM NOT NULL DEFAULT \'happy\';', + sqlite: 'ALTER TABLE `Users` ADD `enum_col` TEXT NOT NULL DEFAULT \'happy\';' + }); + }); + + it('defaults the schema to the one set in the Sequelize options', () => { + return expectsql(customSql.addColumnQuery(User.getTableName(), 'level_id', customSequelize.normalizeAttribute({ + type: DataTypes.FLOAT, + allowNull: false + })), { + mariadb: 'ALTER TABLE `Users` ADD `level_id` FLOAT NOT NULL;', + mysql: 'ALTER TABLE `Users` ADD `level_id` FLOAT NOT NULL;', + postgres: 'ALTER TABLE "custom"."Users" ADD COLUMN "level_id" FLOAT NOT NULL;', + sqlite: 'ALTER TABLE `Users` ADD `level_id` FLOAT NOT NULL;', + mssql: 'ALTER TABLE [Users] ADD [level_id] FLOAT NOT NULL;', + db2: 'ALTER TABLE "Users" ADD "level_id" FLOAT NOT NULL;', + snowflake: 'ALTER TABLE "Users" ADD "level_id" FLOAT NOT NULL;', + oracle: 'ALTER TABLE "Users" ADD "level_id" BINARY_FLOAT NOT NULL' + }); }); }); -} +}); diff --git a/test/unit/sql/add-constraint.test.js b/test/unit/sql/add-constraint.test.js index a3e59502a30e..082abe0b36cb 100644 --- a/test/unit/sql/add-constraint.test.js +++ b/test/unit/sql/add-constraint.test.js @@ -107,9 +107,8 @@ if (current.dialect.supports.constraints.addConstraint) { fields: [{ attribute: 'myColumn' }] - })).to.throw('Default value must be specifed for DEFAULT CONSTRAINT'); + })).to.throw('Default value must be specified for DEFAULT CONSTRAINT'); }); - }); } describe('primary key', () => { @@ -171,6 +170,7 @@ if (current.dialect.supports.constraints.addConstraint) { }), { db2: 'ALTER TABLE "myTable" ADD CONSTRAINT "myTable_myColumn_anotherColumn_myOtherTable_fk" FOREIGN KEY ("myColumn", "anotherColumn") REFERENCES "myOtherTable" ("id1", "id2") ON DELETE CASCADE;', + oracle: 'ALTER TABLE "myTable" ADD CONSTRAINT "myTable_myColumn_anotherColumn_myOtherTable_fk" FOREIGN KEY ("myColumn", "anotherColumn") REFERENCES "myOtherTable" ("id1", "id2") ON DELETE CASCADE;', default: 'ALTER TABLE [myTable] ADD CONSTRAINT [myTable_myColumn_anotherColumn_myOtherTable_fk] FOREIGN KEY ([myColumn], [anotherColumn]) REFERENCES [myOtherTable] ([id1], [id2]) ON UPDATE CASCADE ON DELETE CASCADE;' } @@ -189,18 +189,33 @@ if (current.dialect.supports.constraints.addConstraint) { onDelete: 'cascade' }), { db2: 'ALTER TABLE "myTable" ADD CONSTRAINT "myTable_myColumn_myOtherTable_fk" FOREIGN KEY ("myColumn") REFERENCES "myOtherTable" ("id") ON DELETE CASCADE;', + oracle: 'ALTER TABLE "myTable" ADD CONSTRAINT "myTable_myColumn_myOtherTable_fk" FOREIGN KEY ("myColumn") REFERENCES "myOtherTable" ("id") ON DELETE CASCADE;', default: 'ALTER TABLE [myTable] ADD CONSTRAINT [myTable_myColumn_myOtherTable_fk] FOREIGN KEY ([myColumn]) REFERENCES [myOtherTable] ([id]) ON UPDATE CASCADE ON DELETE CASCADE;' }); }); + it('uses onDelete: \'no action\'', () => { + expectsql(sql.addConstraintQuery('myTable', { + type: 'foreign key', + fields: ['myColumn'], + references: { + table: 'myOtherTable', + field: 'id' + }, + onUpdate: 'cascade', + onDelete: 'no action' + }), { + oracle: 'ALTER TABLE "myTable" ADD CONSTRAINT "myTable_myColumn_myOtherTable_fk" FOREIGN KEY ("myColumn") REFERENCES "myOtherTable" ("id");', + default: 'ALTER TABLE [myTable] ADD CONSTRAINT [myTable_myColumn_myOtherTable_fk] FOREIGN KEY ([myColumn]) REFERENCES [myOtherTable] ([id]) ON UPDATE CASCADE ON DELETE NO ACTION;' + }); + }); + it('errors if references object is not passed', () => { expect(sql.addConstraintQuery.bind(sql, 'myTable', { type: 'foreign key', fields: ['myColumn'] })).to.throw('references object with table and field must be specified'); }); - - }); describe('validation', () => { diff --git a/test/unit/sql/change-column.test.js b/test/unit/sql/change-column.test.js index 45b734e5c0b8..e6a89d5ddcbf 100644 --- a/test/unit/sql/change-column.test.js +++ b/test/unit/sql/change-column.test.js @@ -44,6 +44,7 @@ if (current.dialect.name !== 'sqlite') { mariadb: 'ALTER TABLE `users` CHANGE `level_id` `level_id` FLOAT NOT NULL;', mysql: 'ALTER TABLE `users` CHANGE `level_id` `level_id` FLOAT NOT NULL;', postgres: 'ALTER TABLE "users" ALTER COLUMN "level_id" SET NOT NULL;ALTER TABLE "users" ALTER COLUMN "level_id" DROP DEFAULT;ALTER TABLE "users" ALTER COLUMN "level_id" TYPE FLOAT;', + oracle: 'DECLARE CONS_NAME VARCHAR2(200); BEGIN BEGIN EXECUTE IMMEDIATE \'ALTER TABLE "users" MODIFY "level_id" BINARY_FLOAT NOT NULL\'; EXCEPTION WHEN OTHERS THEN IF SQLCODE = -1442 OR SQLCODE = -1451 THEN EXECUTE IMMEDIATE \'ALTER TABLE "users" MODIFY "level_id" BINARY_FLOAT \'; ELSE RAISE; END IF; END; END;', snowflake: 'ALTER TABLE "users" ALTER COLUMN "level_id" SET NOT NULL;ALTER TABLE "users" ALTER COLUMN "level_id" DROP DEFAULT;ALTER TABLE "users" ALTER COLUMN "level_id" TYPE FLOAT;' }); }); @@ -60,6 +61,7 @@ if (current.dialect.name !== 'sqlite') { onDelete: 'cascade' }).then(sql => { expectsql(sql, { + oracle: 'DECLARE CONS_NAME VARCHAR2(200); BEGIN BEGIN SELECT constraint_name INTO cons_name FROM (SELECT DISTINCT cc.owner, cc.table_name, cc.constraint_name, cc.column_name AS cons_columns FROM all_cons_columns cc, all_constraints c WHERE cc.owner = c.owner AND cc.table_name = c.table_name AND cc.constraint_name = c.constraint_name AND c.constraint_type = \'R\' GROUP BY cc.owner, cc.table_name, cc.constraint_name, cc.column_name) WHERE owner = USER AND table_name = \'users\' AND cons_columns = \'level_id\' ; EXCEPTION WHEN NO_DATA_FOUND THEN CONS_NAME := NULL; END; IF CONS_NAME IS NOT NULL THEN EXECUTE IMMEDIATE \'ALTER TABLE "users" DROP CONSTRAINT "\'||CONS_NAME||\'"\'; END IF; EXECUTE IMMEDIATE \'ALTER TABLE "users" ADD FOREIGN KEY ("level_id") REFERENCES "level" ("id") ON DELETE CASCADE\'; END;', mssql: 'ALTER TABLE [users] ADD FOREIGN KEY ([level_id]) REFERENCES [level] ([id]) ON DELETE CASCADE;', db2: 'ALTER TABLE "users" ADD CONSTRAINT "level_id_foreign_idx" FOREIGN KEY ("level_id") REFERENCES "level" ("id") ON DELETE CASCADE;', mariadb: 'ALTER TABLE `users` ADD FOREIGN KEY (`level_id`) REFERENCES `level` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;', diff --git a/test/unit/sql/create-schema.test.js b/test/unit/sql/create-schema.test.js index b7e38cb622b6..4ddf66ed13a8 100644 --- a/test/unit/sql/create-schema.test.js +++ b/test/unit/sql/create-schema.test.js @@ -10,7 +10,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { describe('dropSchema', () => { it('IF EXISTS', () => { expectsql(sql.dropSchema('foo'), { - postgres: 'DROP SCHEMA IF EXISTS foo CASCADE;' + postgres: 'DROP SCHEMA IF EXISTS "foo" CASCADE;' }); }); }); @@ -27,14 +27,14 @@ describe(Support.getTestDialectTeaser('SQL'), () => { it('9.2.0 or above', () => { current.options.databaseVersion = '9.2.0'; expectsql(sql.createSchema('foo'), { - postgres: 'CREATE SCHEMA IF NOT EXISTS foo;' + postgres: 'CREATE SCHEMA IF NOT EXISTS "foo";' }); }); it('below 9.2.0', () => { current.options.databaseVersion = '9.0.0'; expectsql(sql.createSchema('foo'), { - postgres: 'CREATE SCHEMA foo;' + postgres: 'CREATE SCHEMA "foo";' }); }); }); diff --git a/test/unit/sql/create-table.test.js b/test/unit/sql/create-table.test.js index 6fccb8b11e74..de2293060c50 100644 --- a/test/unit/sql/create-table.test.js +++ b/test/unit/sql/create-table.test.js @@ -27,6 +27,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { postgres: 'CREATE TABLE IF NOT EXISTS "foo"."users" ("id" SERIAL , "mood" "foo"."enum_users_mood", PRIMARY KEY ("id"));', mariadb: "CREATE TABLE IF NOT EXISTS `foo`.`users` (`id` INTEGER NOT NULL auto_increment , `mood` ENUM('happy', 'sad'), PRIMARY KEY (`id`)) ENGINE=InnoDB;", mysql: "CREATE TABLE IF NOT EXISTS `foo.users` (`id` INTEGER NOT NULL auto_increment , `mood` ENUM('happy', 'sad'), PRIMARY KEY (`id`)) ENGINE=InnoDB;", + oracle: 'BEGIN EXECUTE IMMEDIATE \'CREATE TABLE "foo"."users" ("id" NUMBER(*,0) GENERATED BY DEFAULT ON NULL AS IDENTITY, "mood" VARCHAR2(512) CHECK ("mood" IN(\'\'happy\'\', \'\'sad\'\')),PRIMARY KEY ("id"))\'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -955 THEN RAISE; END IF; END;', mssql: "IF OBJECT_ID('[foo].[users]', 'U') IS NULL CREATE TABLE [foo].[users] ([id] INTEGER NOT NULL IDENTITY(1,1) , [mood] VARCHAR(255) CHECK ([mood] IN(N'happy', N'sad')), PRIMARY KEY ([id]));" }); }); @@ -52,6 +53,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { it('references right schema when adding foreign key #9029', () => { expectsql(sql.createTableQuery(BarProject.getTableName(), sql.attributesToSQL(BarProject.rawAttributes), { }), { + oracle: 'BEGIN EXECUTE IMMEDIATE \'CREATE TABLE "bar"."projects" ("id" NUMBER(*,0) GENERATED BY DEFAULT ON NULL AS IDENTITY, "user_id" INTEGER NULL,PRIMARY KEY ("id"),FOREIGN KEY ("user_id") REFERENCES "bar"."users" ("id") )\'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -955 THEN RAISE; END IF; END;', sqlite: 'CREATE TABLE IF NOT EXISTS `bar.projects` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `user_id` INTEGER REFERENCES `bar.users` (`id`) ON DELETE NO ACTION ON UPDATE CASCADE);', db2: 'CREATE TABLE "bar"."projects" ("id" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY(START WITH 1, INCREMENT BY 1) , "user_id" INTEGER, PRIMARY KEY ("id"), FOREIGN KEY ("user_id") REFERENCES "bar"."users" ("id") ON DELETE NO ACTION);', postgres: 'CREATE TABLE IF NOT EXISTS "bar"."projects" ("id" SERIAL , "user_id" INTEGER REFERENCES "bar"."users" ("id") ON DELETE NO ACTION ON UPDATE CASCADE, PRIMARY KEY ("id"));', @@ -85,6 +87,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { db2: 'CREATE TABLE "images" ("id" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY(START WITH 1, INCREMENT BY 1) , PRIMARY KEY ("id"), FOREIGN KEY ("id") REFERENCES "files" ("id"));', mariadb: 'CREATE TABLE IF NOT EXISTS `images` (`id` INTEGER auto_increment , PRIMARY KEY (`id`), FOREIGN KEY (`id`) REFERENCES `files` (`id`)) ENGINE=InnoDB;', mysql: 'CREATE TABLE IF NOT EXISTS `images` (`id` INTEGER auto_increment , PRIMARY KEY (`id`), FOREIGN KEY (`id`) REFERENCES `files` (`id`)) ENGINE=InnoDB;', + oracle: 'BEGIN EXECUTE IMMEDIATE \'CREATE TABLE "images" ("id" NUMBER(*,0) GENERATED BY DEFAULT ON NULL AS IDENTITY ,PRIMARY KEY ("id"),FOREIGN KEY ("id") REFERENCES "files" ("id"))\'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -955 THEN RAISE; END IF; END;', mssql: 'IF OBJECT_ID(\'[images]\', \'U\') IS NULL CREATE TABLE [images] ([id] INTEGER IDENTITY(1,1) , PRIMARY KEY ([id]), FOREIGN KEY ([id]) REFERENCES [files] ([id]));' }); }); diff --git a/test/unit/sql/data-types.test.js b/test/unit/sql/data-types.test.js index 2ab7e08f6eb1..17b5436e92dd 100644 --- a/test/unit/sql/data-types.test.js +++ b/test/unit/sql/data-types.test.js @@ -25,17 +25,20 @@ describe(Support.getTestDialectTeaser('SQL'), () => { describe('STRING', () => { testsql('STRING', DataTypes.STRING, { default: 'VARCHAR(255)', - mssql: 'NVARCHAR(255)' + mssql: 'NVARCHAR(255)', + oracle: 'NVARCHAR2(255)' }); testsql('STRING(1234)', DataTypes.STRING(1234), { default: 'VARCHAR(1234)', - mssql: 'NVARCHAR(1234)' + mssql: 'NVARCHAR(1234)', + oracle: 'NVARCHAR2(1234)' }); testsql('STRING({ length: 1234 })', DataTypes.STRING({ length: 1234 }), { default: 'VARCHAR(1234)', - mssql: 'NVARCHAR(1234)' + mssql: 'NVARCHAR(1234)', + oracle: 'NVARCHAR2(1234)' }); testsql('STRING(1234).BINARY', DataTypes.STRING(1234).BINARY, { @@ -43,7 +46,8 @@ describe(Support.getTestDialectTeaser('SQL'), () => { db2: 'VARCHAR(1234) FOR BIT DATA', sqlite: 'VARCHAR BINARY(1234)', mssql: 'BINARY(1234)', - postgres: 'BYTEA' + postgres: 'BYTEA', + oracle: 'RAW(1234)' }); testsql('STRING.BINARY', DataTypes.STRING.BINARY, { @@ -51,7 +55,8 @@ describe(Support.getTestDialectTeaser('SQL'), () => { db2: 'VARCHAR(255) FOR BIT DATA', sqlite: 'VARCHAR BINARY(255)', mssql: 'BINARY(255)', - postgres: 'BYTEA' + postgres: 'BYTEA', + oracle: 'RAW(255)' }); describe('validate', () => { @@ -69,6 +74,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { testsql('TEXT', DataTypes.TEXT, { default: 'TEXT', db2: 'VARCHAR(32672)', + oracle: 'CLOB', mssql: 'NVARCHAR(MAX)' // in mssql text is actually representing a non unicode text field }); @@ -77,6 +83,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { mssql: 'NVARCHAR(256)', db2: 'VARCHAR(256)', mariadb: 'TINYTEXT', + oracle: 'CLOB', mysql: 'TINYTEXT' }); @@ -85,6 +92,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { mssql: 'NVARCHAR(256)', db2: 'VARCHAR(256)', mariadb: 'TINYTEXT', + oracle: 'CLOB', mysql: 'TINYTEXT' }); @@ -93,6 +101,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { mssql: 'NVARCHAR(MAX)', db2: 'VARCHAR(8192)', mariadb: 'MEDIUMTEXT', + oracle: 'CLOB', mysql: 'MEDIUMTEXT' }); @@ -101,6 +110,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { mssql: 'NVARCHAR(MAX)', db2: 'CLOB(65536)', mariadb: 'LONGTEXT', + oracle: 'CLOB', mysql: 'LONGTEXT' }); @@ -136,12 +146,14 @@ describe(Support.getTestDialectTeaser('SQL'), () => { testsql('CHAR(12).BINARY', DataTypes.CHAR(12).BINARY, { default: 'CHAR(12) BINARY', + oracle: 'RAW(12)', sqlite: 'CHAR BINARY(12)', postgres: 'BYTEA' }); testsql('CHAR.BINARY', DataTypes.CHAR.BINARY, { default: 'CHAR(255) BINARY', + oracle: 'RAW(255)', sqlite: 'CHAR BINARY(255)', postgres: 'BYTEA' }); @@ -155,6 +167,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { mariadb: 'TINYINT(1)', mysql: 'TINYINT(1)', sqlite: 'TINYINT(1)', + oracle: 'CHAR(1)', snowflake: 'BOOLEAN' }); @@ -188,6 +201,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { mysql: 'DATETIME', db2: 'TIMESTAMP', sqlite: 'DATETIME', + oracle: 'TIMESTAMP WITH LOCAL TIME ZONE', snowflake: 'TIMESTAMP' }); @@ -198,6 +212,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { mysql: 'DATETIME(6)', db2: 'TIMESTAMP(6)', sqlite: 'DATETIME', + oracle: 'TIMESTAMP WITH LOCAL TIME ZONE', snowflake: 'TIMESTAMP' }); @@ -246,6 +261,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { mariadb: 'CHAR(36) BINARY', mysql: 'CHAR(36) BINARY', sqlite: 'UUID', + oracle: 'VARCHAR2(36)', snowflake: 'VARCHAR(36)' }); @@ -345,6 +361,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { testsql('NOW', DataTypes.NOW, { default: 'NOW', db2: 'CURRENT TIME', + oracle: 'SYSDATE', mssql: 'GETDATE()' }); }); @@ -359,7 +376,8 @@ describe(Support.getTestDialectTeaser('SQL'), () => { postgres: 'INTEGER', db2: 'INTEGER', mssql: 'INTEGER', - sqlite: 'INTEGER' + sqlite: 'INTEGER', + oracle: 'INTEGER' }); testsql('INTEGER.UNSIGNED.ZEROFILL', DataTypes.INTEGER.UNSIGNED.ZEROFILL, { @@ -367,21 +385,24 @@ describe(Support.getTestDialectTeaser('SQL'), () => { postgres: 'INTEGER', db2: 'INTEGER', mssql: 'INTEGER', - sqlite: 'INTEGER' + sqlite: 'INTEGER', + oracle: 'INTEGER' }); testsql('INTEGER(11)', DataTypes.INTEGER(11), { default: 'INTEGER(11)', postgres: 'INTEGER', db2: 'INTEGER', - mssql: 'INTEGER' + mssql: 'INTEGER', + oracle: 'NUMBER(11,0)' }); testsql('INTEGER({ length: 11 })', DataTypes.INTEGER({ length: 11 }), { default: 'INTEGER(11)', postgres: 'INTEGER', db2: 'INTEGER', - mssql: 'INTEGER' + mssql: 'INTEGER', + oracle: 'NUMBER(11,0)' }); testsql('INTEGER(11).UNSIGNED', DataTypes.INTEGER(11).UNSIGNED, { @@ -389,7 +410,8 @@ describe(Support.getTestDialectTeaser('SQL'), () => { sqlite: 'INTEGER(11)', postgres: 'INTEGER', db2: 'INTEGER', - mssql: 'INTEGER' + mssql: 'INTEGER', + oracle: 'NUMBER(11,0)' }); testsql('INTEGER(11).UNSIGNED.ZEROFILL', DataTypes.INTEGER(11).UNSIGNED.ZEROFILL, { @@ -397,7 +419,8 @@ describe(Support.getTestDialectTeaser('SQL'), () => { sqlite: 'INTEGER(11)', postgres: 'INTEGER', db2: 'INTEGER', - mssql: 'INTEGER' + mssql: 'INTEGER', + oracle: 'NUMBER(11,0)' }); testsql('INTEGER(11).ZEROFILL', DataTypes.INTEGER(11).ZEROFILL, { @@ -405,7 +428,8 @@ describe(Support.getTestDialectTeaser('SQL'), () => { sqlite: 'INTEGER(11)', postgres: 'INTEGER', db2: 'INTEGER', - mssql: 'INTEGER' + mssql: 'INTEGER', + oracle: 'NUMBER(11,0)' }); testsql('INTEGER(11).ZEROFILL.UNSIGNED', DataTypes.INTEGER(11).ZEROFILL.UNSIGNED, { @@ -413,7 +437,8 @@ describe(Support.getTestDialectTeaser('SQL'), () => { sqlite: 'INTEGER(11)', postgres: 'INTEGER', db2: 'INTEGER', - mssql: 'INTEGER' + mssql: 'INTEGER', + oracle: 'NUMBER(11,0)' }); describe('validate', () => { @@ -448,6 +473,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { title: 'TINYINT', dataType: DataTypes.TINYINT, expect: { + oracle: 'NUMBER(3)', default: 'TINYINT' } }, @@ -457,6 +483,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { expect: { default: 'TINYINT(2)', db2: 'TINYINT', + oracle: 'NUMBER(3)', mssql: 'TINYINT', postgres: 'TINYINT' } @@ -467,6 +494,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { expect: { default: 'TINYINT(2)', db2: 'TINYINT', + oracle: 'NUMBER(3)', mssql: 'TINYINT', postgres: 'TINYINT' } @@ -477,6 +505,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { expect: { default: 'TINYINT UNSIGNED', db2: 'TINYINT', + oracle: 'NUMBER(3)', mssql: 'TINYINT', postgres: 'TINYINT', sqlite: 'TINYINT' @@ -488,6 +517,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { expect: { default: 'TINYINT(2) UNSIGNED', db2: 'TINYINT', + oracle: 'NUMBER(3)', sqlite: 'TINYINT(2)', mssql: 'TINYINT', postgres: 'TINYINT' @@ -499,6 +529,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { expect: { default: 'TINYINT UNSIGNED ZEROFILL', db2: 'TINYINT', + oracle: 'NUMBER(3)', mssql: 'TINYINT', postgres: 'TINYINT', sqlite: 'TINYINT' @@ -510,6 +541,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { expect: { default: 'TINYINT(2) UNSIGNED ZEROFILL', db2: 'TINYINT', + oracle: 'NUMBER(3)', sqlite: 'TINYINT(2)', mssql: 'TINYINT', postgres: 'TINYINT' @@ -521,6 +553,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { expect: { default: 'TINYINT ZEROFILL', db2: 'TINYINT', + oracle: 'NUMBER(3)', mssql: 'TINYINT', postgres: 'TINYINT', sqlite: 'TINYINT' @@ -532,6 +565,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { expect: { default: 'TINYINT(2) ZEROFILL', db2: 'TINYINT', + oracle: 'NUMBER(3)', sqlite: 'TINYINT(2)', mssql: 'TINYINT', postgres: 'TINYINT' @@ -543,6 +577,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { expect: { default: 'TINYINT UNSIGNED ZEROFILL', db2: 'TINYINT', + oracle: 'NUMBER(3)', mssql: 'TINYINT', postgres: 'TINYINT', sqlite: 'TINYINT' @@ -554,6 +589,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { expect: { default: 'TINYINT(2) UNSIGNED ZEROFILL', db2: 'TINYINT', + oracle: 'NUMBER(3)', sqlite: 'TINYINT(2)', mssql: 'TINYINT', postgres: 'TINYINT' @@ -600,6 +636,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { dataType: DataTypes.SMALLINT(4), expect: { default: 'SMALLINT(4)', + oracle: 'NUMBER(4,0)', postgres: 'SMALLINT', db2: 'SMALLINT', mssql: 'SMALLINT' @@ -610,6 +647,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { dataType: DataTypes.SMALLINT({ length: 4 }), expect: { default: 'SMALLINT(4)', + oracle: 'NUMBER(4,0)', postgres: 'SMALLINT', db2: 'SMALLINT', mssql: 'SMALLINT' @@ -620,6 +658,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { dataType: DataTypes.SMALLINT.UNSIGNED, expect: { default: 'SMALLINT UNSIGNED', + oracle: 'SMALLINT', postgres: 'SMALLINT', db2: 'SMALLINT', mssql: 'SMALLINT', @@ -631,6 +670,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { dataType: DataTypes.SMALLINT(4).UNSIGNED, expect: { default: 'SMALLINT(4) UNSIGNED', + oracle: 'NUMBER(4,0)', sqlite: 'SMALLINT(4)', postgres: 'SMALLINT', db2: 'SMALLINT', @@ -642,6 +682,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { dataType: DataTypes.SMALLINT.UNSIGNED.ZEROFILL, expect: { default: 'SMALLINT UNSIGNED ZEROFILL', + oracle: 'SMALLINT', postgres: 'SMALLINT', db2: 'SMALLINT', mssql: 'SMALLINT', @@ -653,6 +694,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { dataType: DataTypes.SMALLINT(4).UNSIGNED.ZEROFILL, expect: { default: 'SMALLINT(4) UNSIGNED ZEROFILL', + oracle: 'NUMBER(4,0)', sqlite: 'SMALLINT(4)', postgres: 'SMALLINT', db2: 'SMALLINT', @@ -664,6 +706,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { dataType: DataTypes.SMALLINT.ZEROFILL, expect: { default: 'SMALLINT ZEROFILL', + oracle: 'SMALLINT', postgres: 'SMALLINT', db2: 'SMALLINT', mssql: 'SMALLINT', @@ -675,6 +718,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { dataType: DataTypes.SMALLINT(4).ZEROFILL, expect: { default: 'SMALLINT(4) ZEROFILL', + oracle: 'NUMBER(4,0)', sqlite: 'SMALLINT(4)', postgres: 'SMALLINT', db2: 'SMALLINT', @@ -686,6 +730,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { dataType: DataTypes.SMALLINT.ZEROFILL.UNSIGNED, expect: { default: 'SMALLINT UNSIGNED ZEROFILL', + oracle: 'SMALLINT', postgres: 'SMALLINT', db2: 'SMALLINT', mssql: 'SMALLINT', @@ -697,6 +742,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { dataType: DataTypes.SMALLINT(4).ZEROFILL.UNSIGNED, expect: { default: 'SMALLINT(4) UNSIGNED ZEROFILL', + oracle: 'NUMBER(4,0)', sqlite: 'SMALLINT(4)', postgres: 'SMALLINT', db2: 'SMALLINT', @@ -736,6 +782,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { title: 'MEDIUMINT', dataType: DataTypes.MEDIUMINT, expect: { + oracle: 'NUMBER(8)', default: 'MEDIUMINT' } }, @@ -743,6 +790,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { title: 'MEDIUMINT(6)', dataType: DataTypes.MEDIUMINT(6), expect: { + oracle: 'NUMBER(8)', default: 'MEDIUMINT(6)' } }, @@ -750,6 +798,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { title: 'MEDIUMINT({ length: 6 })', dataType: DataTypes.MEDIUMINT({ length: 6 }), expect: { + oracle: 'NUMBER(8)', default: 'MEDIUMINT(6)' } }, @@ -758,6 +807,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { dataType: DataTypes.MEDIUMINT.UNSIGNED, expect: { default: 'MEDIUMINT UNSIGNED', + oracle: 'NUMBER(8)', sqlite: 'MEDIUMINT' } }, @@ -766,6 +816,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { dataType: DataTypes.MEDIUMINT(6).UNSIGNED, expect: { default: 'MEDIUMINT(6) UNSIGNED', + oracle: 'NUMBER(8)', sqlite: 'MEDIUMINT(6)' } }, @@ -774,6 +825,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { dataType: DataTypes.MEDIUMINT.UNSIGNED.ZEROFILL, expect: { default: 'MEDIUMINT UNSIGNED ZEROFILL', + oracle: 'NUMBER(8)', sqlite: 'MEDIUMINT' } }, @@ -782,6 +834,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { dataType: DataTypes.MEDIUMINT(6).UNSIGNED.ZEROFILL, expect: { default: 'MEDIUMINT(6) UNSIGNED ZEROFILL', + oracle: 'NUMBER(8)', sqlite: 'MEDIUMINT(6)' } }, @@ -790,6 +843,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { dataType: DataTypes.MEDIUMINT.ZEROFILL, expect: { default: 'MEDIUMINT ZEROFILL', + oracle: 'NUMBER(8)', sqlite: 'MEDIUMINT' } }, @@ -798,6 +852,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { dataType: DataTypes.MEDIUMINT(6).ZEROFILL, expect: { default: 'MEDIUMINT(6) ZEROFILL', + oracle: 'NUMBER(8)', sqlite: 'MEDIUMINT(6)' } }, @@ -806,6 +861,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { dataType: DataTypes.MEDIUMINT.ZEROFILL.UNSIGNED, expect: { default: 'MEDIUMINT UNSIGNED ZEROFILL', + oracle: 'NUMBER(8)', sqlite: 'MEDIUMINT' } }, @@ -814,6 +870,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { dataType: DataTypes.MEDIUMINT(6).ZEROFILL.UNSIGNED, expect: { default: 'MEDIUMINT(6) UNSIGNED ZEROFILL', + oracle: 'NUMBER(8)', sqlite: 'MEDIUMINT(6)' } } @@ -846,7 +903,8 @@ describe(Support.getTestDialectTeaser('SQL'), () => { describe('BIGINT', () => { testsql('BIGINT', DataTypes.BIGINT, { - default: 'BIGINT' + default: 'BIGINT', + oracle: 'NUMBER(19)' }); testsql('BIGINT.UNSIGNED', DataTypes.BIGINT.UNSIGNED, { @@ -854,7 +912,8 @@ describe(Support.getTestDialectTeaser('SQL'), () => { postgres: 'BIGINT', db2: 'BIGINT', mssql: 'BIGINT', - sqlite: 'BIGINT' + sqlite: 'BIGINT', + oracle: 'NUMBER(19)' }); testsql('BIGINT.UNSIGNED.ZEROFILL', DataTypes.BIGINT.UNSIGNED.ZEROFILL, { @@ -862,13 +921,15 @@ describe(Support.getTestDialectTeaser('SQL'), () => { postgres: 'BIGINT', db2: 'BIGINT', mssql: 'BIGINT', - sqlite: 'BIGINT' + sqlite: 'BIGINT', + oracle: 'NUMBER(19)' }); testsql('BIGINT(11)', DataTypes.BIGINT(11), { default: 'BIGINT(11)', postgres: 'BIGINT', db2: 'BIGINT', + oracle: 'NUMBER(19)', mssql: 'BIGINT' }); @@ -876,6 +937,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { default: 'BIGINT(11)', postgres: 'BIGINT', db2: 'BIGINT', + oracle: 'NUMBER(19)', mssql: 'BIGINT' }); @@ -884,6 +946,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { sqlite: 'BIGINT(11)', postgres: 'BIGINT', db2: 'BIGINT', + oracle: 'NUMBER(19)', mssql: 'BIGINT' }); @@ -892,6 +955,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { sqlite: 'BIGINT(11)', postgres: 'BIGINT', db2: 'BIGINT', + oracle: 'NUMBER(19)', mssql: 'BIGINT' }); @@ -900,6 +964,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { sqlite: 'BIGINT(11)', postgres: 'BIGINT', db2: 'BIGINT', + oracle: 'NUMBER(19)', mssql: 'BIGINT' }); @@ -908,6 +973,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { sqlite: 'BIGINT(11)', postgres: 'BIGINT', db2: 'BIGINT', + oracle: 'NUMBER(19)', mssql: 'BIGINT' }); @@ -934,6 +1000,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { describe('REAL', () => { testsql('REAL', DataTypes.REAL, { + oracle: 'BINARY_DOUBLE', default: 'REAL' }); @@ -941,6 +1008,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { default: 'REAL UNSIGNED', postgres: 'REAL', db2: 'REAL', + oracle: 'BINARY_DOUBLE', mssql: 'REAL' }); @@ -948,6 +1016,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { default: 'REAL(11)', postgres: 'REAL', db2: 'REAL', + oracle: 'BINARY_DOUBLE', mssql: 'REAL' }); @@ -955,6 +1024,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { default: 'REAL(11)', postgres: 'REAL', db2: 'REAL', + oracle: 'BINARY_DOUBLE', mssql: 'REAL' }); @@ -963,6 +1033,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { sqlite: 'REAL UNSIGNED(11)', postgres: 'REAL', db2: 'REAL', + oracle: 'BINARY_DOUBLE', mssql: 'REAL' }); @@ -971,6 +1042,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { sqlite: 'REAL UNSIGNED ZEROFILL(11)', postgres: 'REAL', db2: 'REAL', + oracle: 'BINARY_DOUBLE', mssql: 'REAL' }); @@ -979,6 +1051,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { sqlite: 'REAL ZEROFILL(11)', postgres: 'REAL', db2: 'REAL', + oracle: 'BINARY_DOUBLE', mssql: 'REAL' }); @@ -987,6 +1060,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { sqlite: 'REAL UNSIGNED ZEROFILL(11)', postgres: 'REAL', db2: 'REAL', + oracle: 'BINARY_DOUBLE', mssql: 'REAL' }); @@ -994,6 +1068,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { default: 'REAL(11,12)', postgres: 'REAL', db2: 'REAL', + oracle: 'BINARY_DOUBLE', mssql: 'REAL' }); @@ -1002,6 +1077,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { sqlite: 'REAL UNSIGNED(11,12)', postgres: 'REAL', db2: 'REAL', + oracle: 'BINARY_DOUBLE', mssql: 'REAL' }); @@ -1010,6 +1086,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { sqlite: 'REAL UNSIGNED(11,12)', postgres: 'REAL', db2: 'REAL', + oracle: 'BINARY_DOUBLE', mssql: 'REAL' }); @@ -1018,6 +1095,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { sqlite: 'REAL UNSIGNED ZEROFILL(11,12)', postgres: 'REAL', db2: 'REAL', + oracle: 'BINARY_DOUBLE', mssql: 'REAL' }); @@ -1026,6 +1104,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { sqlite: 'REAL ZEROFILL(11,12)', postgres: 'REAL', db2: 'REAL', + oracle: 'BINARY_DOUBLE', mssql: 'REAL' }); @@ -1034,6 +1113,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { sqlite: 'REAL UNSIGNED ZEROFILL(11,12)', postgres: 'REAL', db2: 'REAL', + oracle: 'BINARY_DOUBLE', mssql: 'REAL' }); }); @@ -1041,18 +1121,21 @@ describe(Support.getTestDialectTeaser('SQL'), () => { describe('DOUBLE PRECISION', () => { testsql('DOUBLE', DataTypes.DOUBLE, { db2: 'DOUBLE', + oracle: 'BINARY_DOUBLE', default: 'DOUBLE PRECISION' }); testsql('DOUBLE.UNSIGNED', DataTypes.DOUBLE.UNSIGNED, { default: 'DOUBLE PRECISION UNSIGNED', db2: 'DOUBLE', + oracle: 'BINARY_DOUBLE', postgres: 'DOUBLE PRECISION' }); testsql('DOUBLE(11)', DataTypes.DOUBLE(11), { default: 'DOUBLE PRECISION(11)', db2: 'DOUBLE', + oracle: 'BINARY_DOUBLE', postgres: 'DOUBLE PRECISION' }); @@ -1060,6 +1143,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { default: 'DOUBLE PRECISION(11) UNSIGNED', sqlite: 'DOUBLE PRECISION UNSIGNED(11)', db2: 'DOUBLE', + oracle: 'BINARY_DOUBLE', postgres: 'DOUBLE PRECISION' }); @@ -1067,6 +1151,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { default: 'DOUBLE PRECISION(11) UNSIGNED', sqlite: 'DOUBLE PRECISION UNSIGNED(11)', db2: 'DOUBLE', + oracle: 'BINARY_DOUBLE', postgres: 'DOUBLE PRECISION' }); @@ -1074,6 +1159,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { default: 'DOUBLE PRECISION(11) UNSIGNED ZEROFILL', sqlite: 'DOUBLE PRECISION UNSIGNED ZEROFILL(11)', db2: 'DOUBLE', + oracle: 'BINARY_DOUBLE', postgres: 'DOUBLE PRECISION' }); @@ -1081,6 +1167,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { default: 'DOUBLE PRECISION(11) ZEROFILL', sqlite: 'DOUBLE PRECISION ZEROFILL(11)', db2: 'DOUBLE', + oracle: 'BINARY_DOUBLE', postgres: 'DOUBLE PRECISION' }); @@ -1088,12 +1175,14 @@ describe(Support.getTestDialectTeaser('SQL'), () => { default: 'DOUBLE PRECISION(11) UNSIGNED ZEROFILL', sqlite: 'DOUBLE PRECISION UNSIGNED ZEROFILL(11)', db2: 'DOUBLE', + oracle: 'BINARY_DOUBLE', postgres: 'DOUBLE PRECISION' }); testsql('DOUBLE(11, 12)', DataTypes.DOUBLE(11, 12), { default: 'DOUBLE PRECISION(11,12)', db2: 'DOUBLE', + oracle: 'BINARY_DOUBLE', postgres: 'DOUBLE PRECISION' }); @@ -1101,6 +1190,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { default: 'DOUBLE PRECISION(11,12) UNSIGNED', sqlite: 'DOUBLE PRECISION UNSIGNED(11,12)', db2: 'DOUBLE', + oracle: 'BINARY_DOUBLE', postgres: 'DOUBLE PRECISION' }); @@ -1108,6 +1198,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { default: 'DOUBLE PRECISION(11,12) UNSIGNED ZEROFILL', sqlite: 'DOUBLE PRECISION UNSIGNED ZEROFILL(11,12)', db2: 'DOUBLE', + oracle: 'BINARY_DOUBLE', postgres: 'DOUBLE PRECISION' }); @@ -1115,6 +1206,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { default: 'DOUBLE PRECISION(11,12) ZEROFILL', sqlite: 'DOUBLE PRECISION ZEROFILL(11,12)', db2: 'DOUBLE', + oracle: 'BINARY_DOUBLE', postgres: 'DOUBLE PRECISION' }); @@ -1122,6 +1214,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { default: 'DOUBLE PRECISION(11,12) UNSIGNED ZEROFILL', sqlite: 'DOUBLE PRECISION UNSIGNED ZEROFILL(11,12)', db2: 'DOUBLE', + oracle: 'BINARY_DOUBLE', postgres: 'DOUBLE PRECISION' }); }); @@ -1129,11 +1222,13 @@ describe(Support.getTestDialectTeaser('SQL'), () => { describe('FLOAT', () => { testsql('FLOAT', DataTypes.FLOAT, { default: 'FLOAT', + oracle: 'BINARY_FLOAT', postgres: 'FLOAT' }); testsql('FLOAT.UNSIGNED', DataTypes.FLOAT.UNSIGNED, { default: 'FLOAT UNSIGNED', + oracle: 'BINARY_FLOAT', postgres: 'FLOAT', db2: 'FLOAT', mssql: 'FLOAT' @@ -1141,6 +1236,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { testsql('FLOAT(11)', DataTypes.FLOAT(11), { default: 'FLOAT(11)', + oracle: 'BINARY_FLOAT', postgres: 'FLOAT(11)', // 1-24 = 4 bytes; 35-53 = 8 bytes db2: 'FLOAT(11)', // 1-24 = 4 bytes; 35-53 = 8 bytes mssql: 'FLOAT(11)' // 1-24 = 4 bytes; 35-53 = 8 bytes @@ -1148,6 +1244,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { testsql('FLOAT(11).UNSIGNED', DataTypes.FLOAT(11).UNSIGNED, { default: 'FLOAT(11) UNSIGNED', + oracle: 'BINARY_FLOAT', sqlite: 'FLOAT UNSIGNED(11)', postgres: 'FLOAT(11)', db2: 'FLOAT(11)', @@ -1156,6 +1253,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { testsql('FLOAT(11).UNSIGNED.ZEROFILL', DataTypes.FLOAT(11).UNSIGNED.ZEROFILL, { default: 'FLOAT(11) UNSIGNED ZEROFILL', + oracle: 'BINARY_FLOAT', sqlite: 'FLOAT UNSIGNED ZEROFILL(11)', postgres: 'FLOAT(11)', db2: 'FLOAT(11)', @@ -1164,6 +1262,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { testsql('FLOAT(11).ZEROFILL', DataTypes.FLOAT(11).ZEROFILL, { default: 'FLOAT(11) ZEROFILL', + oracle: 'BINARY_FLOAT', sqlite: 'FLOAT ZEROFILL(11)', postgres: 'FLOAT(11)', db2: 'FLOAT(11)', @@ -1172,6 +1271,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { testsql('FLOAT({ length: 11 }).ZEROFILL', DataTypes.FLOAT({ length: 11 }).ZEROFILL, { default: 'FLOAT(11) ZEROFILL', + oracle: 'BINARY_FLOAT', sqlite: 'FLOAT ZEROFILL(11)', postgres: 'FLOAT(11)', db2: 'FLOAT(11)', @@ -1180,6 +1280,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { testsql('FLOAT(11).ZEROFILL.UNSIGNED', DataTypes.FLOAT(11).ZEROFILL.UNSIGNED, { default: 'FLOAT(11) UNSIGNED ZEROFILL', + oracle: 'BINARY_FLOAT', sqlite: 'FLOAT UNSIGNED ZEROFILL(11)', postgres: 'FLOAT(11)', db2: 'FLOAT(11)', @@ -1188,6 +1289,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { testsql('FLOAT(11, 12)', DataTypes.FLOAT(11, 12), { default: 'FLOAT(11,12)', + oracle: 'BINARY_FLOAT', postgres: 'FLOAT', db2: 'FLOAT', mssql: 'FLOAT' @@ -1195,6 +1297,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { testsql('FLOAT(11, 12).UNSIGNED', DataTypes.FLOAT(11, 12).UNSIGNED, { default: 'FLOAT(11,12) UNSIGNED', + oracle: 'BINARY_FLOAT', sqlite: 'FLOAT UNSIGNED(11,12)', postgres: 'FLOAT', db2: 'FLOAT', @@ -1203,6 +1306,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { testsql('FLOAT({ length: 11, decimals: 12 }).UNSIGNED', DataTypes.FLOAT({ length: 11, decimals: 12 }).UNSIGNED, { default: 'FLOAT(11,12) UNSIGNED', + oracle: 'BINARY_FLOAT', sqlite: 'FLOAT UNSIGNED(11,12)', postgres: 'FLOAT', db2: 'FLOAT', @@ -1211,6 +1315,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { testsql('FLOAT(11, 12).UNSIGNED.ZEROFILL', DataTypes.FLOAT(11, 12).UNSIGNED.ZEROFILL, { default: 'FLOAT(11,12) UNSIGNED ZEROFILL', + oracle: 'BINARY_FLOAT', sqlite: 'FLOAT UNSIGNED ZEROFILL(11,12)', postgres: 'FLOAT', db2: 'FLOAT', @@ -1219,6 +1324,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { testsql('FLOAT(11, 12).ZEROFILL', DataTypes.FLOAT(11, 12).ZEROFILL, { default: 'FLOAT(11,12) ZEROFILL', + oracle: 'BINARY_FLOAT', sqlite: 'FLOAT ZEROFILL(11,12)', postgres: 'FLOAT', db2: 'FLOAT', @@ -1227,6 +1333,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { testsql('FLOAT(11, 12).ZEROFILL.UNSIGNED', DataTypes.FLOAT(11, 12).ZEROFILL.UNSIGNED, { default: 'FLOAT(11,12) UNSIGNED ZEROFILL', + oracle: 'BINARY_FLOAT', sqlite: 'FLOAT UNSIGNED ZEROFILL(11,12)', postgres: 'FLOAT', db2: 'FLOAT', @@ -1256,51 +1363,61 @@ describe(Support.getTestDialectTeaser('SQL'), () => { if (current.dialect.supports.NUMERIC) { testsql('NUMERIC', DataTypes.NUMERIC, { - default: 'DECIMAL' + default: 'DECIMAL', + oracle: 'NUMBER' }); testsql('NUMERIC(15,5)', DataTypes.NUMERIC(15, 5), { - default: 'DECIMAL(15,5)' + default: 'DECIMAL(15,5)', + oracle: 'NUMBER(15,5)' }); } describe('DECIMAL', () => { testsql('DECIMAL', DataTypes.DECIMAL, { - default: 'DECIMAL' + default: 'DECIMAL', + oracle: 'NUMBER' }); testsql('DECIMAL(10, 2)', DataTypes.DECIMAL(10, 2), { - default: 'DECIMAL(10,2)' + default: 'DECIMAL(10,2)', + oracle: 'NUMBER(10,2)' }); testsql('DECIMAL({ precision: 10, scale: 2 })', DataTypes.DECIMAL({ precision: 10, scale: 2 }), { - default: 'DECIMAL(10,2)' + default: 'DECIMAL(10,2)', + oracle: 'NUMBER(10,2)' }); testsql('DECIMAL(10)', DataTypes.DECIMAL(10), { - default: 'DECIMAL(10)' + default: 'DECIMAL(10)', + oracle: 'NUMBER(10)' }); testsql('DECIMAL({ precision: 10 })', DataTypes.DECIMAL({ precision: 10 }), { - default: 'DECIMAL(10)' + default: 'DECIMAL(10)', + oracle: 'NUMBER(10)' }); testsql('DECIMAL.UNSIGNED', DataTypes.DECIMAL.UNSIGNED, { mariadb: 'DECIMAL UNSIGNED', mysql: 'DECIMAL UNSIGNED', - default: 'DECIMAL' + default: 'DECIMAL', + oracle: 'NUMBER' }); testsql('DECIMAL.UNSIGNED.ZEROFILL', DataTypes.DECIMAL.UNSIGNED.ZEROFILL, { mariadb: 'DECIMAL UNSIGNED ZEROFILL', mysql: 'DECIMAL UNSIGNED ZEROFILL', - default: 'DECIMAL' + default: 'DECIMAL', + oracle: 'NUMBER' }); testsql('DECIMAL({ precision: 10, scale: 2 }).UNSIGNED', DataTypes.DECIMAL({ precision: 10, scale: 2 }).UNSIGNED, { mariadb: 'DECIMAL(10,2) UNSIGNED', mysql: 'DECIMAL(10,2) UNSIGNED', - default: 'DECIMAL(10,2)' + default: 'DECIMAL(10,2)', + oracle: 'NUMBER(10,2)' }); describe('validate', () => { @@ -1368,6 +1485,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { testsql('BLOB("tiny")', DataTypes.BLOB('tiny'), { default: 'TINYBLOB', + oracle: 'BLOB', mssql: 'VARBINARY(256)', db2: 'BLOB(255)', postgres: 'BYTEA' @@ -1375,6 +1493,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { testsql('BLOB("medium")', DataTypes.BLOB('medium'), { default: 'MEDIUMBLOB', + oracle: 'BLOB', mssql: 'VARBINARY(MAX)', db2: 'BLOB(16M)', postgres: 'BYTEA' @@ -1382,6 +1501,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { testsql('BLOB({ length: "medium" })', DataTypes.BLOB({ length: 'medium' }), { default: 'MEDIUMBLOB', + oracle: 'BLOB', mssql: 'VARBINARY(MAX)', db2: 'BLOB(16M)', postgres: 'BYTEA' @@ -1389,6 +1509,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { testsql('BLOB("long")', DataTypes.BLOB('long'), { default: 'LONGBLOB', + oracle: 'BLOB', mssql: 'VARBINARY(MAX)', db2: 'BLOB(2G)', postgres: 'BYTEA' diff --git a/test/unit/sql/delete.test.js b/test/unit/sql/delete.test.js index 2e0d341108a8..ec34bd5236c6 100644 --- a/test/unit/sql/delete.test.js +++ b/test/unit/sql/delete.test.js @@ -40,6 +40,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { mysql: 'TRUNCATE `public.test_users`', db2: 'TRUNCATE TABLE "public"."test_users" IMMEDIATE', sqlite: 'DELETE FROM `public.test_users`', + oracle: 'TRUNCATE TABLE "public"."test_users"', snowflake: 'TRUNCATE "public"."test_users"' } ); @@ -69,6 +70,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { mysql: 'TRUNCATE `public.test_users`', db2: 'TRUNCATE TABLE "public"."test_users" IMMEDIATE', sqlite: 'DELETE FROM `public.test_users`; DELETE FROM `sqlite_sequence` WHERE `name` = \'public.test_users\';', + oracle: 'TRUNCATE TABLE "public"."test_users"', snowflake: 'TRUNCATE "public"."test_users"' } ); @@ -97,6 +99,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { sqlite: "DELETE FROM `public.test_users` WHERE `name` = 'foo'", db2: 'DELETE FROM "public"."test_users" WHERE "name" = \'foo\'', mssql: "DELETE FROM [public].[test_users] WHERE [name] = N'foo'; SELECT @@ROWCOUNT AS AFFECTEDROWS;", + oracle: 'DELETE FROM "public"."test_users" WHERE "name" = \'foo\'', snowflake: 'DELETE FROM "public"."test_users" WHERE "name" = \'foo\';' } ); @@ -125,6 +128,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { mssql: "DELETE TOP(10) FROM [public].[test_users] WHERE [name] = N'foo'';DROP TABLE mySchema.myTable;'; SELECT @@ROWCOUNT AS AFFECTEDROWS;", db2: "DELETE FROM \"public\".\"test_users\" WHERE \"name\" = 'foo'';DROP TABLE mySchema.myTable;' FETCH NEXT 10 ROWS ONLY", snowflake: 'DELETE FROM "public"."test_users" WHERE "id" IN (SELECT "id" FROM "public"."test_users" WHERE "name" = \'foo\'\';DROP TABLE mySchema.myTable;\' LIMIT 10);', + oracle: 'DELETE FROM "public"."test_users" WHERE rowid IN (SELECT rowid FROM "public"."test_users" WHERE rownum <= 10 AND "name" = \'foo\'\';DROP TABLE mySchema.myTable;\')', default: "DELETE FROM [public.test_users] WHERE `name` = 'foo\\';DROP TABLE mySchema.myTable;' LIMIT 10" } ); @@ -159,6 +163,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { sqlite: "DELETE FROM `public.test_users` WHERE rowid IN (SELECT rowid FROM `public.test_users` WHERE `name` = 'foo'';DROP TABLE mySchema.myTable;' LIMIT 10)", mssql: "DELETE TOP(10) FROM [public].[test_users] WHERE [name] = N'foo'';DROP TABLE mySchema.myTable;'; SELECT @@ROWCOUNT AS AFFECTEDROWS;", db2: "DELETE FROM \"public\".\"test_users\" WHERE \"name\" = 'foo'';DROP TABLE mySchema.myTable;' FETCH NEXT 10 ROWS ONLY", + oracle: 'DELETE FROM "public"."test_users" WHERE rowid IN (SELECT rowid FROM "public"."test_users" WHERE rownum <= 10 AND "name" = \'foo\'\';DROP TABLE mySchema.myTable;\')', snowflake: new Error('Cannot LIMIT delete without a model.'), default: "DELETE FROM [public.test_users] WHERE `name` = 'foo\\';DROP TABLE mySchema.myTable;' LIMIT 10" } diff --git a/test/unit/sql/enum.test.js b/test/unit/sql/enum.test.js index a6e13a23d32f..c27836281a04 100644 --- a/test/unit/sql/enum.test.js +++ b/test/unit/sql/enum.test.js @@ -43,13 +43,13 @@ describe(Support.getTestDialectTeaser('SQL'), () => { describe('pgEnum', () => { it('uses schema #3171', () => { expectsql(sql.pgEnum(FooUser.getTableName(), 'mood', FooUser.rawAttributes.mood.type), { - postgres: 'CREATE TYPE "foo"."enum_users_mood" AS ENUM(\'happy\', \'sad\');' + postgres: 'DO \'BEGIN CREATE TYPE "foo"."enum_users_mood" AS ENUM(\'\'happy\'\', \'\'sad\'\'); EXCEPTION WHEN duplicate_object THEN null; END\';' }); }); it('does add schema when public', () => { expectsql(sql.pgEnum(PublicUser.getTableName(), 'theirMood', PublicUser.rawAttributes.mood.type), { - postgres: 'CREATE TYPE "public"."enum_users_theirMood" AS ENUM(\'happy\', \'sad\');' + postgres: 'DO \'BEGIN CREATE TYPE "public"."enum_users_theirMood" AS ENUM(\'\'happy\'\', \'\'sad\'\'); EXCEPTION WHEN duplicate_object THEN null; END\';' }); }); }); diff --git a/test/unit/sql/generateJoin.test.js b/test/unit/sql/generateJoin.test.js index 5283d048ba14..29e6cbf28964 100644 --- a/test/unit/sql/generateJoin.test.js +++ b/test/unit/sql/generateJoin.test.js @@ -99,7 +99,8 @@ describe(Support.getTestDialectTeaser('SQL'), () => { ] }, { - default: 'LEFT OUTER JOIN [company] AS [Company] ON [User].[company_id] = [Company].[id]' + default: 'LEFT OUTER JOIN [company] AS [Company] ON [User].[company_id] = [Company].[id]', + oracle: 'LEFT OUTER JOIN "company" "Company" ON "User"."company_id" = "Company"."id"' } ); @@ -118,6 +119,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { { default: 'INNER JOIN [company] AS [Company] ON [User].[company_id] = [Company].[id] OR [Company].[public] = true', sqlite: 'INNER JOIN `company` AS `Company` ON `User`.`company_id` = `Company`.`id` OR `Company`.`public` = 1', + oracle: 'INNER JOIN "company" "Company" ON "User"."company_id" = "Company"."id" OR "Company"."public" = \'1\'', mssql: 'INNER JOIN [company] AS [Company] ON [User].[company_id] = [Company].[id] OR [Company].[public] = 1' } ); @@ -137,6 +139,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { ] }, { + oracle: 'LEFT OUTER JOIN "company" "Professionals->Company" ON "Professionals"."company_id" = "Professionals->Company"."id"', default: 'LEFT OUTER JOIN [company] AS [Professionals->Company] ON [Professionals].[company_id] = [Professionals->Company].[id]' } ); @@ -151,7 +154,8 @@ describe(Support.getTestDialectTeaser('SQL'), () => { ] }, { - default: 'LEFT OUTER JOIN [company] AS [Company] ON [User].[companyId] = [Company].[id]' + default: 'LEFT OUTER JOIN [company] AS [Company] ON [User].[companyId] = [Company].[id]', + oracle: 'LEFT OUTER JOIN "company" "Company" ON "User"."companyId" = "Company"."id"' } ); @@ -168,6 +172,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { }, { default: "LEFT OUTER JOIN [company] AS [Company] ON [User].[companyId] = [Company].[id] AND [Company].[name] = 'ABC'", + oracle: 'LEFT OUTER JOIN "company" "Company" ON "User"."companyId" = "Company"."id" AND "Company"."name" = \'ABC\'', mssql: "LEFT OUTER JOIN [company] AS [Company] ON [User].[companyId] = [Company].[id] AND [Company].[name] = N'ABC'" } ); @@ -184,7 +189,8 @@ describe(Support.getTestDialectTeaser('SQL'), () => { ] }, { - default: `${current.dialect.supports['RIGHT JOIN'] ? 'RIGHT' : 'LEFT'} OUTER JOIN [company] AS [Company] ON [User].[companyId] = [Company].[id]` + default: `${current.dialect.supports['RIGHT JOIN'] ? 'RIGHT' : 'LEFT'} OUTER JOIN [company] AS [Company] ON [User].[companyId] = [Company].[id]`, + oracle: 'RIGHT OUTER JOIN "company" "Company" ON "User"."companyId" = "Company"."id"' } ); @@ -203,7 +209,8 @@ describe(Support.getTestDialectTeaser('SQL'), () => { }, { - default: 'LEFT OUTER JOIN [user] AS [Company->Owner] ON [Company].[owner_id] = [Company->Owner].[id_user]' + default: 'LEFT OUTER JOIN [user] AS [Company->Owner] ON [Company].[owner_id] = [Company->Owner].[id_user]', + oracle: 'LEFT OUTER JOIN "user" "Company->Owner" ON "Company"."owner_id" = "Company->Owner"."id_user"' } ); @@ -224,7 +231,10 @@ describe(Support.getTestDialectTeaser('SQL'), () => { } ] }, - { default: 'LEFT OUTER JOIN [profession] AS [Company->Owner->Profession] ON [Company->Owner].[professionId] = [Company->Owner->Profession].[id]' } + { + default: 'LEFT OUTER JOIN [profession] AS [Company->Owner->Profession] ON [Company->Owner].[professionId] = [Company->Owner->Profession].[id]', + oracle: 'LEFT OUTER JOIN "profession" "Company->Owner->Profession" ON "Company->Owner"."professionId" = "Company->Owner->Profession"."id"' + } ); testsql( @@ -242,7 +252,10 @@ describe(Support.getTestDialectTeaser('SQL'), () => { } ] }, - { default: 'LEFT OUTER JOIN [user] AS [Company->Owner] ON [Company].[owner_id] = [Company->Owner].[id_user]' } + { + default: 'LEFT OUTER JOIN [user] AS [Company->Owner] ON [Company].[owner_id] = [Company->Owner].[id_user]', + oracle: 'LEFT OUTER JOIN "user" "Company->Owner" ON "Company"."owner_id" = "Company->Owner"."id_user"' + } ); testsql( @@ -255,7 +268,8 @@ describe(Support.getTestDialectTeaser('SQL'), () => { ] }, { - default: 'INNER JOIN [company] AS [Company] ON [User].[companyId] = [Company].[id]' + default: 'INNER JOIN [company] AS [Company] ON [User].[companyId] = [Company].[id]', + oracle: 'INNER JOIN "company" "Company" ON "User"."companyId" = "Company"."id"' } ); @@ -271,7 +285,10 @@ describe(Support.getTestDialectTeaser('SQL'), () => { User.Tasks ] }, - { default: 'LEFT OUTER JOIN [task] AS [Tasks] ON [User].[id_user] = [Tasks].[user_id]' } + { + default: 'LEFT OUTER JOIN [task] AS [Tasks] ON [User].[id_user] = [Tasks].[user_id]', + oracle: 'LEFT OUTER JOIN "task" "Tasks" ON "User"."id_user" = "Tasks"."user_id"' + } ); testsql( @@ -285,7 +302,8 @@ describe(Support.getTestDialectTeaser('SQL'), () => { }, { // The primary key of the main model will be aliased because it's coming from a subquery that the :M join is not a part of - default: 'LEFT OUTER JOIN [task] AS [Tasks] ON [User].[id] = [Tasks].[user_id]' + default: 'LEFT OUTER JOIN [task] AS [Tasks] ON [User].[id] = [Tasks].[user_id]', + oracle: 'LEFT OUTER JOIN "task" "Tasks" ON "User"."id" = "Tasks"."user_id"' } ); @@ -303,7 +321,11 @@ describe(Support.getTestDialectTeaser('SQL'), () => { } } ] - }, { default: 'LEFT OUTER JOIN [task] AS [Tasks] ON ([User].[id_user] = [Tasks].[user_id] OR [Tasks].[user_id] = 2)' } + }, + { + default: 'LEFT OUTER JOIN [task] AS [Tasks] ON ([User].[id_user] = [Tasks].[user_id] OR [Tasks].[user_id] = 2)', + oracle: 'LEFT OUTER JOIN "task" "Tasks" ON ("User"."id_user" = "Tasks"."user_id" OR "Tasks"."user_id" = 2)' + } ); testsql( @@ -316,7 +338,11 @@ describe(Support.getTestDialectTeaser('SQL'), () => { on: { 'user_id': { [Op.col]: 'User.alternative_id' } } } ] - }, { default: 'LEFT OUTER JOIN [task] AS [Tasks] ON [Tasks].[user_id] = [User].[alternative_id]' } + }, + { + default: 'LEFT OUTER JOIN [task] AS [Tasks] ON [Tasks].[user_id] = [User].[alternative_id]', + oracle: 'LEFT OUTER JOIN "task" "Tasks" ON "Tasks"."user_id" = "User"."alternative_id"' + } ); testsql( @@ -343,7 +369,8 @@ describe(Support.getTestDialectTeaser('SQL'), () => { }, { - default: 'LEFT OUTER JOIN [user] AS [Company->Owner] ON ([Company].[owner_id] = [Company->Owner].[id_user] OR [Company->Owner].[id_user] = 2)' + default: 'LEFT OUTER JOIN [user] AS [Company->Owner] ON ([Company].[owner_id] = [Company->Owner].[id_user] OR [Company->Owner].[id_user] = 2)', + oracle: 'LEFT OUTER JOIN "user" "Company->Owner" ON ("Company"."owner_id" = "Company->Owner"."id_user" OR "Company->Owner"."id_user" = 2)' } ); diff --git a/test/unit/sql/get-where-conditions.test.js b/test/unit/sql/get-where-conditions.test.js new file mode 100644 index 000000000000..88578738955e --- /dev/null +++ b/test/unit/sql/get-where-conditions.test.js @@ -0,0 +1,26 @@ +const { expect } = require('chai'); +const { sequelize } = require('../../support'); + +describe('QueryGenerator#getWhereConditions', () => { + const queryGenerator = sequelize.queryInterface.queryGenerator; + + it('throws if called with invalid arguments', () => { + const User = sequelize.define('User'); + + expect(() => { + queryGenerator.getWhereConditions(new Date(), User.getTableName(), User); + }).to.throw('Unsupported where option value'); + }); + + it('ignores undefined', () => { + const User = sequelize.define('User'); + + expect(queryGenerator.getWhereConditions(undefined, User.getTableName(), User)).to.eq(''); + }); + + it('ignores null', () => { + const User = sequelize.define('User'); + + expect(queryGenerator.getWhereConditions(null, User.getTableName(), User)).to.eq(''); + }); +}); diff --git a/test/unit/sql/group.test.js b/test/unit/sql/group.test.js index 2e51466bfc1c..a6d1407abd3a 100644 --- a/test/unit/sql/group.test.js +++ b/test/unit/sql/group.test.js @@ -41,6 +41,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { postgres: 'SELECT * FROM "Users" AS "User" GROUP BY "name";', db2: 'SELECT * FROM "Users" AS "User" GROUP BY "name";', mssql: 'SELECT * FROM [Users] AS [User] GROUP BY [name];', + oracle: 'SELECT * FROM "Users" "User" GROUP BY "name";', snowflake: 'SELECT * FROM "Users" AS "User" GROUP BY "name";' }); @@ -52,6 +53,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { postgres: 'SELECT * FROM "Users" AS "User";', db2: 'SELECT * FROM "Users" AS "User";', mssql: 'SELECT * FROM [Users] AS [User];', + oracle: 'SELECT * FROM "Users" "User";', snowflake: 'SELECT * FROM "Users" AS "User";' }); }); diff --git a/test/unit/sql/index.test.js b/test/unit/sql/index.test.js index 03371188ade7..8ebb7904677b 100644 --- a/test/unit/sql/index.test.js +++ b/test/unit/sql/index.test.js @@ -54,6 +54,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { mssql: 'CREATE FULLTEXT INDEX [user_field_c] ON [User] ([fieldC])', postgres: 'CREATE INDEX CONCURRENTLY "user_field_c" ON "User" ("fieldC")', mariadb: 'ALTER TABLE `User` ADD FULLTEXT INDEX `user_field_c` (`fieldC`)', + oracle: 'CREATE INDEX "user_field_c" ON "User" ("fieldC")', mysql: 'ALTER TABLE `User` ADD FULLTEXT INDEX `user_field_c` (`fieldC`)' }); @@ -68,6 +69,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { db2: 'CREATE UNIQUE INDEX "a_b_uniq" ON "User" ("fieldB", "fieldA" DESC)', postgres: 'CREATE UNIQUE INDEX "a_b_uniq" ON "User" USING BTREE ("fieldB", "fieldA" COLLATE "en_US" DESC)', mariadb: 'ALTER TABLE `User` ADD UNIQUE INDEX `a_b_uniq` USING BTREE (`fieldB`, `fieldA`(5) DESC) WITH PARSER foo', + oracle: 'CREATE UNIQUE INDEX "a_b_uniq" ON "User" ("fieldB", "fieldA" DESC)', mysql: 'ALTER TABLE `User` ADD UNIQUE INDEX `a_b_uniq` USING BTREE (`fieldB`, `fieldA`(5) DESC) WITH PARSER foo' }); }); @@ -78,6 +80,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { mssql: 'CREATE INDEX [table_column] ON [table] ([column] DESC)', db2: 'CREATE INDEX "table_column" ON "table" ("column" DESC)', mariadb: 'ALTER TABLE `table` ADD INDEX `table_column` (`column`(5) DESC)', + oracle: 'CREATE INDEX "table_column" ON "table" ("column" DESC)', mysql: 'ALTER TABLE `table` ADD INDEX `table_column` (`column`(5) DESC)' }); }); @@ -250,6 +253,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { mysql: 'DROP INDEX `table_column1_column2` ON `table`', mssql: 'DROP INDEX [table_column1_column2] ON [table]', db2: 'DROP INDEX "table_column1_column2"', + oracle: 'DROP INDEX "table_column1_column2"', default: 'DROP INDEX IF EXISTS [table_column1_column2]' }); }); diff --git a/test/unit/sql/insert.test.js b/test/unit/sql/insert.test.js index ea5fe6e31576..8924fcdbaa02 100644 --- a/test/unit/sql/insert.test.js +++ b/test/unit/sql/insert.test.js @@ -32,7 +32,8 @@ describe(Support.getTestDialectTeaser('SQL'), () => { postgres: 'INSERT INTO "users" ("user_name") VALUES ($1) RETURNING "id","user_name";', db2: 'SELECT * FROM FINAL TABLE(INSERT INTO "users" ("user_name") VALUES ($1));', snowflake: 'INSERT INTO "users" ("user_name") VALUES ($1);', - default: 'INSERT INTO `users` (`user_name`) VALUES ($1);' + oracle: 'INSERT INTO "users" ("user_name") VALUES (:1) RETURNING "id","user_name" INTO :2,:3;', + default: 'INSERT INTO `users` (`user_name`) VALUES ($1);' }, bind: ['triggertest'] }); @@ -55,6 +56,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { db2: 'SELECT * FROM FINAL TABLE(INSERT INTO "ms" ("id") VALUES ($1));', postgres: 'INSERT INTO "ms" ("id") VALUES ($1);', snowflake: 'INSERT INTO "ms" ("id") VALUES ($1);', + oracle: 'INSERT INTO "ms" ("id") VALUES (:1);', default: 'INSERT INTO `ms` (`id`) VALUES ($1);' }, bind: [0] @@ -62,6 +64,70 @@ describe(Support.getTestDialectTeaser('SQL'), () => { }); }); + it( + current.dialect.supports.inserts.onConflictWhere + ? 'adds conflictWhere clause to generated queries' + : 'throws error if conflictWhere is provided', + () => { + const User = Support.sequelize.define( + 'user', + { + username: { + type: DataTypes.STRING, + field: 'user_name', + primaryKey: true + }, + password: { + type: DataTypes.STRING, + field: 'pass_word' + }, + createdAt: { + type: DataTypes.DATE, + field: 'created_at' + }, + updatedAt: { + type: DataTypes.DATE, + field: 'updated_at' + } + }, + { + timestamps: true + } + ); + + const upsertKeys = ['user_name']; + + let result; + + try { + result = sql.insertQuery( + User.tableName, + { user_name: 'testuser', pass_word: '12345' }, + User.fieldRawAttributesMap, + { + updateOnDuplicate: ['user_name', 'pass_word', 'updated_at'], + conflictWhere: { + user_name: 'test where value' + }, + upsertKeys + } + ); + } catch (error) { + result = error; + } + + expectsql(result, { + default: new Error( + 'missing dialect support for conflictWhere option' + ), + postgres: + 'INSERT INTO "users" ("user_name","pass_word") VALUES ($1,$2) ON CONFLICT ("user_name") WHERE "user_name" = \'test where value\' DO UPDATE SET "user_name"=EXCLUDED."user_name","pass_word"=EXCLUDED."pass_word","updated_at"=EXCLUDED."updated_at";', + sqlite: + 'INSERT INTO `users` (`user_name`,`pass_word`) VALUES ($1,$2) ON CONFLICT (`user_name`) WHERE `user_name` = \'test where value\' DO UPDATE SET `user_name`=EXCLUDED.`user_name`,`pass_word`=EXCLUDED.`pass_word`,`updated_at`=EXCLUDED.`updated_at`;' + }); + } + ); + describe('dates', () => { it('formats the date correctly when inserting', () => { const timezoneSequelize = Support.createSequelizeInstance({ @@ -82,6 +148,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { postgres: 'INSERT INTO "users" ("date") VALUES ($1);', db2: 'SELECT * FROM FINAL TABLE(INSERT INTO "users" ("date") VALUES ($1));', snowflake: 'INSERT INTO "users" ("date") VALUES ($1);', + oracle: 'INSERT INTO "users" ("date") VALUES (:1);', mssql: 'INSERT INTO [users] ([date]) VALUES ($1);', default: 'INSERT INTO `users` (`date`) VALUES ($1);' }, @@ -91,6 +158,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { mysql: ['2015-01-20 01:00:00'], snowflake: ['2015-01-20 01:00:00'], mariadb: ['2015-01-20 01:00:00.000'], + oracle: [new Date(Date.UTC(2015, 0, 20))], default: ['2015-01-20 01:00:00.000 +01:00'] } }); @@ -116,11 +184,13 @@ describe(Support.getTestDialectTeaser('SQL'), () => { db2: 'SELECT * FROM FINAL TABLE(INSERT INTO "users" ("date") VALUES ($1));', snowflake: 'INSERT INTO "users" ("date") VALUES ($1);', mssql: 'INSERT INTO [users] ([date]) VALUES ($1);', + oracle: 'INSERT INTO "users" ("date") VALUES (:1);', default: 'INSERT INTO `users` (`date`) VALUES ($1);' }, bind: { sqlite: ['2015-01-20 01:02:03.089 +00:00'], mariadb: ['2015-01-20 02:02:03.089'], + oracle: [new Date(Date.UTC(2015, 0, 20, 1, 2, 3, 89))], mysql: ['2015-01-20 02:02:03.089'], db2: ['2015-01-20 02:02:03.089'], snowflake: ['2015-01-20 02:02:03.089'], @@ -148,6 +218,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { db2: 'SELECT * FROM FINAL TABLE(INSERT INTO "users" ("user_name") VALUES ($1));', snowflake: 'INSERT INTO "users" ("user_name") VALUES ($1);', mssql: 'INSERT INTO [users] ([user_name]) VALUES ($1);', + oracle: 'INSERT INTO "users" ("user_name") VALUES (:1);', default: 'INSERT INTO `users` (`user_name`) VALUES ($1);' }, bind: { @@ -189,6 +260,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { { default: 'INSERT INTO `users` (`user_name`,`pass_word`) VALUES (\'testuser\',\'12345\');', snowflake: 'INSERT INTO "users" ("user_name","pass_word") VALUES (\'testuser\',\'12345\');', + oracle: 'INSERT INTO "users" ("user_name","pass_word") VALUES (:1,:2)', postgres: 'INSERT INTO "users" ("user_name","pass_word") VALUES (\'testuser\',\'12345\') ON CONFLICT ("user_name") DO UPDATE SET "user_name"=EXCLUDED."user_name","pass_word"=EXCLUDED."pass_word","updated_at"=EXCLUDED."updated_at";', mssql: 'INSERT INTO [users] ([user_name],[pass_word]) VALUES (N\'testuser\',N\'12345\');', db2: 'INSERT INTO "users" ("user_name","pass_word") VALUES (\'testuser\',\'12345\');', @@ -198,7 +270,8 @@ describe(Support.getTestDialectTeaser('SQL'), () => { }); }); - it('allow bulk insert primary key with 0', () => { + // Oracle dialect doesn't support mix of null and non-null in auto-increment column + (current.dialect.name !== 'oracle' ? it : it.skip)('allow bulk insert primary key with 0', () => { const M = Support.sequelize.define('m', { id: { type: DataTypes.INTEGER, @@ -218,5 +291,71 @@ describe(Support.getTestDialectTeaser('SQL'), () => { } }); }); + + if ( + current.dialect.supports.inserts.updateOnDuplicate + ) { + it('correctly generates SQL for conflictWhere', () => { + const User = Support.sequelize.define( + 'user', + { + username: { + type: DataTypes.STRING, + field: 'user_name', + primaryKey: true + }, + password: { + type: DataTypes.STRING, + field: 'pass_word' + }, + createdAt: { + type: DataTypes.DATE, + field: 'created_at' + }, + updatedAt: { + type: DataTypes.DATE, + field: 'updated_at' + }, + deletedAt: { + type: DataTypes.DATE, + field: 'deleted_at' + } + }, + { + timestamps: true + } + ); + + // mapping primary keys to their "field" override values + const primaryKeys = User.primaryKeyAttributes.map(attr => User.getAttributes()[attr].field || attr); + + let result; + + try { + result = sql.bulkInsertQuery( + User.tableName, + [{ user_name: 'testuser', pass_word: '12345' }], + { + updateOnDuplicate: ['user_name', 'pass_word', 'updated_at'], + upsertKeys: primaryKeys, + conflictWhere: { deleted_at: null } + }, + User.fieldRawAttributesMap + ); + } catch (error) { + result = error; + } + + expectsql(result, { + default: new Error( + `conflictWhere not supported for dialect ${current.dialect.name}` + ), + 'postgres': + 'INSERT INTO "users" ("user_name","pass_word") VALUES (\'testuser\',\'12345\') ON CONFLICT ("user_name") WHERE "deleted_at" IS NULL DO UPDATE SET "user_name"=EXCLUDED."user_name","pass_word"=EXCLUDED."pass_word","updated_at"=EXCLUDED."updated_at";', + 'sqlite': + 'INSERT INTO `users` (`user_name`,`pass_word`) VALUES (\'testuser\',\'12345\') ON CONFLICT (`user_name`) WHERE `deleted_at` IS NULL DO UPDATE SET `user_name`=EXCLUDED.`user_name`,`pass_word`=EXCLUDED.`pass_word`,`updated_at`=EXCLUDED.`updated_at`;' + }); + }); + } }); }); diff --git a/test/unit/sql/json.test.js b/test/unit/sql/json.test.js index 1e874a411ad0..a1b8939c11d1 100644 --- a/test/unit/sql/json.test.js +++ b/test/unit/sql/json.test.js @@ -84,6 +84,7 @@ if (current.dialect.supports.JSON) { postgres: '("id"#>>\'{}\') = \'1\'', sqlite: "json_extract(`id`,'$') = '1'", mariadb: "json_unquote(json_extract(`id`,'$')) = '1'", + oracle: 'json_value("id",\'$\') = \'1\'', mysql: "json_unquote(json_extract(`id`,'$')) = '1'" }); }); @@ -93,6 +94,7 @@ if (current.dialect.supports.JSON) { postgres: '("profile"#>>\'{id}\') = \'1\'', sqlite: "json_extract(`profile`,'$.id') = '1'", mariadb: "json_unquote(json_extract(`profile`,'$.id')) = '1'", + oracle: 'json_value("profile",\'$."id"\') = \'1\'', mysql: "json_unquote(json_extract(`profile`,'$.\\\"id\\\"')) = '1'" }); }); @@ -102,6 +104,7 @@ if (current.dialect.supports.JSON) { postgres: '("property"#>>\'{value}\') = \'1\' AND ("another"#>>\'{value}\') = \'string\'', sqlite: "json_extract(`property`,'$.value') = '1' AND json_extract(`another`,'$.value') = 'string'", mariadb: "json_unquote(json_extract(`property`,'$.value')) = '1' AND json_unquote(json_extract(`another`,'$.value')) = 'string'", + oracle: 'json_value("property",\'$."value"\') = \'1\' AND json_value("another",\'$."value"\') = \'string\'', mysql: "json_unquote(json_extract(`property`,'$.\\\"value\\\"')) = '1' AND json_unquote(json_extract(`another`,'$.\\\"value\\\"')) = 'string'" }); }); @@ -111,6 +114,7 @@ if (current.dialect.supports.JSON) { postgres: '("property"#>>\'{0,0}\') = \'4\' AND ("property"#>>\'{0,1}\') = \'6\' AND ("property"#>>\'{1,0}\') = \'8\'', sqlite: "json_extract(`property`,'$[0][0]') = '4' AND json_extract(`property`,'$[0][1]') = '6' AND json_extract(`property`,'$[1][0]') = '8'", mariadb: "json_unquote(json_extract(`property`,'$[0][0]')) = '4' AND json_unquote(json_extract(`property`,'$[0][1]')) = '6' AND json_unquote(json_extract(`property`,'$[1][0]')) = '8'", + oracle: 'json_value("property",\'$[0][0]\') = \'4\' AND json_value("property",\'$[0][1]\') = \'6\' AND json_value("property",\'$[1][0]\') = \'8\'', mysql: "json_unquote(json_extract(`property`,'$[0][0]')) = '4' AND json_unquote(json_extract(`property`,'$[0][1]')) = '6' AND json_unquote(json_extract(`property`,'$[1][0]')) = '8'" }); }); @@ -120,6 +124,7 @@ if (current.dialect.supports.JSON) { postgres: '("profile"#>>\'{id}\') = \'1\'', sqlite: "json_extract(`profile`,'$.id') = '1'", mariadb: "json_unquote(json_extract(`profile`,'$.id')) = '1'", + oracle: 'json_value("profile",\'$."id"\') = \'1\'', mysql: "json_unquote(json_extract(`profile`,'$.\\\"id\\\"')) = '1'" }); }); @@ -129,6 +134,7 @@ if (current.dialect.supports.JSON) { postgres: '("profile"#>>\'{id,0,1}\') = \'1\'', sqlite: "json_extract(`profile`,'$.id[0][1]') = '1'", mariadb: "json_unquote(json_extract(`profile`,'$.id[0][1]')) = '1'", + oracle: 'json_value("profile",\'$."id"[0][1]\') = \'1\'', mysql: "json_unquote(json_extract(`profile`,'$.\\\"id\\\"[0][1]')) = '1'" }); }); @@ -138,6 +144,7 @@ if (current.dialect.supports.JSON) { postgres: '("json"#>>\'{}\') = \'{}\'', sqlite: "json_extract(`json`,'$') = '{}'", mariadb: "json_unquote(json_extract(`json`,'$')) = '{}'", + oracle: 'json_value("json",\'$\') = \'{}\'', mysql: "json_unquote(json_extract(`json`,'$')) = '{}'" }); }); @@ -159,7 +166,9 @@ if (current.dialect.supports.JSON) { }); it('nested json functions', () => { - expectsql(sql.handleSequelizeMethod(Sequelize.json('json_extract(json_object(\'{"profile":null}\'), "profile")')), { + const rawJSON = current.dialect.name === 'oracle' ? 'json_value(json_object(\'{"profile":null}\'), "profile")' : 'json_extract(json_object(\'{"profile":null}\'), "profile")'; + expectsql(sql.handleSequelizeMethod(Sequelize.json(rawJSON)), { + oracle: 'json_value(json_object(\'{"profile":null}\'), "profile")', default: 'json_extract(json_object(\'{"profile":null}\'), "profile")' }); }); @@ -180,6 +189,70 @@ if (current.dialect.supports.JSON) { expect(() => sql.handleSequelizeMethod(Sequelize.json('json(); DELETE YOLO INJECTIONS; -- '))).to.throw(); }); }); + + describe('cast type injection', () => { + const jsonFieldOptions = { field: { type: new DataTypes.JSON() } }; + + it('should reject SQL injection via :: cast type notation in JSON keys', () => { + expect(() => { + sql.whereItemQuery('data', { 'role::text) OR 1=1--': 'anything' }, jsonFieldOptions); + }).to.throw(Error, /Invalid cast type/); + }); + + it('should reject UNION-based injection via :: cast type notation', () => { + expect(() => { + sql.whereItemQuery('data', { 'role::text) AND 0 UNION SELECT * FROM secrets--': 'x' }, jsonFieldOptions); + }).to.throw(Error, /Invalid cast type/); + }); + + it('should allow valid cast types via :: notation', () => { + expect(() => { + sql.whereItemQuery('data', { 'id::integer': 1 }, jsonFieldOptions); + }).to.not.throw(); + }); + + it('should allow the text cast type via :: notation', () => { + expect(() => { + sql.whereItemQuery('data', { 'name::text': 'value' }, jsonFieldOptions); + }).to.not.throw(); + }); + + it('should reject cast types with parentheses', () => { + expect(() => { + sql.whereItemQuery('data', { 'role::text)': 'anything' }, jsonFieldOptions); + }).to.throw(Error, /Invalid cast type/); + }); + + it('should reject cast types with semicolons', () => { + expect(() => { + sql.whereItemQuery('data', { 'role::text; DROP TABLE users': 'anything' }, jsonFieldOptions); + }).to.throw(Error, /Invalid cast type/); + }); + + it('should reject cast types with comment markers', () => { + expect(() => { + sql.whereItemQuery('data', { 'role::text--': 'anything' }, jsonFieldOptions); + }).to.throw(Error, /Invalid cast type/); + }); + + it('should allow double precision cast type', () => { + expect(() => { + sql.whereItemQuery('data', { 'level::double precision': 1 }, jsonFieldOptions); + }).to.not.throw(); + }); + + it('should reject empty cast type', () => { + expect(() => { + sql.whereItemQuery('data', { 'role::': 'anything' }, jsonFieldOptions); + }).to.throw(Error, /Invalid cast type/); + }); + + it('should reject unknown cast types', () => { + expect(() => { + sql.whereItemQuery('data', { 'role::foobar': 'anything' }, jsonFieldOptions); + }).to.throw(Error, /Invalid cast type/); + }); + }); }); }); } diff --git a/test/unit/sql/offset-limit.test.js b/test/unit/sql/offset-limit.test.js index a81238eb6254..04db33ab4441 100644 --- a/test/unit/sql/offset-limit.test.js +++ b/test/unit/sql/offset-limit.test.js @@ -30,6 +30,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { }, { default: ' LIMIT 10', db2: ' FETCH NEXT 10 ROWS ONLY', + oracle: ' ORDER BY "tableRef"."id" OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY', mssql: ' ORDER BY [tableRef].[id] OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY' }); @@ -41,6 +42,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { }, { default: ' LIMIT 10', db2: ' FETCH NEXT 10 ROWS ONLY', + oracle: ' OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY', mssql: ' OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY' }); @@ -55,6 +57,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { snowflake: ' LIMIT 10 OFFSET 20', postgres: ' LIMIT 10 OFFSET 20', db2: ' OFFSET 20 ROWS FETCH NEXT 10 ROWS ONLY', + oracle: ' OFFSET 20 ROWS FETCH NEXT 10 ROWS ONLY', mssql: ' OFFSET 20 ROWS FETCH NEXT 10 ROWS ONLY' }); @@ -69,6 +72,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { snowflake: " LIMIT ''';DELETE FROM user'", mysql: " LIMIT '\\';DELETE FROM user'", db2: " FETCH NEXT ''';DELETE FROM user' ROWS ONLY", + oracle: " OFFSET 0 ROWS FETCH NEXT ''';DELETE FROM user' ROWS ONLY", mssql: " OFFSET 0 ROWS FETCH NEXT N''';DELETE FROM user' ROWS ONLY" }); @@ -85,6 +89,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { snowflake: " LIMIT 10 OFFSET ''';DELETE FROM user'", mysql: " LIMIT '\\';DELETE FROM user', 10", db2: ' FETCH NEXT 10 ROWS ONLY', + oracle: " OFFSET ''';DELETE FROM user' ROWS FETCH NEXT 10 ROWS ONLY", mssql: " OFFSET N''';DELETE FROM user' ROWS FETCH NEXT 10 ROWS ONLY" }); @@ -95,6 +100,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { }, { db2: ' FETCH NEXT 10 ROWS ONLY', default: ' LIMIT 10', + oracle: ' ORDER BY "tableRef"."id" OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY', mssql: ' ORDER BY [tableRef].[id] OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY' }); }); diff --git a/test/unit/sql/order.test.js b/test/unit/sql/order.test.js index 3f399a3ad566..e3beee45fa84 100644 --- a/test/unit/sql/order.test.js +++ b/test/unit/sql/order.test.js @@ -341,6 +341,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { ] }, { default: 'SELECT [Subtask].[id], [Subtask].[name], [Subtask].[createdAt], [Task].[id] AS [Task.id], [Task].[name] AS [Task.name], [Task].[created_at] AS [Task.createdAt], [Task->Project].[id] AS [Task.Project.id], [Task->Project].[name] AS [Task.Project.name], [Task->Project].[created_at] AS [Task.Project.createdAt] FROM [subtask] AS [Subtask] INNER JOIN [task] AS [Task] ON [Subtask].[task_id] = [Task].[id] INNER JOIN [project] AS [Task->Project] ON [Task].[project_id] = [Task->Project].[id] ORDER BY [Task->Project].[created_at] ASC, [Task->Project].[created_at], [Task].[created_at] ASC, [Task].[created_at], [Task->Project].[created_at] ASC, [Task->Project].[created_at], [Task].[created_at] ASC, [Task].[created_at], [Task->Project].[created_at] ASC, [Task->Project].[created_at], [Task].[created_at] ASC, [Task].[created_at], [Task->Project].[created_at] ASC, [Task->Project].[created_at], [Task].[created_at] ASC, [Task].[created_at], [Subtask].[created_at] ASC, [Subtask].[created_at], [Subtask].[created_at];', + oracle: 'SELECT "Subtask"."id", "Subtask"."name", "Subtask"."createdAt", "Task"."id" AS "Task.id", "Task"."name" AS "Task.name", "Task"."created_at" AS "Task.createdAt", "Task->Project"."id" AS "Task.Project.id", "Task->Project"."name" AS "Task.Project.name", "Task->Project"."created_at" AS "Task.Project.createdAt" FROM "subtask" "Subtask" INNER JOIN "task" "Task" ON "Subtask"."task_id" = "Task"."id" INNER JOIN "project" "Task->Project" ON "Task"."project_id" = "Task->Project"."id" ORDER BY "Task->Project"."created_at" ASC, "Task->Project"."created_at", "Task"."created_at" ASC, "Task"."created_at", "Task->Project"."created_at" ASC, "Task->Project"."created_at", "Task"."created_at" ASC, "Task"."created_at", "Task->Project"."created_at" ASC, "Task->Project"."created_at", "Task"."created_at" ASC, "Task"."created_at", "Task->Project"."created_at" ASC, "Task->Project"."created_at", "Task"."created_at" ASC, "Task"."created_at", "Subtask"."created_at" ASC, "Subtask"."created_at", "Subtask"."created_at";', postgres: 'SELECT "Subtask"."id", "Subtask"."name", "Subtask"."createdAt", "Task"."id" AS "Task.id", "Task"."name" AS "Task.name", "Task"."created_at" AS "Task.createdAt", "Task->Project"."id" AS "Task.Project.id", "Task->Project"."name" AS "Task.Project.name", "Task->Project"."created_at" AS "Task.Project.createdAt" FROM "subtask" AS "Subtask" INNER JOIN "task" AS "Task" ON "Subtask"."task_id" = "Task"."id" INNER JOIN "project" AS "Task->Project" ON "Task"."project_id" = "Task->Project"."id" ORDER BY "Task->Project"."created_at" ASC, "Task->Project"."created_at", "Task"."created_at" ASC, "Task"."created_at", "Task->Project"."created_at" ASC, "Task->Project"."created_at", "Task"."created_at" ASC, "Task"."created_at", "Task->Project"."created_at" ASC, "Task->Project"."created_at", "Task"."created_at" ASC, "Task"."created_at", "Task->Project"."created_at" ASC, "Task->Project"."created_at", "Task"."created_at" ASC, "Task"."created_at", "Subtask"."created_at" ASC, "Subtask"."created_at", "Subtask"."created_at";' }); @@ -357,6 +358,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { mysql: 'SELECT `id`, `name` FROM `subtask` AS `Subtask` ORDER BY RAND();', postgres: 'SELECT "id", "name" FROM "subtask" AS "Subtask" ORDER BY RANDOM();', snowflake: 'SELECT "id", "name" FROM "subtask" AS "Subtask" ORDER BY RANDOM();', + oracle: 'SELECT "id", "name" FROM "subtask" "Subtask" ORDER BY RAND();', sqlite: 'SELECT `id`, `name` FROM `subtask` AS `Subtask` ORDER BY RANDOM();' }); diff --git a/test/unit/sql/remove-column.test.js b/test/unit/sql/remove-column.test.js index fc4f3fa6ee52..11c352ce36f2 100644 --- a/test/unit/sql/remove-column.test.js +++ b/test/unit/sql/remove-column.test.js @@ -1,15 +1,21 @@ 'use strict'; -const Support = require('../support'), - expectsql = Support.expectsql, - current = Support.sequelize, - sql = current.dialect.queryGenerator; +const Support = require('../support'); + +const expectsql = Support.expectsql; +const current = Support.sequelize; +const sql = current.dialect.queryGenerator; + +const customSequelize = Support.createSequelizeInstance({ + schema: 'custom' +}); +const customSql = customSequelize.dialect.queryGenerator; // Notice: [] will be replaced by dialect specific tick/quote character when there is not dialect specific expectation but only a default expectation -if (current.dialect.name !== 'sqlite') { - describe(Support.getTestDialectTeaser('SQL'), () => { - describe('removeColumn', () => { +describe(Support.getTestDialectTeaser('SQL'), () => { + describe('removeColumn', () => { + if (current.dialect.name !== 'sqlite') { it('schema', () => { expectsql(sql.removeColumnQuery({ schema: 'archive', @@ -20,9 +26,25 @@ if (current.dialect.name !== 'sqlite') { mariadb: 'ALTER TABLE `archive`.`user` DROP `email`;', mysql: 'ALTER TABLE `archive.user` DROP `email`;', postgres: 'ALTER TABLE "archive"."user" DROP COLUMN "email";', - snowflake: 'ALTER TABLE "archive"."user" DROP "email";' + snowflake: 'ALTER TABLE "archive"."user" DROP "email";', + oracle: 'ALTER TABLE "archive"."user" DROP COLUMN "email";' }); }); + } + + it('defaults the schema to the one set in the Sequelize options', () => { + expectsql(customSql.removeColumnQuery({ + tableName: 'user' + }, 'email'), { + mssql: 'ALTER TABLE [user] DROP COLUMN [email];', + db2: 'ALTER TABLE "user" DROP COLUMN "email";', + mariadb: 'ALTER TABLE `user` DROP `email`;', + mysql: 'ALTER TABLE `user` DROP `email`;', + postgres: 'ALTER TABLE "custom"."user" DROP COLUMN "email";', + snowflake: 'ALTER TABLE "user" DROP "email";', + sqlite: 'CREATE TABLE IF NOT EXISTS `user_backup` (`0` e, `1` m, `2` a, `3` i, `4` l);INSERT INTO `user_backup` SELECT `0`, `1`, `2`, `3`, `4` FROM `user`;DROP TABLE `user`;CREATE TABLE IF NOT EXISTS `user` (`0` e, `1` m, `2` a, `3` i, `4` l);INSERT INTO `user` SELECT `0`, `1`, `2`, `3`, `4` FROM `user_backup`;DROP TABLE `user_backup`;', + oracle: 'ALTER TABLE "user" DROP COLUMN "email";' + }); }); }); -} +}); diff --git a/test/unit/sql/select.test.js b/test/unit/sql/select.test.js index 646128710186..008a2b38665a 100644 --- a/test/unit/sql/select.test.js +++ b/test/unit/sql/select.test.js @@ -15,10 +15,10 @@ const Support = require('../support'), describe(Support.getTestDialectTeaser('SQL'), () => { describe('select', () => { - const testsql = function(options, expectation) { + const testsql = function(options, expectation, testFunction = it) { const model = options.model; - it(util.inspect(options, { depth: 2 }), () => { + testFunction(util.inspect(options, { depth: 2 }), () => { return expectsql( sql.selectQuery( options.table || model && model.getTableName(), @@ -30,6 +30,8 @@ describe(Support.getTestDialectTeaser('SQL'), () => { }); }; + testsql.only = (options, expectation) => testsql(options, expectation, it.only); + testsql({ table: 'User', attributes: [ @@ -46,6 +48,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { }, { default: "SELECT [email], [first_name] AS [firstName] FROM [User] WHERE [User].[email] = 'jon.snow@gmail.com' ORDER BY [email] DESC LIMIT 10;", db2: 'SELECT "email", "first_name" AS "firstName" FROM "User" WHERE "User"."email" = \'jon.snow@gmail.com\' ORDER BY "email" DESC FETCH NEXT 10 ROWS ONLY;', + oracle: 'SELECT "email", "first_name" AS "firstName" FROM "User" WHERE "User"."email" = \'jon.snow@gmail.com\' ORDER BY "email" DESC OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY;', mssql: "SELECT [email], [first_name] AS [firstName] FROM [User] WHERE [User].[email] = N'jon.snow@gmail.com' ORDER BY [email] DESC OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY;" }); @@ -68,6 +71,12 @@ describe(Support.getTestDialectTeaser('SQL'), () => { ] } }, { + oracle: `SELECT "User".* FROM (${ + [ + `SELECT * FROM (SELECT "email", "first_name" AS "firstName", "last_name" AS "lastName" FROM "User" WHERE "User"."companyId" = 1 ORDER BY "last_name" ASC${sql.addLimitAndOffset({ limit: 3, order: ['last_name', 'ASC'] })}) sub`, + `SELECT * FROM (SELECT "email", "first_name" AS "firstName", "last_name" AS "lastName" FROM "User" WHERE "User"."companyId" = 5 ORDER BY "last_name" ASC${sql.addLimitAndOffset({ limit: 3, order: ['last_name', 'ASC'] })}) sub` + ].join(current.dialect.supports['UNION ALL'] ? ' UNION ALL ' : ' UNION ') + }) "User" ORDER BY "last_name" ASC;`, default: `SELECT [User].* FROM (${ [ `SELECT * FROM (SELECT [email], [first_name] AS [firstName], [last_name] AS [lastName] FROM [User] WHERE [User].[companyId] = 1 ORDER BY [last_name] ASC${sql.addLimitAndOffset({ limit: 3, order: ['last_name', 'ASC'] })}) AS sub`, @@ -126,7 +135,11 @@ describe(Support.getTestDialectTeaser('SQL'), () => { `SELECT * FROM (SELECT [user].[id_user] AS [id], [user].[last_name] AS [subquery_order_0], [project_users].[user_id] AS [project_users.userId], [project_users].[project_id] AS [project_users.projectId] FROM [users] AS [user] INNER JOIN [project_users] AS [project_users] ON [user].[id_user] = [project_users].[user_id] AND [project_users].[project_id] = 1 ORDER BY [subquery_order_0] ASC${ current.dialect.name === 'mssql' ? ', [user].[id_user]' : ''}${sql.addLimitAndOffset({ limit: 3, order: ['last_name', 'ASC'] })}) AS sub`, `SELECT * FROM (SELECT [user].[id_user] AS [id], [user].[last_name] AS [subquery_order_0], [project_users].[user_id] AS [project_users.userId], [project_users].[project_id] AS [project_users.projectId] FROM [users] AS [user] INNER JOIN [project_users] AS [project_users] ON [user].[id_user] = [project_users].[user_id] AND [project_users].[project_id] = 5 ORDER BY [subquery_order_0] ASC${ current.dialect.name === 'mssql' ? ', [user].[id_user]' : ''}${sql.addLimitAndOffset({ limit: 3, order: ['last_name', 'ASC'] })}) AS sub` ].join(current.dialect.supports['UNION ALL'] ? ' UNION ALL ' : ' UNION ') - }) AS [user] ORDER BY [subquery_order_0] ASC;` + }) AS [user] ORDER BY [subquery_order_0] ASC;`, + oracle: 'SELECT "user".* FROM (' + + 'SELECT * FROM (SELECT "user"."id_user" AS "id", "user"."last_name" AS "subquery_order_0", "project_users"."user_id" AS "project_users.userId", "project_users"."project_id" AS "project_users.projectId" FROM "users" "user" INNER JOIN "project_users" "project_users" ON "user"."id_user" = "project_users"."user_id" AND "project_users"."project_id" = 1 ORDER BY "subquery_order_0" ASC OFFSET 0 ROWS FETCH NEXT 3 ROWS ONLY) sub UNION ALL ' + + 'SELECT * FROM (SELECT "user"."id_user" AS "id", "user"."last_name" AS "subquery_order_0", "project_users"."user_id" AS "project_users.userId", "project_users"."project_id" AS "project_users.projectId" FROM "users" "user" INNER JOIN "project_users" "project_users" ON "user"."id_user" = "project_users"."user_id" AND "project_users"."project_id" = 5 ORDER BY "subquery_order_0" ASC OFFSET 0 ROWS FETCH NEXT 3 ROWS ONLY) sub)' + + ' "user" ORDER BY "subquery_order_0" ASC;' }); testsql({ @@ -157,7 +170,11 @@ describe(Support.getTestDialectTeaser('SQL'), () => { `SELECT * FROM (SELECT [user].[id_user] AS [id], [user].[last_name] AS [subquery_order_0], [project_users].[user_id] AS [project_users.userId], [project_users].[project_id] AS [project_users.projectId] FROM [users] AS [user] INNER JOIN [project_users] AS [project_users] ON [user].[id_user] = [project_users].[user_id] AND [project_users].[project_id] = 1 AND [project_users].[status] = 1 ORDER BY [subquery_order_0] ASC${ current.dialect.name === 'mssql' ? ', [user].[id_user]' : ''}${sql.addLimitAndOffset({ limit: 3, order: ['last_name', 'ASC'] })}) AS sub`, `SELECT * FROM (SELECT [user].[id_user] AS [id], [user].[last_name] AS [subquery_order_0], [project_users].[user_id] AS [project_users.userId], [project_users].[project_id] AS [project_users.projectId] FROM [users] AS [user] INNER JOIN [project_users] AS [project_users] ON [user].[id_user] = [project_users].[user_id] AND [project_users].[project_id] = 5 AND [project_users].[status] = 1 ORDER BY [subquery_order_0] ASC${ current.dialect.name === 'mssql' ? ', [user].[id_user]' : ''}${sql.addLimitAndOffset({ limit: 3, order: ['last_name', 'ASC'] })}) AS sub` ].join(current.dialect.supports['UNION ALL'] ? ' UNION ALL ' : ' UNION ') - }) AS [user] ORDER BY [subquery_order_0] ASC;` + }) AS [user] ORDER BY [subquery_order_0] ASC;`, + oracle: 'SELECT "user".* FROM (' + + 'SELECT * FROM (SELECT "user"."id_user" AS "id", "user"."last_name" AS "subquery_order_0", "project_users"."user_id" AS "project_users.userId", "project_users"."project_id" AS "project_users.projectId" FROM "users" "user" INNER JOIN "project_users" "project_users" ON "user"."id_user" = "project_users"."user_id" AND "project_users"."project_id" = 1 AND "project_users"."status" = 1 ORDER BY "subquery_order_0" ASC OFFSET 0 ROWS FETCH NEXT 3 ROWS ONLY) sub UNION ALL ' + + 'SELECT * FROM (SELECT "user"."id_user" AS "id", "user"."last_name" AS "subquery_order_0", "project_users"."user_id" AS "project_users.userId", "project_users"."project_id" AS "project_users.projectId" FROM "users" "user" INNER JOIN "project_users" "project_users" ON "user"."id_user" = "project_users"."user_id" AND "project_users"."project_id" = 5 AND "project_users"."status" = 1 ORDER BY "subquery_order_0" ASC OFFSET 0 ROWS FETCH NEXT 3 ROWS ONLY) sub)' + + ' "user" ORDER BY "subquery_order_0" ASC;' }); testsql({ @@ -188,7 +205,12 @@ describe(Support.getTestDialectTeaser('SQL'), () => { `SELECT * FROM (SELECT [user].[id_user] AS [id], [user].[id_user] AS [subquery_order_0], [project_users].[user_id] AS [project_users.userId], [project_users].[project_id] AS [project_users.projectId] FROM [users] AS [user] INNER JOIN [project_users] AS [project_users] ON [user].[id_user] = [project_users].[user_id] AND [project_users].[project_id] = 1 WHERE [user].[age] >= 21 ORDER BY [subquery_order_0] ASC${ current.dialect.name === 'mssql' ? ', [user].[id_user]' : ''}${sql.addLimitAndOffset({ limit: 3, order: ['last_name', 'ASC'] })}) AS sub`, `SELECT * FROM (SELECT [user].[id_user] AS [id], [user].[id_user] AS [subquery_order_0], [project_users].[user_id] AS [project_users.userId], [project_users].[project_id] AS [project_users.projectId] FROM [users] AS [user] INNER JOIN [project_users] AS [project_users] ON [user].[id_user] = [project_users].[user_id] AND [project_users].[project_id] = 5 WHERE [user].[age] >= 21 ORDER BY [subquery_order_0] ASC${ current.dialect.name === 'mssql' ? ', [user].[id_user]' : ''}${sql.addLimitAndOffset({ limit: 3, order: ['last_name', 'ASC'] })}) AS sub` ].join(current.dialect.supports['UNION ALL'] ? ' UNION ALL ' : ' UNION ') - }) AS [user] ORDER BY [subquery_order_0] ASC;` + }) AS [user] ORDER BY [subquery_order_0] ASC;`, + oracle: 'SELECT "user".* FROM (' + + 'SELECT * FROM (SELECT "user"."id_user" AS "id", "user"."id_user" AS "subquery_order_0", "project_users"."user_id" AS "project_users.userId", "project_users"."project_id" AS "project_users.projectId" FROM "users" "user" INNER JOIN "project_users" "project_users" ON "user"."id_user" = "project_users"."user_id" AND "project_users"."project_id" = 1 WHERE "user"."age" >= 21 ORDER BY "subquery_order_0" ASC OFFSET 0 ROWS FETCH NEXT 3 ROWS ONLY) sub UNION ALL ' + + 'SELECT * FROM (SELECT "user"."id_user" AS "id", "user"."id_user" AS "subquery_order_0", "project_users"."user_id" AS "project_users.userId", "project_users"."project_id" AS "project_users.projectId" FROM "users" "user" INNER JOIN "project_users" "project_users" ON "user"."id_user" = "project_users"."user_id" AND "project_users"."project_id" = 5 WHERE "user"."age" >= 21 ORDER BY "subquery_order_0" ASC OFFSET 0 ROWS FETCH NEXT 3 ROWS ONLY) sub) ' + + '"user" ORDER BY "subquery_order_0" ASC;' + }); }()); @@ -269,10 +291,14 @@ describe(Support.getTestDialectTeaser('SQL'), () => { ] } }, { + oracle: 'SELECT "user".*, "POSTS"."id" AS "POSTS.id", "POSTS"."title" AS "POSTS.title" FROM (' + + 'SELECT * FROM (SELECT "id_user" AS "id", "email", "first_name" AS "firstName", "last_name" AS "lastName" FROM "users" "user" WHERE "user"."companyId" = 1 ORDER BY "lastName" ASC OFFSET 0 ROWS FETCH NEXT 3 ROWS ONLY) sub UNION ALL ' + + 'SELECT * FROM (SELECT "id_user" AS "id", "email", "first_name" AS "firstName", "last_name" AS "lastName" FROM "users" "user" WHERE "user"."companyId" = 5 ORDER BY "lastName" ASC OFFSET 0 ROWS FETCH NEXT 3 ROWS ONLY) sub) ' + + '"user" LEFT OUTER JOIN "post" "POSTS" ON "user"."id" = "POSTS"."user_id" ORDER BY "lastName" ASC;', default: `SELECT [user].*, [POSTS].[id] AS [POSTS.id], [POSTS].[title] AS [POSTS.title] FROM (${ [ - `SELECT * FROM (SELECT [id_user] AS [id], [email], [first_name] AS [firstName], [last_name] AS [lastName] FROM [users] AS [user] WHERE [user].[companyId] = 1 ORDER BY [user].[last_name] ASC${sql.addLimitAndOffset({ limit: 3, order: [['last_name', 'ASC']] })}) AS sub`, - `SELECT * FROM (SELECT [id_user] AS [id], [email], [first_name] AS [firstName], [last_name] AS [lastName] FROM [users] AS [user] WHERE [user].[companyId] = 5 ORDER BY [user].[last_name] ASC${sql.addLimitAndOffset({ limit: 3, order: [['last_name', 'ASC']] })}) AS sub` + `SELECT * FROM (SELECT [id_user] AS [id], [email], [first_name] AS [firstName], [last_name] AS [lastName] FROM [users] AS [user] WHERE [user].[companyId] = 1 ORDER BY [lastName] ASC${sql.addLimitAndOffset({ limit: 3, order: [['last_name', 'ASC']] })}) AS sub`, + `SELECT * FROM (SELECT [id_user] AS [id], [email], [first_name] AS [firstName], [last_name] AS [lastName] FROM [users] AS [user] WHERE [user].[companyId] = 5 ORDER BY [lastName] ASC${sql.addLimitAndOffset({ limit: 3, order: [['last_name', 'ASC']] })}) AS sub` ].join(current.dialect.supports['UNION ALL'] ? ' UNION ALL ' : ' UNION ') }) AS [user] LEFT OUTER JOIN [post] AS [POSTS] ON [user].[id] = [POSTS].[user_id];` }); @@ -293,12 +319,42 @@ describe(Support.getTestDialectTeaser('SQL'), () => { hasMultiAssociation: true, //must be set only for mssql dialect here subQuery: true }, { + oracle: 'SELECT "user".*, "POSTS"."id" AS "POSTS.id", "POSTS"."title" AS "POSTS.title" FROM (' + + 'SELECT "user"."id_user" AS "id", "user"."email", "user"."first_name" AS "firstName", "user"."last_name" AS "lastName" FROM "users" "user" ORDER BY "user"."last_name" ASC OFFSET 10 ROWS FETCH NEXT 30 ROWS ONLY)' + + ' "user" LEFT OUTER JOIN "post" "POSTS" ON "user"."id_user" = "POSTS"."user_id" ORDER BY "user"."last_name" ASC;', default: `${'SELECT [user].*, [POSTS].[id] AS [POSTS.id], [POSTS].[title] AS [POSTS.title] FROM (' + 'SELECT [user].[id_user] AS [id], [user].[email], [user].[first_name] AS [firstName], [user].[last_name] AS [lastName] FROM [users] AS [user] ORDER BY [user].[last_name] ASC'}${ sql.addLimitAndOffset({ limit: 30, offset: 10, order: [['`user`.`last_name`', 'ASC']] }) }) AS [user] LEFT OUTER JOIN [post] AS [POSTS] ON [user].[id_user] = [POSTS].[user_id] ORDER BY [user].[last_name] ASC;` }); + // By default, SELECT with include of a multi association & limit will be ran as a subQuery + // This checks the result when the query is forced to be ran without a subquery + testsql({ + table: User.getTableName(), + model: User, + include, + attributes: [ + ['id_user', 'id'], + 'email', + ['first_name', 'firstName'], + ['last_name', 'lastName'] + ], + order: [['[last_name]'.replace(/\[/g, Support.sequelize.dialect.TICK_CHAR_LEFT).replace(/\]/g, Support.sequelize.dialect.TICK_CHAR_RIGHT), 'ASC']], + limit: 30, + offset: 10, + hasMultiAssociation: true, // must be set only for mssql dialect here + subQuery: false + }, { + oracle: 'SELECT "user"."id_user" AS "id", "user"."email", "user"."first_name" AS "firstName", "user"."last_name" AS "lastName", "POSTS"."id" AS "POSTS.id", "POSTS"."title" AS "POSTS.title" FROM "users" "user" LEFT OUTER JOIN "post" "POSTS" ON "user"."id_user" = "POSTS"."user_id" ORDER BY "user"."last_name" ASC OFFSET 10 ROWS FETCH NEXT 30 ROWS ONLY;', + default: Support.minifySql(`SELECT [user].[id_user] AS [id], [user].[email], [user].[first_name] AS [firstName], [user].[last_name] AS [lastName], [POSTS].[id] AS [POSTS.id], [POSTS].[title] AS [POSTS.title] + FROM [users] AS [user] LEFT OUTER JOIN [post] AS [POSTS] + ON [user].[id_user] = [POSTS].[user_id] + ORDER BY [user].[last_name] ASC + ${sql.addLimitAndOffset({ limit: 30, offset: 10, order: [['last_name', 'ASC']], include }, User)}; + `) + }); + const nestedInclude = Model._validateIncludedElements({ include: [{ attributes: ['title'], @@ -333,10 +389,14 @@ describe(Support.getTestDialectTeaser('SQL'), () => { ] } }, { + oracle: 'SELECT "user".*, "POSTS"."id" AS "POSTS.id", "POSTS"."title" AS "POSTS.title", "POSTS->COMMENTS"."id" AS "POSTS.COMMENTS.id", "POSTS->COMMENTS"."title" AS "POSTS.COMMENTS.title" FROM (' + + 'SELECT * FROM (SELECT "id_user" AS "id", "email", "first_name" AS "firstName", "last_name" AS "lastName" FROM "users" "user" WHERE "user"."companyId" = 1 ORDER BY "lastName" ASC OFFSET 0 ROWS FETCH NEXT 3 ROWS ONLY) sub UNION ALL ' + + 'SELECT * FROM (SELECT "id_user" AS "id", "email", "first_name" AS "firstName", "last_name" AS "lastName" FROM "users" "user" WHERE "user"."companyId" = 5 ORDER BY "lastName" ASC OFFSET 0 ROWS FETCH NEXT 3 ROWS ONLY) sub)' + + ' "user" LEFT OUTER JOIN "post" "POSTS" ON "user"."id" = "POSTS"."user_id" LEFT OUTER JOIN "comment" "POSTS->COMMENTS" ON "POSTS"."id" = "POSTS->COMMENTS"."post_id" ORDER BY "lastName" ASC;', default: `SELECT [user].*, [POSTS].[id] AS [POSTS.id], [POSTS].[title] AS [POSTS.title], [POSTS->COMMENTS].[id] AS [POSTS.COMMENTS.id], [POSTS->COMMENTS].[title] AS [POSTS.COMMENTS.title] FROM (${ [ - `SELECT * FROM (SELECT [id_user] AS [id], [email], [first_name] AS [firstName], [last_name] AS [lastName] FROM [users] AS [user] WHERE [user].[companyId] = 1 ORDER BY [user].[last_name] ASC${sql.addLimitAndOffset({ limit: 3, order: ['last_name', 'ASC'] })}) AS sub`, - `SELECT * FROM (SELECT [id_user] AS [id], [email], [first_name] AS [firstName], [last_name] AS [lastName] FROM [users] AS [user] WHERE [user].[companyId] = 5 ORDER BY [user].[last_name] ASC${sql.addLimitAndOffset({ limit: 3, order: ['last_name', 'ASC'] })}) AS sub` + `SELECT * FROM (SELECT [id_user] AS [id], [email], [first_name] AS [firstName], [last_name] AS [lastName] FROM [users] AS [user] WHERE [user].[companyId] = 1 ORDER BY [lastName] ASC${sql.addLimitAndOffset({ limit: 3, order: ['last_name', 'ASC'] })}) AS sub`, + `SELECT * FROM (SELECT [id_user] AS [id], [email], [first_name] AS [firstName], [last_name] AS [lastName] FROM [users] AS [user] WHERE [user].[companyId] = 5 ORDER BY [lastName] ASC${sql.addLimitAndOffset({ limit: 3, order: ['last_name', 'ASC'] })}) AS sub` ].join(current.dialect.supports['UNION ALL'] ? ' UNION ALL ' : ' UNION ') }) AS [user] LEFT OUTER JOIN [post] AS [POSTS] ON [user].[id] = [POSTS].[user_id] LEFT OUTER JOIN [comment] AS [POSTS->COMMENTS] ON [POSTS].[id] = [POSTS->COMMENTS].[post_id];` }); @@ -370,6 +430,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { }).include, model: User }, User), { + oracle: 'SELECT "User"."name", "User"."age", "Posts"."id" AS "Posts.id", "Posts"."title" AS "Posts.title" FROM "User" "User" LEFT OUTER JOIN "Post" "Posts" ON "User"."id" = "Posts"."user_id";', default: 'SELECT [User].[name], [User].[age], [Posts].[id] AS [Posts.id], [Posts].[title] AS [Posts.title] FROM [User] AS [User] LEFT OUTER JOIN [Post] AS [Posts] ON [User].[id] = [Posts].[user_id];' }); }); @@ -403,6 +464,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { }).include, model: User }, User), { + oracle: 'SELECT "User"."name", "User"."age", "Posts"."id" AS "Posts.id", "Posts"."title" AS "Posts.title" FROM "User" "User" RIGHT OUTER JOIN "Post" "Posts" ON "User"."id" = "Posts"."user_id";', default: `SELECT [User].[name], [User].[age], [Posts].[id] AS [Posts.id], [Posts].[title] AS [Posts.title] FROM [User] AS [User] ${current.dialect.supports['RIGHT JOIN'] ? 'RIGHT' : 'LEFT'} OUTER JOIN [Post] AS [Posts] ON [User].[id] = [Posts].[user_id];` }); }); @@ -445,7 +507,8 @@ describe(Support.getTestDialectTeaser('SQL'), () => { }).include, model: User }, User), { - default: `SELECT [user].[id_user], [user].[id], [projects].[id] AS [projects.id], [projects].[title] AS [projects.title], [projects].[createdAt] AS [projects.createdAt], [projects].[updatedAt] AS [projects.updatedAt], [projects->project_user].[user_id] AS [projects.project_user.userId], [projects->project_user].[project_id] AS [projects.project_user.projectId] FROM [User] AS [user] ${current.dialect.supports['RIGHT JOIN'] ? 'RIGHT' : 'LEFT'} OUTER JOIN ( [project_users] AS [projects->project_user] INNER JOIN [projects] AS [projects] ON [projects].[id] = [projects->project_user].[project_id]) ON [user].[id_user] = [projects->project_user].[user_id];` + default: `SELECT [user].[id_user], [user].[id], [projects].[id] AS [projects.id], [projects].[title] AS [projects.title], [projects].[createdAt] AS [projects.createdAt], [projects].[updatedAt] AS [projects.updatedAt], [projects->project_user].[user_id] AS [projects.project_user.userId], [projects->project_user].[project_id] AS [projects.project_user.projectId] FROM [User] AS [user] ${current.dialect.supports['RIGHT JOIN'] ? 'RIGHT' : 'LEFT'} OUTER JOIN ( [project_users] AS [projects->project_user] INNER JOIN [projects] AS [projects] ON [projects].[id] = [projects->project_user].[project_id]) ON [user].[id_user] = [projects->project_user].[user_id];`, + oracle: 'SELECT "user"."id_user", "user"."id", "projects"."id" AS "projects.id", "projects"."title" AS "projects.title", "projects"."createdAt" AS "projects.createdAt", "projects"."updatedAt" AS "projects.updatedAt", "projects->project_user"."user_id" AS "projects.project_user.userId", "projects->project_user"."project_id" AS "projects.project_user.projectId" FROM "User" "user" RIGHT OUTER JOIN ( "project_users" "projects->project_user" INNER JOIN "projects" "projects" ON "projects"."id" = "projects->project_user"."project_id") ON "user"."id_user" = "projects->project_user"."user_id";' }); }); @@ -482,6 +545,9 @@ describe(Support.getTestDialectTeaser('SQL'), () => { }).include, subQuery: true }, User), { + oracle: 'SELECT "User".* FROM ' + + '(SELECT "User"."name", "User"."age", "User"."id" AS "id", "postaliasname"."id" AS "postaliasname.id", "postaliasname"."title" AS "postaliasname.title" FROM "User" "User" ' + + 'INNER JOIN "Post" "postaliasname" ON "User"."id" = "postaliasname"."user_id" WHERE ( SELECT "user_id" FROM "Post" "postaliasname" WHERE ("postaliasname"."user_id" = "User"."id") ORDER BY "postaliasname"."id" OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY ) IS NOT NULL) "User";', default: 'SELECT [User].* FROM ' + '(SELECT [User].[name], [User].[age], [User].[id] AS [id], [postaliasname].[id] AS [postaliasname.id], [postaliasname].[title] AS [postaliasname.title] FROM [User] AS [User] ' + 'INNER JOIN [Post] AS [postaliasname] ON [User].[id] = [postaliasname].[user_id] ' + @@ -506,6 +572,10 @@ describe(Support.getTestDialectTeaser('SQL'), () => { }).include, subQuery: true }, User), { + oracle: 'SELECT "User".* FROM ' + + '(SELECT "User"."name", "User"."age", "User"."id" AS "id", "postaliasname"."id" AS "postaliasname.id", "postaliasname"."title" AS "postaliasname.title" FROM "User" "User" ' + + 'INNER JOIN "Post" "postaliasname" ON "User"."id" = "postaliasname"."user_id" WHERE "postaliasname"."title" = \'test\' AND ( SELECT "user_id" FROM "Post" "postaliasname" ' + + 'WHERE ("postaliasname"."user_id" = "User"."id") ORDER BY "postaliasname"."id" OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY ) IS NOT NULL) "User";', default: 'SELECT [User].* FROM ' + '(SELECT [User].[name], [User].[age], [User].[id] AS [id], [postaliasname].[id] AS [postaliasname.id], [postaliasname].[title] AS [postaliasname.title] FROM [User] AS [User] ' + 'INNER JOIN [Post] AS [postaliasname] ON [User].[id] = [postaliasname].[user_id] ' + @@ -558,6 +628,15 @@ describe(Support.getTestDialectTeaser('SQL'), () => { offset: 0, subQuery: true }, Company), { + oracle: 'SELECT "Company".* FROM (' + + 'SELECT "Company"."name", "Company"."public", "Company"."id" AS "id" FROM "Company" "Company" ' + + 'INNER JOIN "Users" "Users" ON "Company"."id" = "Users"."companyId" ' + + 'INNER JOIN "Professions" "Users->Profession" ON "Users"."professionId" = "Users->Profession"."id" ' + + 'WHERE ("Company"."scopeId" IN (42)) AND "Users->Profession"."name" = \'test\' AND ( ' + + 'SELECT "Users"."companyId" FROM "Users" "Users" ' + + 'INNER JOIN "Professions" "Profession" ON "Users"."professionId" = "Profession"."id" ' + + 'WHERE ("Users"."companyId" = "Company"."id") ORDER BY "Users"."id" OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY ) ' + + 'IS NOT NULL ORDER BY "Company"."id" OFFSET 0 ROWS FETCH NEXT 5 ROWS ONLY) "Company";', default: 'SELECT [Company].* FROM (' + 'SELECT [Company].[name], [Company].[public], [Company].[id] AS [id] FROM [Company] AS [Company] ' + 'INNER JOIN [Users] AS [Users] ON [Company].[id] = [Users].[companyId] ' + @@ -591,6 +670,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { mysql: 'SELECT `name`, `age`, `data` FROM `User` AS `User` WHERE `User`.`data` IN (X\'313233\');', sqlite: 'SELECT `name`, `age`, `data` FROM `User` AS `User` WHERE `User`.`data` IN (X\'313233\');', db2: "SELECT \"name\", \"age\", \"data\" FROM \"User\" AS \"User\" WHERE \"User\".\"data\" IN ('x''313233''');", + oracle: 'SELECT "name", "age", "data" FROM "User" "User" WHERE "User"."data" IN (\'313233\');', mssql: 'SELECT [name], [age], [data] FROM [User] AS [User] WHERE [User].[data] IN (0x313233);' }); }); @@ -690,7 +770,8 @@ describe(Support.getTestDialectTeaser('SQL'), () => { }).include, model: User }, User), { - default: 'SELECT [User].[name], [User].[age], [Posts].[id] AS [Posts.id], [Posts].[* FROM User; DELETE FROM User;SELECT id] AS [Posts.* FROM User; DELETE FROM User;SELECT id] FROM [User] AS [User] LEFT OUTER JOIN [Post] AS [Posts] ON [User].[id] = [Posts].[user_id];' + default: 'SELECT [User].[name], [User].[age], [Posts].[id] AS [Posts.id], [Posts].[* FROM User; DELETE FROM User;SELECT id] AS [Posts.* FROM User; DELETE FROM User;SELECT id] FROM [User] AS [User] LEFT OUTER JOIN [Post] AS [Posts] ON [User].[id] = [Posts].[user_id];', + oracle: 'SELECT "User"."name", "User"."age", "Posts"."id" AS "Posts.id", "Posts"."* FROM User; DELETE FROM User;SELECT id" AS "Posts.* FROM User; DELETE FROM User;SELECT id" FROM "User" "User" LEFT OUTER JOIN "Post" "Posts" ON "User"."id" = "Posts"."user_id";' }); expectsql(sql.selectQuery('User', { @@ -706,6 +787,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { }).include, model: User }, User), { + oracle: 'SELECT "User"."name", "User"."age", "Posts"."id" AS "Posts.id", "Posts"."* FROM User; DELETE FROM User;SELECT id" AS "Posts.data" FROM "User" "User" LEFT OUTER JOIN "Post" "Posts" ON "User"."id" = "Posts"."user_id";', default: 'SELECT [User].[name], [User].[age], [Posts].[id] AS [Posts.id], [Posts].[* FROM User; DELETE FROM User;SELECT id] AS [Posts.data] FROM [User] AS [User] LEFT OUTER JOIN [Post] AS [Posts] ON [User].[id] = [Posts].[user_id];' }); @@ -722,6 +804,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { }).include, model: User }, User), { + oracle: 'SELECT "User"."name", "User"."age", "Posts"."id" AS "Posts.id", "Posts"."* FROM User; DELETE FROM User;SELECT id" AS "Posts.data" FROM "User" "User" LEFT OUTER JOIN "Post" "Posts" ON "User"."id" = "Posts"."user_id";', default: 'SELECT [User].[name], [User].[age], [Posts].[id] AS [Posts.id], [Posts].[* FROM User; DELETE FROM User;SELECT id] AS [Posts.data] FROM [User] AS [User] LEFT OUTER JOIN [Post] AS [Posts] ON [User].[id] = [Posts].[user_id];' }); }); @@ -740,6 +823,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { expectsql(sql.selectQuery('User'), { default: 'SELECT * FROM [User];', postgres: 'SELECT * FROM "User";', + oracle: 'SELECT * FROM "User";', snowflake: 'SELECT * FROM User;' }); }); @@ -750,6 +834,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { }), { default: 'SELECT [name], [age] FROM [User];', postgres: 'SELECT name, age FROM "User";', + oracle: 'SELECT name, age FROM "User";', snowflake: 'SELECT name, age FROM User;' }); }); @@ -784,6 +869,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { }, User), { default: 'SELECT [User].[name], [User].[age], [Posts].[id] AS [Posts.id], [Posts].[title] AS [Posts.title] FROM [User] AS [User] LEFT OUTER JOIN [Post] AS [Posts] ON [User].[id] = [Posts].[user_id];', postgres: 'SELECT "User".name, "User".age, Posts.id AS "Posts.id", Posts.title AS "Posts.title" FROM "User" AS "User" LEFT OUTER JOIN Post AS Posts ON "User".id = Posts.user_id;', + oracle: 'SELECT "User".name, "User".age, Posts.id AS "Posts.id", Posts.title AS "Posts.title" FROM "User" "User" LEFT OUTER JOIN Post Posts ON "User".id = Posts.user_id;', snowflake: 'SELECT User.name, User.age, Posts.id AS "Posts.id", Posts.title AS "Posts.title" FROM User AS User LEFT OUTER JOIN Post AS Posts ON User.id = Posts.user_id;' }); }); @@ -831,6 +917,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { }, User), { default: 'SELECT [User].[name], [User].[age], [Posts].[id] AS [Posts.id], [Posts].[title] AS [Posts.title], [Posts->Comments].[id] AS [Posts.Comments.id], [Posts->Comments].[title] AS [Posts.Comments.title], [Posts->Comments].[createdAt] AS [Posts.Comments.createdAt], [Posts->Comments].[updatedAt] AS [Posts.Comments.updatedAt], [Posts->Comments].[post_id] AS [Posts.Comments.post_id] FROM [User] AS [User] LEFT OUTER JOIN [Post] AS [Posts] ON [User].[id] = [Posts].[user_id] LEFT OUTER JOIN [Comment] AS [Posts->Comments] ON [Posts].[id] = [Posts->Comments].[post_id];', postgres: 'SELECT "User".name, "User".age, Posts.id AS "Posts.id", Posts.title AS "Posts.title", "Posts->Comments".id AS "Posts.Comments.id", "Posts->Comments".title AS "Posts.Comments.title", "Posts->Comments".createdAt AS "Posts.Comments.createdAt", "Posts->Comments".updatedAt AS "Posts.Comments.updatedAt", "Posts->Comments".post_id AS "Posts.Comments.post_id" FROM "User" AS "User" LEFT OUTER JOIN Post AS Posts ON "User".id = Posts.user_id LEFT OUTER JOIN Comment AS "Posts->Comments" ON Posts.id = "Posts->Comments".post_id;', + oracle: 'SELECT "User".name, "User".age, Posts.id AS "Posts.id", Posts.title AS "Posts.title", "Posts->Comments".id AS "Posts.Comments.id", "Posts->Comments".title AS "Posts.Comments.title", "Posts->Comments".createdAt AS "Posts.Comments.createdAt", "Posts->Comments".updatedAt AS "Posts.Comments.updatedAt", "Posts->Comments".post_id AS "Posts.Comments.post_id" FROM "User" "User" LEFT OUTER JOIN Post Posts ON "User".id = Posts.user_id LEFT OUTER JOIN "Comment" "Posts->Comments" ON Posts.id = "Posts->Comments".post_id;', snowflake: 'SELECT User.name, User.age, Posts.id AS "Posts.id", Posts.title AS "Posts.title", "Posts->Comments".id AS "Posts.Comments.id", "Posts->Comments".title AS "Posts.Comments.title", "Posts->Comments".createdAt AS "Posts.Comments.createdAt", "Posts->Comments".updatedAt AS "Posts.Comments.updatedAt", "Posts->Comments".post_id AS "Posts.Comments.post_id" FROM User AS User LEFT OUTER JOIN Post AS Posts ON User.id = Posts.user_id LEFT OUTER JOIN Comment AS "Posts->Comments" ON Posts.id = "Posts->Comments".post_id;' }); }); @@ -868,6 +955,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { }, User), { default: 'SELECT [User].[name], [User].[age], [User].[status.label], [Posts].[id] AS [Posts.id], [Posts].[title] AS [Posts.title], [Posts].[status.label] AS [Posts.status.label] FROM [User] AS [User] LEFT OUTER JOIN [Post] AS [Posts] ON [User].[id] = [Posts].[user_id];', postgres: 'SELECT "User".name, "User".age, "User"."status.label", Posts.id AS "Posts.id", Posts.title AS "Posts.title", Posts."status.label" AS "Posts.status.label" FROM "User" AS "User" LEFT OUTER JOIN Post AS Posts ON "User".id = Posts.user_id;', + oracle: 'SELECT "User".name, "User".age, "User"."status.label", Posts.id AS "Posts.id", Posts.title AS "Posts.title", Posts."status.label" AS "Posts.status.label" FROM "User" "User" LEFT OUTER JOIN Post Posts ON "User".id = Posts.user_id;', snowflake: 'SELECT User.name, User.age, User."status.label", Posts.id AS "Posts.id", Posts.title AS "Posts.title", Posts."status.label" AS "Posts.status.label" FROM User AS User LEFT OUTER JOIN Post AS Posts ON User.id = Posts.user_id;' }); }); @@ -929,4 +1017,105 @@ describe(Support.getTestDialectTeaser('SQL'), () => { }).to.throw(Error, 'Support for `{where: \'raw query\'}` has been removed.'); }); }); + + + describe('queryGenerator: selectQuery', () => { + const User = Support.sequelize.define('User', { + username: DataTypes.STRING + }, { timestamps: false }); + + + const Project = Support.sequelize.define('Project', { + duration: DataTypes.BIGINT + }, { timestamps: false }); + + const ProjectContributor = Support.sequelize.define('ProjectContributor', {}, { timestamps: false }); + + // project owners + User.hasMany(Project, { as: 'projects' }); + Project.belongsTo(User, { as: 'owner' }); + + // project contributors + Project.belongsToMany(User, { + through: ProjectContributor, + as: 'contributors' + }); + + it('supports offset without limit', () => { + const query = sql.selectQuery(User.tableName, { + model: User, + attributes: ['id'], + offset: 1 + }, User); + + expectsql(query, { + postgres: 'SELECT "id" FROM "Users" AS "User" OFFSET 1;', + mysql: 'SELECT `id` FROM `Users` AS `User` LIMIT 1, 10000000000000;', //original 'SELECT `id` FROM `Users` AS `User` LIMIT 18446744073709551615 OFFSET 1;', + mariadb: 'SELECT `id` FROM `Users` AS `User` LIMIT 1, 10000000000000;', //original 'SELECT `id` FROM `Users` AS `User` LIMIT 18446744073709551615 OFFSET 1;', + sqlite: 'SELECT `id` FROM `Users` AS `User` LIMIT 1, 10000000000000;', //original 'SELECT `id` FROM `Users` AS `User` LIMIT -1 OFFSET 1;' + oracle: 'SELECT "id" FROM "Users" "User" ORDER BY "User"."id" OFFSET 1 ROWS;', + snowflake: 'SELECT "id" FROM "Users" AS "User" LIMIT NULL OFFSET 1;', + db2: 'SELECT "id" FROM "Users" AS "User" OFFSET 1 ROWS;', + ibmi: 'SELECT "id" FROM "Users" AS "User" OFFSET 1 ROWS', + mssql: 'SELECT [id] FROM [Users] AS [User] ORDER BY [User].[id] OFFSET 1 ROWS;' + }); + }); + + it('supports querying for bigint values', () => { + const query = sql.selectQuery(Project.tableName, { + model: Project, + attributes: ['id'], + where: { + duration: { [Op.eq]: 9007199254740993n } + } + }, Project); + + expectsql(query, { + postgres: 'SELECT "id" FROM "Projects" AS "Project" WHERE "Project"."duration" = 9007199254740993;', + mysql: 'SELECT `id` FROM `Projects` AS `Project` WHERE `Project`.`duration` = 9007199254740993;', + mariadb: 'SELECT `id` FROM `Projects` AS `Project` WHERE `Project`.`duration` = 9007199254740993;', + sqlite: 'SELECT `id` FROM `Projects` AS `Project` WHERE `Project`.`duration` = 9007199254740993;', + oracle: 'SELECT "id" FROM "Projects" "Project" WHERE "Project"."duration" = 9007199254740993;', + snowflake: 'SELECT "id" FROM "Projects" AS "Project" WHERE "Project"."duration" = 9007199254740993;', + db2: 'SELECT "id" FROM "Projects" AS "Project" WHERE "Project"."duration" = 9007199254740993;', + ibmi: 'SELECT "id" FROM "Projects" AS "Project" WHERE "Project"."duration" = \'9007199254740993\'', + mssql: 'SELECT [id] FROM [Projects] AS [Project] WHERE [Project].[duration] = 9007199254740993;' + }); + }); + + it('throws an error if encountering parentheses in an attribute', () => { + expect(() => sql.selectQuery(Project.tableName, { + model: Project, + attributes: [['count(*)', 'count']] + }, Project)).to.throw('In order to fix the vulnerability CVE-2023-22578, we had to remove support for treating attributes as raw SQL if they included parentheses.'); + }); + + it('escapes attributes with parentheses if attributeBehavior is escape', () => { + const escapeSequelize = Support.createSequelizeInstance({ + attributeBehavior: 'escape' + }); + + expectsql(escapeSequelize.queryInterface.queryGenerator.selectQuery(Project.tableName, { + model: Project, + attributes: [['count(*)', 'count']] + }, Project), { + default: 'SELECT [count(*)] AS [count] FROM [Projects] AS [Project];', + oracle: 'SELECT "count(*)" AS "count" FROM "Projects" "Project";' + }); + }); + + it('inlines attributes with parentheses if attributeBehavior is unsafe-legacy', () => { + const escapeSequelize = Support.createSequelizeInstance({ + attributeBehavior: 'unsafe-legacy' + }); + + expectsql(escapeSequelize.queryInterface.queryGenerator.selectQuery(Project.tableName, { + model: Project, + attributes: [['count(*)', 'count']] + }, Project), { + default: 'SELECT count(*) AS [count] FROM [Projects] AS [Project];', + oracle: 'SELECT count(*) AS "count" FROM "Projects" "Project";' + }); + }); + }); }); diff --git a/test/unit/sql/show-constraints.test.js b/test/unit/sql/show-constraints.test.js index aff407f49118..56ef9de590df 100644 --- a/test/unit/sql/show-constraints.test.js +++ b/test/unit/sql/show-constraints.test.js @@ -15,6 +15,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { mysql: "SELECT CONSTRAINT_CATALOG AS constraintCatalog, CONSTRAINT_NAME AS constraintName, CONSTRAINT_SCHEMA AS constraintSchema, CONSTRAINT_TYPE AS constraintType, TABLE_NAME AS tableName, TABLE_SCHEMA AS tableSchema from INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE table_name='myTable';", db2: 'SELECT CONSTNAME AS "constraintName", TRIM(TABSCHEMA) AS "schemaName", TABNAME AS "tableName" FROM SYSCAT.TABCONST WHERE TABNAME = \'myTable\' ORDER BY CONSTNAME;', snowflake: "SELECT CONSTRAINT_CATALOG AS constraintCatalog, CONSTRAINT_NAME AS constraintName, CONSTRAINT_SCHEMA AS constraintSchema, CONSTRAINT_TYPE AS constraintType, TABLE_NAME AS tableName, TABLE_SCHEMA AS tableSchema from INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE table_name='myTable';", + oracle: "SELECT CONSTRAINT_NAME constraint_name FROM user_cons_columns WHERE table_name = 'myTable'", default: "SELECT sql FROM sqlite_master WHERE tbl_name='myTable';" }); }); @@ -27,6 +28,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { mysql: "SELECT CONSTRAINT_CATALOG AS constraintCatalog, CONSTRAINT_NAME AS constraintName, CONSTRAINT_SCHEMA AS constraintSchema, CONSTRAINT_TYPE AS constraintType, TABLE_NAME AS tableName, TABLE_SCHEMA AS tableSchema from INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE table_name='myTable' AND constraint_name = 'myConstraintName';", db2: 'SELECT CONSTNAME AS "constraintName", TRIM(TABSCHEMA) AS "schemaName", TABNAME AS "tableName" FROM SYSCAT.TABCONST WHERE TABNAME = \'myTable\' AND CONSTNAME LIKE \'%myConstraintName%\' ORDER BY CONSTNAME;', snowflake: "SELECT CONSTRAINT_CATALOG AS constraintCatalog, CONSTRAINT_NAME AS constraintName, CONSTRAINT_SCHEMA AS constraintSchema, CONSTRAINT_TYPE AS constraintType, TABLE_NAME AS tableName, TABLE_SCHEMA AS tableSchema from INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE table_name='myTable' AND constraint_name = 'myConstraintName';", + oracle: "SELECT CONSTRAINT_NAME constraint_name FROM user_cons_columns WHERE table_name = 'myTable'", default: "SELECT sql FROM sqlite_master WHERE tbl_name='myTable' AND sql LIKE '%myConstraintName%';" }); }); diff --git a/test/unit/sql/update.test.js b/test/unit/sql/update.test.js index 05205ff20cd3..561206408d90 100644 --- a/test/unit/sql/update.test.js +++ b/test/unit/sql/update.test.js @@ -27,6 +27,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { { query: { db2: 'SELECT * FROM FINAL TABLE (UPDATE "users" SET "user_name"=$1 WHERE "id" = $2);', + oracle: 'UPDATE "users" SET "user_name"=:1 WHERE "id" = :2', default: 'UPDATE [users] SET [user_name]=$1 WHERE [id] = $2' }, bind: { @@ -57,6 +58,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { postgres: 'UPDATE "users" SET "user_name"=$1 WHERE "id" = $2 RETURNING "id","user_name"', db2: 'SELECT * FROM FINAL TABLE (UPDATE "users" SET "user_name"=$1 WHERE "id" = $2);', snowflake: 'UPDATE "users" SET "user_name"=$1 WHERE "id" = $2', + oracle: 'UPDATE "users" SET "user_name"=:1 WHERE "id" = :2', default: 'UPDATE `users` SET `user_name`=$1 WHERE `id` = $2' }, bind: { @@ -85,6 +87,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { sqlite: 'UPDATE `Users` SET `username`=$1 WHERE rowid IN (SELECT rowid FROM `Users` WHERE `username` = $2 LIMIT 1)', db2: 'SELECT * FROM FINAL TABLE (UPDATE (SELECT * FROM "Users" WHERE "username" = $2 FETCH NEXT 1 ROWS ONLY) SET "username"=$1);', snowflake: 'UPDATE "Users" SET "username"=$1 WHERE "username" = $2 LIMIT 1', + oracle: 'UPDATE "Users" SET "username"=:1 WHERE "username" = :2 AND rownum <= 1', default: 'UPDATE [Users] SET [username]=$1 WHERE [username] = $2' }, bind: { diff --git a/test/unit/sql/where.test.js b/test/unit/sql/where.test.js index 4b8c2d5c2220..02a35fb2a7b4 100644 --- a/test/unit/sql/where.test.js +++ b/test/unit/sql/where.test.js @@ -1,14 +1,14 @@ 'use strict'; -const Support = require('../support'), - DataTypes = require('sequelize/lib/data-types'), - QueryTypes = require('sequelize/lib/query-types'), - util = require('util'), - _ = require('lodash'), - expectsql = Support.expectsql, - current = Support.sequelize, - sql = current.dialect.queryGenerator, - Op = Support.Sequelize.Op; +const Support = require('../support'); +const { QueryTypes, DataTypes } = require('sequelize'); +const util = require('util'); +const _ = require('lodash'); + +const expectsql = Support.expectsql; +const current = Support.sequelize; +const sql = current.dialect.queryGenerator; +const Op = Support.Sequelize.Op; // Notice: [] will be replaced by dialect specific tick/quote character when there is not dialect specific expectation but only a default expectation @@ -61,10 +61,20 @@ describe(Support.getTestDialectTeaser('SQL'), () => { db2: 'WHERE "yolo"."User"."id" = 1', snowflake: 'WHERE "yolo"."User"."id" = 1', mariadb: 'WHERE `yolo`.`User`.`id` = 1', + oracle: 'WHERE "yolo"."User"."id" = 1', mssql: 'WHERE [yolo].[User].[id] = 1' }); }); + testsql({ + name: 'TO_DATE(\'0\',\'Y\')||\'\' OR 1=1--' + }, { + default: 'WHERE [name] = \'TO_DATE(\'\'0\'\',\'\'Y\'\')||\'\'\'\' OR 1=1--\'', + 'mariadb mysql': "WHERE `name` = 'TO_DATE(\\'0\\',\\'Y\\')||\\'\\' OR 1=1--'", + mssql: 'WHERE [name] = N\'TO_DATE(\'\'0\'\',\'\'Y\'\')||\'\'\'\' OR 1=1--\'', + oracle: new Error('Invalid SQL function call.') + }); + testsql({ name: 'a project', [Op.or]: [ @@ -96,6 +106,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { snowflake: 'WHERE "name" = \'here is a null char: \0\'', mssql: "WHERE [name] = N'here is a null char: \0'", db2: "WHERE \"name\" = 'here is a null char: \0'", + oracle: 'WHERE "name" = \'here is a null char: \0\'', sqlite: "WHERE `name` = 'here is a null char: \0'" }); }); @@ -121,6 +132,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { db2: '"deleted" IS NULL', postgres: '"deleted" IS NULL', snowflake: '"deleted" IS NULL', + oracle: '"deleted" IS NULL', mssql: '[deleted] IS NULL' }); @@ -160,6 +172,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { mysql: "`field` = X'53657175656c697a65'", db2: '"field" = BLOB(\'Sequelize\')', snowflake: '"field" = X\'53657175656c697a65\'', + oracle: '"field" = \'53657175656c697a65\'', mssql: '[field] = 0x53657175656c697a65' }); }); @@ -170,6 +183,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { }, { default: '[deleted] IS NOT true', mssql: '[deleted] IS NOT 1', + oracle: '"deleted" IS NOT 1', sqlite: '`deleted` IS NOT 1' }); @@ -505,6 +519,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { mysql: "`date` BETWEEN '2013-01-01 00:00:00' AND '2013-01-11 00:00:00'", db2: "\"date\" BETWEEN '2013-01-01 00:00:00' AND '2013-01-11 00:00:00'", snowflake: '"date" BETWEEN \'2013-01-01 00:00:00\' AND \'2013-01-11 00:00:00\'', + oracle: '"date" BETWEEN TO_TIMESTAMP_TZ(\'2013-01-01 00:00:00.000 +00:00\',\'YYYY-MM-DD HH24:MI:SS.FFTZH:TZM\') AND TO_TIMESTAMP_TZ(\'2013-01-11 00:00:00.000 +00:00\',\'YYYY-MM-DD HH24:MI:SS.FFTZH:TZM\')', mariadb: "`date` BETWEEN '2013-01-01 00:00:00.000' AND '2013-01-11 00:00:00.000'" }); @@ -514,13 +529,22 @@ describe(Support.getTestDialectTeaser('SQL'), () => { model: { rawAttributes: { date: { - type: new DataTypes.DATE() + // We need to convert timestamp to a dialect specific date format to work as expected + // For example: Oracle database expects TO_TIMESTAMP_TZ('2013-01-01 00:00:00.000 +00:00','YYYY-MM-DD HH24:MI:SS.FFTZH:TZM') + // from a timestamp instead of '2013-01-01 00:00:00.000 +00:00' which is returned by default DATE class + + // We cannot use - type: new current.dialect.DataTypes.Date - because when dialect is set to 'mysql' + // mysql DATE class returns '2013-01-01 00:00:00' instead of '2013-01-01 00:00:00.000 +00:00'(expected) + // and that would cause this test to fail when dialect is set to 'mysql' + // So we're using - new current.dialect.DataTypes.Date - only in case when dialect is set to 'oracle' as of now + type: current.dialect.name === 'oracle' ? new current.dialect.DataTypes.DATE() : new DataTypes.DATE() } } } }, { default: "[date] BETWEEN '2013-01-01 00:00:00.000 +00:00' AND '2013-01-11 00:00:00.000 +00:00'", + oracle: '"date" BETWEEN TO_TIMESTAMP_TZ(\'2013-01-01 00:00:00.000 +00:00\',\'YYYY-MM-DD HH24:MI:SS.FFTZH:TZM\') AND TO_TIMESTAMP_TZ(\'2013-01-11 00:00:00.000 +00:00\',\'YYYY-MM-DD HH24:MI:SS.FFTZH:TZM\')', mssql: "[date] BETWEEN N'2013-01-01 00:00:00.000 +00:00' AND N'2013-01-11 00:00:00.000 +00:00'" }); @@ -880,6 +904,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { postgres: "(\"profile\"#>>'{id}') = CAST('12346-78912' AS TEXT)", sqlite: "json_extract(`profile`,'$.id') = CAST('12346-78912' AS TEXT)", mariadb: "json_unquote(json_extract(`profile`,'$.id')) = CAST('12346-78912' AS CHAR)", + oracle: 'json_value("profile",\'$."id"\') = CAST(\'12346-78912\' AS TEXT)', mysql: "json_unquote(json_extract(`profile`,'$.\\\"id\\\"')) = CAST('12346-78912' AS CHAR)" }); }); @@ -889,6 +914,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { postgres: "(\"profile\"#>>'{id}') = '12346-78912' AND (\"profile\"#>>'{name}') = 'test'", sqlite: "json_extract(`profile`,'$.id') = '12346-78912' AND json_extract(`profile`,'$.name') = 'test'", mariadb: "json_unquote(json_extract(`profile`,'$.id')) = '12346-78912' AND json_unquote(json_extract(`profile`,'$.name')) = 'test'", + oracle: 'json_value("profile",\'$."id"\') = \'12346-78912\' AND json_value("profile",\'$."name"\') = \'test\'', mysql: "json_unquote(json_extract(`profile`,'$.\\\"id\\\"')) = '12346-78912' AND json_unquote(json_extract(`profile`,'$.\\\"name\\\"')) = 'test'" }); }); @@ -906,6 +932,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { mariadb: "json_unquote(json_extract(`User`.`data`,'$.nested.attribute')) = 'value'", mysql: "json_unquote(json_extract(`User`.`data`,'$.\\\"nested\\\".\\\"attribute\\\"')) = 'value'", postgres: "(\"User\".\"data\"#>>'{nested,attribute}') = 'value'", + oracle: 'json_value("User"."data",\'$."nested"."attribute"\') = \'value\'', sqlite: "json_extract(`User`.`data`,'$.nested.attribute') = 'value'" }); @@ -921,6 +948,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { mariadb: "CAST(json_unquote(json_extract(`data`,'$.nested')) AS DECIMAL) IN (1, 2)", mysql: "CAST(json_unquote(json_extract(`data`,'$.\\\"nested\\\"')) AS DECIMAL) IN (1, 2)", postgres: "CAST((\"data\"#>>'{nested}') AS DOUBLE PRECISION) IN (1, 2)", + oracle: 'CAST(json_value("data",\'$."nested"\') AS DOUBLE PRECISION) IN (1, 2)', sqlite: "CAST(json_extract(`data`,'$.nested') AS DOUBLE PRECISION) IN (1, 2)" }); @@ -936,6 +964,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { mariadb: "CAST(json_unquote(json_extract(`data`,'$.nested')) AS DECIMAL) BETWEEN 1 AND 2", mysql: "CAST(json_unquote(json_extract(`data`,'$.\\\"nested\\\"')) AS DECIMAL) BETWEEN 1 AND 2", postgres: "CAST((\"data\"#>>'{nested}') AS DOUBLE PRECISION) BETWEEN 1 AND 2", + oracle: 'CAST(json_value("data",\'$."nested"\') AS DOUBLE PRECISION) BETWEEN 1 AND 2', sqlite: "CAST(json_extract(`data`,'$.nested') AS DOUBLE PRECISION) BETWEEN 1 AND 2" }); @@ -955,6 +984,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { mariadb: "(json_unquote(json_extract(`User`.`data`,'$.nested.attribute')) = 'value' AND json_unquote(json_extract(`User`.`data`,'$.nested.prop')) != 'None')", mysql: "(json_unquote(json_extract(`User`.`data`,'$.\\\"nested\\\".\\\"attribute\\\"')) = 'value' AND json_unquote(json_extract(`User`.`data`,'$.\\\"nested\\\".\\\"prop\\\"')) != 'None')", postgres: "((\"User\".\"data\"#>>'{nested,attribute}') = 'value' AND (\"User\".\"data\"#>>'{nested,prop}') != 'None')", + oracle: '(json_value("User"."data",\'$."nested"."attribute"\') = \'value\' AND json_value("User"."data",\'$."nested"."prop"\') != \'None\')', sqlite: "(json_extract(`User`.`data`,'$.nested.attribute') = 'value' AND json_extract(`User`.`data`,'$.nested.prop') != 'None')" }); @@ -974,6 +1004,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { mariadb: "(json_unquote(json_extract(`User`.`data`,'$.name.last')) = 'Simpson' AND json_unquote(json_extract(`User`.`data`,'$.employment')) != 'None')", mysql: "(json_unquote(json_extract(`User`.`data`,'$.\\\"name\\\".\\\"last\\\"')) = 'Simpson' AND json_unquote(json_extract(`User`.`data`,'$.\\\"employment\\\"')) != 'None')", postgres: "((\"User\".\"data\"#>>'{name,last}') = 'Simpson' AND (\"User\".\"data\"#>>'{employment}') != 'None')", + oracle: '(json_value("User"."data",\'$."name"."last"\') = \'Simpson\' AND json_value("User"."data",\'$."employment"\') != \'None\')', sqlite: "(json_extract(`User`.`data`,'$.name.last') = 'Simpson' AND json_extract(`User`.`data`,'$.employment') != 'None')" }); @@ -988,6 +1019,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { mariadb: "(CAST(json_unquote(json_extract(`data`,'$.price')) AS DECIMAL) = 5 AND json_unquote(json_extract(`data`,'$.name')) = 'Product')", mysql: "(CAST(json_unquote(json_extract(`data`,'$.\\\"price\\\"')) AS DECIMAL) = 5 AND json_unquote(json_extract(`data`,'$.\\\"name\\\"')) = 'Product')", postgres: "(CAST((\"data\"#>>'{price}') AS DOUBLE PRECISION) = 5 AND (\"data\"#>>'{name}') = 'Product')", + oracle: '(CAST(json_value("data",\'$."price"\') AS DOUBLE PRECISION) = 5 AND json_value("data",\'$."name"\') = \'Product\')', sqlite: "(CAST(json_extract(`data`,'$.price') AS DOUBLE PRECISION) = 5 AND json_extract(`data`,'$.name') = 'Product')" }); @@ -1003,6 +1035,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { mariadb: "json_unquote(json_extract(`data`,'$.nested.attribute')) = 'value'", mysql: "json_unquote(json_extract(`data`,'$.\\\"nested\\\".\\\"attribute\\\"')) = 'value'", postgres: "(\"data\"#>>'{nested,attribute}') = 'value'", + oracle: 'json_value("data",\'$."nested"."attribute"\') = \'value\'', sqlite: "json_extract(`data`,'$.nested.attribute') = 'value'" }); @@ -1018,6 +1051,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { mariadb: "CAST(json_unquote(json_extract(`data`,'$.nested.attribute')) AS DECIMAL) = 4", mysql: "CAST(json_unquote(json_extract(`data`,'$.\\\"nested\\\".\\\"attribute\\\"')) AS DECIMAL) = 4", postgres: "CAST((\"data\"#>>'{nested,attribute}') AS DOUBLE PRECISION) = 4", + oracle: 'CAST(json_value("data",\'$."nested"."attribute"\') AS DOUBLE PRECISION) = 4', sqlite: "CAST(json_extract(`data`,'$.nested.attribute') AS DOUBLE PRECISION) = 4" }); @@ -1035,6 +1069,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { mariadb: "CAST(json_unquote(json_extract(`data`,'$.nested.attribute')) AS DECIMAL) IN (3, 7)", mysql: "CAST(json_unquote(json_extract(`data`,'$.\\\"nested\\\".\\\"attribute\\\"')) AS DECIMAL) IN (3, 7)", postgres: "CAST((\"data\"#>>'{nested,attribute}') AS DOUBLE PRECISION) IN (3, 7)", + oracle: 'CAST(json_value("data",\'$."nested"."attribute"\') AS DOUBLE PRECISION) IN (3, 7)', sqlite: "CAST(json_extract(`data`,'$.nested.attribute') AS DOUBLE PRECISION) IN (3, 7)" }); @@ -1052,6 +1087,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { mariadb: "CAST(json_unquote(json_extract(`data`,'$.nested.attribute')) AS DECIMAL) > 2", mysql: "CAST(json_unquote(json_extract(`data`,'$.\\\"nested\\\".\\\"attribute\\\"')) AS DECIMAL) > 2", postgres: "CAST((\"data\"#>>'{nested,attribute}') AS DOUBLE PRECISION) > 2", + oracle: 'CAST(json_value("data",\'$."nested"."attribute"\') AS DOUBLE PRECISION) > 2', sqlite: "CAST(json_extract(`data`,'$.nested.attribute') AS DOUBLE PRECISION) > 2" }); @@ -1069,6 +1105,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { mariadb: "CAST(json_unquote(json_extract(`data`,'$.nested.attribute')) AS DECIMAL) > 2", mysql: "CAST(json_unquote(json_extract(`data`,'$.\\\"nested\\\".\\\"attribute\\\"')) AS DECIMAL) > 2", postgres: "CAST((\"data\"#>>'{nested,attribute}') AS INTEGER) > 2", + oracle: 'CAST(json_value("data",\'$."nested"."attribute"\') AS INTEGER) > 2', sqlite: "CAST(json_extract(`data`,'$.nested.attribute') AS INTEGER) > 2" }); @@ -1087,6 +1124,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { mariadb: `CAST(json_unquote(json_extract(\`data\`,'$.nested.attribute')) AS DATETIME) > ${sql.escape(dt)}`, mysql: `CAST(json_unquote(json_extract(\`data\`,'$.\\"nested\\".\\"attribute\\"')) AS DATETIME) > ${sql.escape(dt)}`, postgres: `CAST(("data"#>>'{nested,attribute}') AS TIMESTAMPTZ) > ${sql.escape(dt)}`, + oracle: `json_value("data",'$."nested"."attribute"' RETURNING TIMESTAMP WITH TIME ZONE) > ${sql.escape(dt)}`, sqlite: `json_extract(\`data\`,'$.nested.attribute') > ${sql.escape(dt.toISOString())}` }); @@ -1102,6 +1140,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { mariadb: "json_unquote(json_extract(`data`,'$.nested.attribute')) = 'true'", mysql: "json_unquote(json_extract(`data`,'$.\\\"nested\\\".\\\"attribute\\\"')) = 'true'", postgres: "CAST((\"data\"#>>'{nested,attribute}') AS BOOLEAN) = true", + oracle: 'CAST((CASE WHEN json_value("data",\'$."nested"."attribute"\')=\'true\' THEN 1 ELSE 0 END) AS NUMBER) = 1', sqlite: "CAST(json_extract(`data`,'$.nested.attribute') AS BOOLEAN) = 1" }); @@ -1119,6 +1158,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { mariadb: "json_unquote(json_extract(`meta_data`,'$.nested.attribute')) = 'value'", mysql: "json_unquote(json_extract(`meta_data`,'$.\\\"nested\\\".\\\"attribute\\\"')) = 'value'", postgres: "(\"meta_data\"#>>'{nested,attribute}') = 'value'", + oracle: 'json_value("meta_data",\'$."nested"."attribute"\') = \'value\'', sqlite: "json_extract(`meta_data`,'$.nested.attribute') = 'value'" }); }); @@ -1285,5 +1325,25 @@ describe(Support.getTestDialectTeaser('SQL'), () => { testsql(current.where(current.col('hours'), Op.notBetween, [0, 5]), { default: '[hours] NOT BETWEEN 0 AND 5' }); + + testsql(current.where(current.literal('\'hours\''), Op.eq, 'hours'), { + default: '\'hours\' = \'hours\'', + mssql: '\'hours\' = N\'hours\'' + }); + + it('where(left: ModelAttributeColumnOptions, op, right)', () => { + const User = current.define('user', { + id: { + type: DataTypes.INTEGER, + field: 'internal_id', + primaryKey: true + } + }); + + const where = current.where(User.rawAttributes.id, Op.eq, 1); + const expectations = { default: '[user].[internal_id] = 1' }; + + return expectsql(sql.getWhereConditions(where, User.tableName, User), expectations); + }); }); }); diff --git a/test/unit/transaction.test.js b/test/unit/transaction.test.js index 6fea3c631274..639b9ea9519c 100644 --- a/test/unit/transaction.test.js +++ b/test/unit/transaction.test.js @@ -46,6 +46,9 @@ describe('Transaction', () => { ], mssql: [ 'BEGIN TRANSACTION;' + ], + oracle: [ + 'BEGIN TRANSACTION' ] }; @@ -73,6 +76,10 @@ describe('Transaction', () => { ], mssql: [ 'BEGIN TRANSACTION;' + ], + oracle: [ + 'BEGIN TRANSACTION', + 'SET TRANSACTION ISOLATION LEVEL READ COMMITTED;' ] }; diff --git a/test/unit/utils.test.js b/test/unit/utils.test.js index 5f921deab56b..302978699049 100644 --- a/test/unit/utils.test.js +++ b/test/unit/utils.test.js @@ -71,14 +71,14 @@ describe(Support.getTestDialectTeaser('Utils'), () => { it('defaults symbol keys', () => { expect(Utils.defaults( - { a: 1, [Symbol.for('c')]: 3 }, + { a: 1, [Symbol.for('eq')]: 3 }, { b: 2 }, - { [Symbol.for('c')]: 4, [Symbol.for('d')]: 4 } + { [Symbol.for('eq')]: 4, [Symbol.for('ne')]: 4 } )).to.eql({ a: 1, b: 2, - [Symbol.for('c')]: 3, - [Symbol.for('d')]: 4 + [Symbol.for('eq')]: 3, + [Symbol.for('ne')]: 4 }); }); }); diff --git a/test/unit/utils/sql.test.js b/test/unit/utils/sql.test.js new file mode 100644 index 000000000000..f529b35d3dd4 --- /dev/null +++ b/test/unit/utils/sql.test.js @@ -0,0 +1,655 @@ +const { injectReplacements } = require('sequelize/lib/utils/sql'); +const { expect } = require('chai'); +const { + expectsql, + sequelize, + createSequelizeInstance, + expectPerDialect, + toMatchSql +} = require('../../support'); + +const dialect = sequelize.dialect; + +describe('injectReplacements (named replacements)', () => { + it('parses named replacements', () => { + const sql = injectReplacements(`SELECT ${dialect.TICK_CHAR_LEFT}:id${dialect.TICK_CHAR_RIGHT} FROM users WHERE id = ':id' OR id = :id OR id = ''':id'''`, dialect, { + id: 1 + }); + + expectsql(sql, { + default: 'SELECT [:id] FROM users WHERE id = \':id\' OR id = 1 OR id = \'\'\':id\'\'\'' + }); + }); + + it('throws if a named replacement is not provided as an own property', () => { + expect(() => { + injectReplacements('SELECT * FROM users WHERE id = :toString', dialect, { + id: 1 + }); + }).to.throw('Named replacement ":toString" has no entry in the replacement map.'); + }); + + it('parses named replacements followed by cast syntax', () => { + const sql = injectReplacements('SELECT * FROM users WHERE id = :id::string', dialect, { + id: 1 + }); + + expectsql(sql, { + default: 'SELECT * FROM users WHERE id = 1::string' + }); + }); + + it('parses named replacements following JSONB indexing', () => { + const sql = injectReplacements( + 'SELECT * FROM users WHERE json_col->>:key', + dialect, + { key: 'name' } + ); + + expectsql(sql, { + default: "SELECT * FROM users WHERE json_col->>'name'", + mssql: "SELECT * FROM users WHERE json_col->>N'name'" + }); + }); + + it('parses named replacements followed by a semicolon', () => { + const sql = injectReplacements('SELECT * FROM users WHERE id = :id;', dialect, { + id: 1 + }); + + expectsql(sql, { + default: 'SELECT * FROM users WHERE id = 1;' + }); + }); + + it('parses bind parameters following JSONB indexing', () => { + const sql = injectReplacements( + 'SELECT * FROM users WHERE json_col->>$key', + dialect, + { id: 1 } + ); + + expectsql(sql, { + default: 'SELECT * FROM users WHERE json_col->>$key' + }); + }); + + // this is a workaround. + // The right way to support ARRAY in replacement is https://github.com/sequelize/sequelize/issues/14410 + if (sequelize.dialect.supports.ARRAY) { + it('parses named replacements inside ARRAY[]', () => { + const sql = injectReplacements('SELECT * FROM users WHERE id = ARRAY[:id1]::int[] OR id = ARRAY[:id1,:id2]::int[] OR id = ARRAY[:id1, :id2]::int[];', dialect, { + id1: 1, + id2: 4 + }); + + expectsql(sql, { + default: 'SELECT * FROM users WHERE id = ARRAY[1]::int[] OR id = ARRAY[1,4]::int[] OR id = ARRAY[1, 4]::int[];' + }); + }); + } + + it('parses single letter named replacements', () => { + const sql = injectReplacements('SELECT * FROM users WHERE id = :a', dialect, { + a: 1 + }); + + expectsql(sql, { + default: 'SELECT * FROM users WHERE id = 1' + }); + }); + + it('does not consider the token to be a replacement if it does not follow \'(\', \',\', \'=\' or whitespace', () => { + const sql = injectReplacements('SELECT * FROM users WHERE id = fn(:id) OR id = fn(\'a\',:id) OR id=:id OR id = :id', dialect, { + id: 1 + }); + + expectsql(sql, { + default: 'SELECT * FROM users WHERE id = fn(1) OR id = fn(\'a\',1) OR id=1 OR id = 1' + }); + }); + + it('does not consider the token to be a replacement if it is part of a $ quoted string', () => { + const sql = injectReplacements('SELECT * FROM users WHERE id = $tag$ :id $tag$ OR id = $$ :id $$', dialect, { + id: 1 + }); + + expectsql(sql, { + default: 'SELECT * FROM users WHERE id = $tag$ :id $tag$ OR id = $$ :id $$' + }); + }); + + it('does not consider the token to be a replacement if it is part of a nested $ quoted string', () => { + const sql = injectReplacements('SELECT * FROM users WHERE id = $tag1$ $tag2$ :id $tag2$ $tag1$', dialect, { + id: 1 + }); + + expectsql(sql, { + default: 'SELECT * FROM users WHERE id = $tag1$ $tag2$ :id $tag2$ $tag1$' + }); + }); + + it('does consider the token to be a replacement if it is in between two identifiers that look like $ quoted strings', () => { + const sql = injectReplacements('SELECT z$$ :id x$$ * FROM users', dialect, { + id: 1 + }); + + expectsql(sql, { + default: 'SELECT z$$ 1 x$$ * FROM users' + }); + }); + + it('does consider the token to be a bind parameter if it is located after a $ quoted string', () => { + const sql = injectReplacements('SELECT $$ abc $$ AS string FROM users WHERE id = :id', dialect, { + id: 1 + }); + + expectsql(sql, { + default: 'SELECT $$ abc $$ AS string FROM users WHERE id = 1' + }); + }); + + it('does not consider the token to be a bind parameter if it is part of a string with a backslash escaped quote, in dialects that support backslash escape', () => { + expectPerDialect( + () => + injectReplacements( + "SELECT * FROM users WHERE id = '\\' $id' OR id = $id", + dialect, + { id: 1 } + ), + { + default: + new Error(`The following SQL query includes an unterminated string literal: +SELECT * FROM users WHERE id = '\\' $id' OR id = $id`), + 'mysql mariadb': toMatchSql( + "SELECT * FROM users WHERE id = '\\' $id' OR id = $id" + ) + } + ); + }); + + it('does not consider the token to be a bind parameter if it is part of a string with a backslash escaped quote, in dialects that support standardConformingStrings = false', () => { + expectPerDialect( + () => + injectReplacements( + "SELECT * FROM users WHERE id = '\\' $id' OR id = $id", + getNonStandardConfirmingStringDialect(), + { id: 1 } + ), + { + default: + new Error(`The following SQL query includes an unterminated string literal: +SELECT * FROM users WHERE id = '\\' $id' OR id = $id`), + + 'mysql mariadb postgres': toMatchSql( + "SELECT * FROM users WHERE id = '\\' $id' OR id = $id" + ) + } + ); + }); + + it('does not consider the token to be a bind parameter if it is part of an E-prefixed string with a backslash escaped quote, in dialects that support E-prefixed strings', () => { + expectPerDialect( + () => + injectReplacements( + "SELECT * FROM users WHERE id = E'\\' $id' OR id = $id", + dialect, + { id: 1 } + ), + { + default: + new Error(`The following SQL query includes an unterminated string literal: +SELECT * FROM users WHERE id = E'\\' $id' OR id = $id`), + 'mysql mariadb postgres': toMatchSql( + "SELECT * FROM users WHERE id = E'\\' $id' OR id = $id" + ) + } + ); + }); + + it('treats strings prefixed with a lowercase e as E-prefixed strings too', () => { + expectPerDialect( + () => + injectReplacements( + "SELECT * FROM users WHERE id = e'\\' $id' OR id = $id", + dialect, + { id: 1 } + ), + { + default: + new Error(`The following SQL query includes an unterminated string literal: +SELECT * FROM users WHERE id = e'\\' $id' OR id = $id`), + + 'mysql mariadb postgres': toMatchSql( + "SELECT * FROM users WHERE id = e'\\' $id' OR id = $id" + ) + } + ); + }); + + it('considers the token to be a replacement if it is outside a string ending with an escaped backslash', () => { + const sql = injectReplacements('SELECT * FROM users WHERE id = \'\\\\\' OR id = :id', dialect, { + id: 1 + }); + + expectsql(sql, { + default: 'SELECT * FROM users WHERE id = \'\\\\\' OR id = 1' + }); + }); + + it('does not consider the token to be a replacement if it is part of a string with an escaped backslash followed by a backslash escaped quote', () => { + const test = () => + injectReplacements( + "SELECT * FROM users WHERE id = '\\\\\\' :id' OR id = :id", + dialect, + { id: 1 } + ); + + expectPerDialect(test, { + default: + new Error(`The following SQL query includes an unterminated string literal: +SELECT * FROM users WHERE id = '\\\\\\' :id' OR id = :id`), + + 'mysql mariadb': "SELECT * FROM users WHERE id = '\\\\\\' :id' OR id = 1" + }); + }); + + it('does not consider the token to be a replacement if it is in a single line comment', () => { + const sql = injectReplacements(` + SELECT * FROM users -- WHERE id = :id + WHERE id = :id + `, dialect, { id: 1 }); + + expectsql(sql, { + default: ` + SELECT * FROM users -- WHERE id = :id + WHERE id = 1 + ` + }); + }); + + it('does not consider the token to be a replacement if it is in string but a previous comment included a string delimiter', () => { + const sql = injectReplacements(` + SELECT * FROM users -- ' + WHERE id = ' :id ' + `, dialect, { id: 1 }); + + expectsql(sql, { + default: ` + SELECT * FROM users -- ' + WHERE id = ' :id ' + ` + }); + }); + + it('does not consider the token to be a replacement if it is in a single line comment', () => { + const sql = injectReplacements(` + SELECT * FROM users /* + WHERE id = :id + */ + WHERE id = :id + `, dialect, { id: 1 }); + + expectsql(sql, { + default: ` + SELECT * FROM users /* + WHERE id = :id + */ + WHERE id = 1 + ` + }); + }); + + it('does not interpret ::x as a replacement, as it is a cast', () => { + expect(injectReplacements('(\'foo\')::string', dialect, [0])).to.equal('(\'foo\')::string'); + }); +}); + +describe('injectReplacements (positional replacements)', () => { + it('parses positional replacements', () => { + const sql = injectReplacements(`SELECT ${dialect.TICK_CHAR_LEFT}?${dialect.TICK_CHAR_RIGHT} FROM users WHERE id = '?' OR id = ? OR id = '''?''' OR id2 = ?`, dialect, [1, 2]); + + expectsql(sql, { + default: 'SELECT [?] FROM users WHERE id = \'?\' OR id = 1 OR id = \'\'\'?\'\'\' OR id2 = 2' + }); + }); + + it('parses positional replacements followed by cast syntax', () => { + const sql = injectReplacements('SELECT * FROM users WHERE id = ?::string', dialect, [1]); + + expectsql(sql, { + default: 'SELECT * FROM users WHERE id = 1::string' + }); + }); + + it('parses named replacements following JSONB indexing', () => { + const sql = injectReplacements( + 'SELECT * FROM users WHERE json_col->>?', + dialect, + ['name'] + ); + + expectsql(sql, { + default: "SELECT * FROM users WHERE json_col->>'name'", + mssql: "SELECT * FROM users WHERE json_col->>N'name'" + }); + }); + + it('parses positional replacements followed by a semicolon', () => { + const sql = injectReplacements('SELECT * FROM users WHERE id = ?;', dialect, [1]); + + expectsql(sql, { + default: 'SELECT * FROM users WHERE id = 1;' + }); + }); + + // this is a workaround. + // The right way to support ARRAY in replacement is https://github.com/sequelize/sequelize/issues/14410 + if (sequelize.dialect.supports.ARRAY) { + it('parses positional replacements inside ARRAY[]', () => { + const sql = injectReplacements('SELECT * FROM users WHERE id = ARRAY[?]::int[] OR ARRAY[?,?]::int[] OR ARRAY[?, ?]::int[];', dialect, [1, 1, 4, 1, 4]); + + expectsql(sql, { + default: 'SELECT * FROM users WHERE id = ARRAY[1]::int[] OR ARRAY[1,4]::int[] OR ARRAY[1, 4]::int[];' + }); + }); + } + + it('does not consider the token to be a replacement if it does not follow \'(\', \',\', \'=\' or whitespace', () => { + const sql = injectReplacements('SELECT * FROM users WHERE id = fn(?) OR id = fn(\'a\',?) OR id=? OR id = ?', dialect, [2, 1, 3, 4]); + + expectsql(sql, { + default: 'SELECT * FROM users WHERE id = fn(2) OR id = fn(\'a\',1) OR id=3 OR id = 4' + }); + }); + + it('does not consider the token to be a replacement if it is part of a $ quoted string', () => { + const sql = injectReplacements('SELECT * FROM users WHERE id = $tag$ ? $tag$ OR id = $$ ? $$', dialect, [1]); + + expectsql(sql, { + default: 'SELECT * FROM users WHERE id = $tag$ ? $tag$ OR id = $$ ? $$' + }); + }); + + it('does not consider the token to be a replacement if it is part of a nested $ quoted string', () => { + const sql = injectReplacements('SELECT * FROM users WHERE id = $tag1$ $tag2$ ? $tag2$ $tag1$', dialect, [1]); + + expectsql(sql, { + default: 'SELECT * FROM users WHERE id = $tag1$ $tag2$ ? $tag2$ $tag1$' + }); + }); + + it('does consider the token to be a replacement if it is in between two identifiers that look like $ quoted strings', () => { + const sql = injectReplacements('SELECT z$$ ? x$$ * FROM users', dialect, [1]); + + expectsql(sql, { + default: 'SELECT z$$ 1 x$$ * FROM users' + }); + }); + + it('does not consider the token to be a replacement if it is in an unnamed $ quoted string', () => { + const sql = injectReplacements('SELECT $$ ? $$', dialect, [1]); + + expectsql(sql, { + default: 'SELECT $$ ? $$' + }); + }); + + it('does consider the token to be a replacement if it is located after a $ quoted string', () => { + const sql = injectReplacements('SELECT $$ abc $$ AS string FROM users WHERE id = ?', dialect, [1]); + + expectsql(sql, { + default: 'SELECT $$ abc $$ AS string FROM users WHERE id = 1' + }); + }); + + it('does not consider the token to be a replacement if it is part of a string with a backslash escaped quote', () => { + const test = () => + injectReplacements( + "SELECT * FROM users WHERE id = '\\' :id' OR id = :id", + dialect, + { id: 1 } + ); + + expectPerDialect(test, { + default: + new Error(`The following SQL query includes an unterminated string literal: +SELECT * FROM users WHERE id = '\\' :id' OR id = :id`), + + 'mysql mariadb': toMatchSql( + "SELECT * FROM users WHERE id = '\\' :id' OR id = 1" + ) + }); + }); + + it('does not consider the token to be a replacement if it is part of a string with a backslash escaped quote, in dialects that support standardConformingStrings = false', () => { + const test = () => + injectReplacements( + "SELECT * FROM users WHERE id = '\\' :id' OR id = :id", + getNonStandardConfirmingStringDialect(), + { id: 1 } + ); + + expectPerDialect(test, { + default: + new Error(`The following SQL query includes an unterminated string literal: +SELECT * FROM users WHERE id = '\\' :id' OR id = :id`), + + 'mysql mariadb postgres': toMatchSql( + "SELECT * FROM users WHERE id = '\\' :id' OR id = 1" + ) + }); + }); + + it('does not consider the token to be a replacement if it is part of an E-prefixed string with a backslash escaped quote, in dialects that support E-prefixed strings', () => { + expectPerDialect( + () => + injectReplacements( + "SELECT * FROM users WHERE id = E'\\' :id' OR id = :id", + dialect, + { id: 1 } + ), + { + default: + new Error(`The following SQL query includes an unterminated string literal: +SELECT * FROM users WHERE id = E'\\' :id' OR id = :id`), + + 'mysql mariadb postgres': toMatchSql( + "SELECT * FROM users WHERE id = E'\\' :id' OR id = 1" + ) + } + ); + }); + + it('considers the token to be a replacement if it is outside a string ending with an escaped backslash', () => { + const sql = injectReplacements('SELECT * FROM users WHERE id = \'\\\\\' OR id = ?', dialect, [1]); + + expectsql(sql, { + default: 'SELECT * FROM users WHERE id = \'\\\\\' OR id = 1' + }); + }); + + it('does not consider the token to be a replacement if it is part of a string with an escaped backslash followed by a backslash escaped quote', () => { + const test = () => + injectReplacements( + "SELECT * FROM users WHERE id = '\\\\\\' :id' OR id = :id", + dialect, + { id: 1 } + ); + + expectPerDialect(test, { + default: + new Error(`The following SQL query includes an unterminated string literal: +SELECT * FROM users WHERE id = '\\\\\\' :id' OR id = :id`), + + 'mysql mariadb': "SELECT * FROM users WHERE id = '\\\\\\' :id' OR id = 1" + }); + }); + + it('does not consider the token to be a replacement if it is in a single line comment', () => { + const sql = injectReplacements(` + SELECT * FROM users -- WHERE id = ? + WHERE id = ? + `, dialect, [1]); + + expectsql(sql, { + default: ` + SELECT * FROM users -- WHERE id = ? + WHERE id = 1 + ` + }); + }); + + it('does not consider the token to be a replacement if it is in string but a previous comment included a string delimiter', () => { + const sql = injectReplacements(` + SELECT * FROM users -- ' + WHERE id = ' ? ' + `, dialect, [1]); + + expectsql(sql, { + default: ` + SELECT * FROM users -- ' + WHERE id = ' ? ' + ` + }); + }); + + it('does not consider the token to be a replacement if it is in a single line comment', () => { + const sql = injectReplacements(` + SELECT * FROM users /* + WHERE id = ? + */ + WHERE id = ? + `, dialect, [1]); + + expectsql(sql, { + default: ` + SELECT * FROM users /* + WHERE id = ? + */ + WHERE id = 1 + ` + }); + }); + + // https://github.com/sequelize/sequelize/issues/14358 + it('does not parse ?& and ?| operators as replacements (#14358)', async () => { + const sql = injectReplacements('SELECT * FROM products WHERE tags ?& ARRAY[1] AND tags ?| ARRAY[1] AND id = ?;', dialect, [1]); + + expectsql(sql, { + default: 'SELECT * FROM products WHERE tags ?& ARRAY[1] AND tags ?| ARRAY[1] AND id = 1;', + // 'default' removes the trailing ; for ibmi, but we actually need to test it's there this time, to ensure '?;' is treated as a replacement + ';' + ibmi: 'SELECT * FROM products WHERE tags ?& ARRAY[1] AND tags ?| ARRAY[1] AND id = 1;' + }); + }); + + it('formats where clause correctly when the value is falsy', () => { + expect(injectReplacements('foo = ?', dialect, [0])).to.equal('foo = 0'); + }); + + it('formats arrays as an expression instead of an ARRAY data type', async () => { + const sql = injectReplacements('INSERT INTO users (username, email, created_at, updated_at) VALUES ?;', dialect, [[ + ['john', 'john@gmail.com', '2012-01-01 10:10:10', '2012-01-01 10:10:10'], + ['michael', 'michael@gmail.com', '2012-01-01 10:10:10', '2012-01-01 10:10:10'] + ]]); + + expectsql(sql, { + default: ` + INSERT INTO users (username, email, created_at, updated_at) + VALUES + ('john', 'john@gmail.com', '2012-01-01 10:10:10', '2012-01-01 10:10:10'), + ('michael', 'michael@gmail.com', '2012-01-01 10:10:10', '2012-01-01 10:10:10');`, + // 'default' removes the trailing ; for ibmi, but we actually need to test it's there this time, to ensure '?;' is treated as a replacement + ';' + ibmi: ` + INSERT INTO users (username, email, created_at, updated_at) + VALUES + ('john', 'john@gmail.com', '2012-01-01 10:10:10', '2012-01-01 10:10:10'), + ('michael', 'michael@gmail.com', '2012-01-01 10:10:10', '2012-01-01 10:10:10');`, + mssql: ` + INSERT INTO users (username, email, created_at, updated_at) + VALUES + (N'john', N'john@gmail.com', N'2012-01-01 10:10:10', N'2012-01-01 10:10:10'), + (N'michael', N'michael@gmail.com', N'2012-01-01 10:10:10', N'2012-01-01 10:10:10');` + }); + }); + + it('does not consider the token to be a replacement if it is part of a string with a backslash escaped quote', () => { + const test = () => + injectReplacements( + "SELECT * FROM users WHERE id = '\\' ?' OR id = ?", + dialect, + [1] + ); + expectPerDialect(test, { + default: + new Error(`The following SQL query includes an unterminated string literal: +SELECT * FROM users WHERE id = '\\' ?' OR id = ?`), + + 'mysql mariadb': toMatchSql( + "SELECT * FROM users WHERE id = '\\' ?' OR id = 1" + ) + }); + }); + + it('does not consider the token to be a replacement if it is part of a string with a backslash escaped quote, in dialects that support standardConformingStrings = false', () => { + const test = () => + injectReplacements( + "SELECT * FROM users WHERE id = '\\' ?' OR id = ?", + getNonStandardConfirmingStringDialect(), + [1] + ); + + expectPerDialect(test, { + default: + new Error(`The following SQL query includes an unterminated string literal: +SELECT * FROM users WHERE id = '\\' ?' OR id = ?`), + + 'mysql mariadb postgres': toMatchSql( + "SELECT * FROM users WHERE id = '\\' ?' OR id = 1" + ) + }); + }); + + it('does not consider the token to be a replacement if it is part of an E-prefixed string with a backslash escaped quote, in dialects that support E-prefixed strings', () => { + expectPerDialect( + () => + injectReplacements( + "SELECT * FROM users WHERE id = E'\\' ?' OR id = ?", + dialect, + [1] + ), + { + default: + new Error(`The following SQL query includes an unterminated string literal: +SELECT * FROM users WHERE id = E'\\' ?' OR id = ?`), + + 'mysql mariadb postgres': toMatchSql( + "SELECT * FROM users WHERE id = E'\\' ?' OR id = 1" + ) + } + ); + }); + + it('does not consider the token to be a replacement if it is part of a string with an escaped backslash followed by a backslash escaped quote', () => { + const test = () => + injectReplacements( + "SELECT * FROM users WHERE id = '\\\\\\' ?' OR id = ?", + dialect, + [1] + ); + + expectPerDialect(test, { + default: + new Error(`The following SQL query includes an unterminated string literal: +SELECT * FROM users WHERE id = '\\\\\\' ?' OR id = ?`), + + 'mysql mariadb': "SELECT * FROM users WHERE id = '\\\\\\' ?' OR id = 1" + }); + }); +}); + +function getNonStandardConfirmingStringDialect() { + return createSequelizeInstance({ + standardConformingStrings: false + }).dialect; +} diff --git a/tsconfig.json b/tsconfig.json index 6bfd52628733..26d9315bdb93 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,10 +7,10 @@ "declaration": true, "emitDeclarationOnly": true, "sourceRoot": "", - "outDir": "./dist/", + "outDir": "./types", "strict": true, "baseUrl": "./", - "rootDir": "./", + "rootDir": "./src", "types": ["node"], "allowSyntheticDefaultImports": true, "esModuleInterop": true, @@ -18,5 +18,5 @@ "checkJs": false, "removeComments": false }, - "include": ["./lib/**/*.ts"] + "include": ["./src/**/*.ts"] } diff --git a/types/index.d.ts b/types/index.d.ts deleted file mode 100644 index efb34b39dc8c..000000000000 --- a/types/index.d.ts +++ /dev/null @@ -1,25 +0,0 @@ -import DataTypes = require("./lib/data-types"); -import Deferrable = require("./lib/deferrable"); -import Op from "../lib/operators"; -import QueryTypes = require("./lib/query-types"); -import TableHints = require("./lib/table-hints"); -import IndexHints = require("./lib/index-hints"); -import Utils = require("./lib/utils"); - -export * from "./lib/associations/index"; -export * from "./lib/data-types"; -export * from "./lib/errors"; -export { BaseError as Error } from "./lib/errors"; -export * from "./lib/model"; -export * from "./lib/query-interface"; -export * from "./lib/sequelize"; -export * from "./lib/transaction"; -export { useInflection } from "./lib/utils"; -export { Validator } from "./lib/utils/validator-extras"; -export { Utils, QueryTypes, Op, TableHints, IndexHints, DataTypes, Deferrable }; - -/** - * Type helper for making certain fields of an object optional. This is helpful - * for creating the `CreationAttributes` from your `Attributes` for a Model. - */ -export type Optional = Omit & Partial>; diff --git a/types/lib/errors.d.ts b/types/lib/errors.d.ts deleted file mode 100644 index 2f8340b14113..000000000000 --- a/types/lib/errors.d.ts +++ /dev/null @@ -1,262 +0,0 @@ -import Model from "./model"; - -/** - * The Base Error all Sequelize Errors inherit from. - */ -export class BaseError extends Error { - public name: string; -} - -/** - * Scope Error. Thrown when the sequelize cannot query the specified scope. - */ -export class SequelizeScopeError extends BaseError {} - -export class ValidationError extends BaseError { - /** Array of ValidationErrorItem objects describing the validation errors */ - public readonly errors: ValidationErrorItem[]; - - /** - * Validation Error. Thrown when the sequelize validation has failed. The error contains an `errors` - * property, which is an array with 1 or more ValidationErrorItems, one for each validation that failed. - * - * @param message Error message - * @param errors Array of ValidationErrorItem objects describing the validation errors - */ - constructor(message: string, errors?: ValidationErrorItem[]); - - /** - * Gets all validation error items for the path / field specified. - * - * @param path The path to be checked for error items - */ - public get(path: string): ValidationErrorItem[]; -} - -/** - * An enum that is used internally by the `ValidationErrorItem` class - * that maps current `type` strings (as given to ValidationErrorItem.constructor()) to - * our new `origin` values. - */ -export enum ValidationErrorItemType { - 'notnull violation' = 'CORE', - 'string violation' = 'CORE', - 'unique violation' = 'DB', - 'validation error' = 'FUNCTION', -} - -/** - * An enum that defines valid ValidationErrorItem `origin` values - */ -export enum ValidationErrorItemOrigin { - /** - * specifies errors that originate from the sequelize "core" - */ - CORE = 'CORE', - - /** - * specifies validation errors that originate from the storage engine - */ - DB = 'DB', - - /** - * specifies validation errors that originate from validator functions (both built-in and custom) defined for a given attribute - */ - FUNCTION = 'FUNCTION', -} - -export class ValidationErrorItem { - /** An error message */ - public readonly message: string; - - /** The type/origin of the validation error */ - public readonly type: string | null; - - /** The field that triggered the validation error */ - public readonly path: string | null; - - /** The value that generated the error */ - public readonly value: string | null; - - /** The DAO instance that caused the validation error */ - public readonly instance: Model | null; - - /** A validation "key", used for identification */ - public readonly validatorKey: string | null; - - /** Property name of the BUILT-IN validator function that caused the validation error (e.g. "in" or "len"), if applicable */ - public readonly validatorName: string | null; - - /** Parameters used with the BUILT-IN validator function, if applicable */ - public readonly validatorArgs: unknown[]; - - public readonly original: Error; - - /** - * Creates a new ValidationError item. Instances of this class are included in the `ValidationError.errors` property. - * - * @param message An error message - * @param type The type/origin of the validation error - * @param path The field that triggered the validation error - * @param value The value that generated the error - * @param instance the DAO instance that caused the validation error - * @param validatorKey a validation "key", used for identification - * @param fnName property name of the BUILT-IN validator function that caused the validation error (e.g. "in" or "len"), if applicable - * @param fnArgs parameters used with the BUILT-IN validator function, if applicable - */ - constructor( - message?: string, - type?: string, - path?: string, - value?: string, - instance?: object, - validatorKey?: string, - fnName?: string, - fnArgs?: unknown[] - ); -} - -export interface CommonErrorProperties { - /** The database specific error which triggered this one */ - readonly parent: Error; - - /** The database specific error which triggered this one */ - readonly original: Error; - - /** The SQL that triggered the error */ - readonly sql: string; -} - -/** - * Thrown when a record was not found, Usually used with rejectOnEmpty mode (see message for details) - */ -export class EmptyResultError extends BaseError { -} - -export class DatabaseError extends BaseError implements CommonErrorProperties { - public readonly parent: Error; - public readonly original: Error; - public readonly sql: string; - public readonly parameters: Array; - /** - * A base class for all database related errors. - * @param parent The database specific error which triggered this one - */ - constructor(parent: Error); -} - -/** Thrown when a database query times out because of a deadlock */ -export class TimeoutError extends DatabaseError {} - -export interface UniqueConstraintErrorOptions { - parent?: Error; - message?: string; - errors?: ValidationErrorItem[]; - fields?: { [key: string]: unknown }; - original?: Error; -} - -/** - * Thrown when a unique constraint is violated in the database - */ -export class UniqueConstraintError extends ValidationError implements CommonErrorProperties { - public readonly parent: Error; - public readonly original: Error; - public readonly sql: string; - public readonly fields: { [key: string]: unknown }; - constructor(options?: UniqueConstraintErrorOptions); -} - -/** - * Thrown when a foreign key constraint is violated in the database - */ -export class ForeignKeyConstraintError extends DatabaseError { - public table: string; - public fields: { [field: string]: string }; - public value: unknown; - public index: string; - constructor(options: { parent?: Error; message?: string; index?: string; fields?: string[]; table?: string }); -} - -/** - * Thrown when an exclusion constraint is violated in the database - */ -export class ExclusionConstraintError extends DatabaseError { - public constraint: string; - public fields: { [field: string]: string }; - public table: string; - constructor(options: { parent?: Error; message?: string; constraint?: string; fields?: string[]; table?: string }); -} - -/** - * Thrown when constraint name is not found in the database - */ -export class UnknownConstraintError extends DatabaseError { - public constraint: string; - public fields: { [field: string]: string }; - public table: string; - constructor(options: { parent?: Error; message?: string; constraint?: string; fields?: string[]; table?: string }); -} - -/** - * Thrown when attempting to update a stale model instance - */ -export class OptimisticLockError extends BaseError { - constructor(options: { message?: string, modelName?: string, values?: { [key: string]: any }, where?: { [key: string]: any } }); -} - -/** - * A base class for all connection related errors. - */ -export class ConnectionError extends BaseError { - public parent: Error; - public original: Error; - constructor(parent: Error); -} - -/** - * Thrown when a connection to a database is refused - */ -export class ConnectionRefusedError extends ConnectionError {} - -/** - * Thrown when a connection to a database is refused due to insufficient privileges - */ -export class AccessDeniedError extends ConnectionError {} - -/** - * Thrown when a connection to a database has a hostname that was not found - */ -export class HostNotFoundError extends ConnectionError {} - -/** - * Thrown when a connection to a database has a hostname that was not reachable - */ -export class HostNotReachableError extends ConnectionError {} - -/** - * Thrown when a connection to a database has invalid values for any of the connection parameters - */ -export class InvalidConnectionError extends ConnectionError {} - -/** - * Thrown when a connection to a database times out - */ -export class ConnectionTimedOutError extends ConnectionError {} - -/** - * Thrown when queued operations were aborted because a connection was closed - */ -export class AsyncQueueError extends BaseError {} - -export class AggregateError extends BaseError { - /** - * AggregateError. A wrapper for multiple errors. - * - * @param {Error[]} errors The aggregated errors that occurred - */ - constructor(errors: Error[]); - - /** the aggregated errors that occurred */ - public readonly errors: Error[]; -} diff --git a/types/test/findOne.ts b/types/test/findOne.ts deleted file mode 100644 index 1a71a0647d9f..000000000000 --- a/types/test/findOne.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { User } from "./models/User"; - -User.findOne({ where: { firstName: 'John' } }); - -// @ts-expect-error -User.findOne({ where: { blah: 'blah2' } }); diff --git a/types/test/infer-attributes.ts b/types/test/infer-attributes.ts deleted file mode 100644 index 1892acb5b6aa..000000000000 --- a/types/test/infer-attributes.ts +++ /dev/null @@ -1,123 +0,0 @@ -import { expectTypeOf } from 'expect-type'; -import { InferAttributes, InferCreationAttributes, CreationOptional, Model, NonAttribute, Attributes, CreationAttributes } from 'sequelize'; - -class User extends Model< - InferAttributes, - InferCreationAttributes -> { - declare id: CreationOptional; - declare name: string; - declare anArray: CreationOptional; - - // omitted using `omit` option - declare groups: Group[]; - // omitted using `NonAttribute` - declare projects: NonAttribute; - - instanceMethod() {} - static staticMethod() {} -} - -type UserAttributes = Attributes; -type UserCreationAttributes = CreationAttributes; - -expectTypeOf().not.toBeAny(); - -{ - class Test extends Model> { - declare id: NonAttribute; - } - - const win: Attributes = {}; -} - -{ - const win: UserAttributes = { - id: 1, - name: '', - anArray: [''], - }; - - const fail1: UserAttributes = { - id: 1, - name: '', - // @ts-expect-error - 'extra' should not be present - extra: '' - }; - - // @ts-expect-error - 'name' should be present - const fail2: UserAttributes = { - id: 1, - }; -} - -{ - const win: UserCreationAttributes = { - id: undefined, - name: '', - anArray: undefined, - }; - - const fail1: UserCreationAttributes = { - id: 1, - name: '', - // @ts-expect-error 'extra' does not exist - extra: '' - }; - - const fail2: UserCreationAttributes = { - id: 1, - // @ts-expect-error name cannot be undefined - name: undefined, - anArray: undefined, - }; -} - -type GroupAttributes = InferAttributes; - -class Group extends Model { - declare id: number; -} - -{ - // @ts-expect-error - id should not be missing - const fail1: GroupAttributes = {}; - - // @ts-expect-error - id should not be missing - const fail2: InferAttributes = {}; - - // @ts-expect-error - id should not be missing - const fail3: InferAttributes = {}; -} - -class Project extends Model> { - declare id: number; -} - -// brands: - -{ - // ensure branding does not break arrays. - const brandedArray: NonAttribute = ['']; - const anArray: string[] = brandedArray; - const item: string = brandedArray[0]; -} - -{ - // ensure branding does not break objects - const brandedObject: NonAttribute> = {}; - const anObject: Record = brandedObject; - const item: string = brandedObject.key; -} - -{ - // ensure branding does not break primitives - const brandedString: NonAttribute = ''; - const aString: string = brandedString; -} - -{ - // ensure branding does not break instances - const brandedUser: NonAttribute = new User(); - const aUser: User = brandedUser; -} diff --git a/types/test/tsconfig.json b/types/test/tsconfig.json deleted file mode 100644 index 0d4f95ea960f..000000000000 --- a/types/test/tsconfig.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "target": "es6", - "noEmit": true, - "strict": true, - "baseUrl": ".", - "paths": { - "sequelize": ["../../dist/"], - "sequelize/*": ["../../dist/*"] - }, - "lib": ["es2016"] - }, - "include": ["../index.d.ts", "./**/sequelize.d.ts", "./**/*.ts"] -} diff --git a/types/test/typescriptDocs/DefineNoAttributes.ts b/types/test/typescriptDocs/DefineNoAttributes.ts deleted file mode 100644 index 8273cad18ff1..000000000000 --- a/types/test/typescriptDocs/DefineNoAttributes.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Keep this file in sync with the code in the "Usage of `sequelize.define`" - * that doesn't have attribute types in /docs/manual/other-topics/typescript.md - * - * Don't include this comment in the md file. - */ -import { Sequelize, Model, DataTypes } from 'sequelize'; - -const sequelize = new Sequelize('mysql://root:asd123@localhost:3306/mydb'); - -// We need to declare an interface for our model that is basically what our class would be -interface UserInstance extends Model { - id: number; - name: string; -} - -const UserModel = sequelize.define('User', { - id: { - primaryKey: true, - type: DataTypes.INTEGER.UNSIGNED, - }, - name: { - type: DataTypes.STRING, - }, -}); - -async function doStuff() { - const instance = await UserModel.findByPk(1, { - rejectOnEmpty: true, - }); - console.log(instance.id); -} diff --git a/types/test/where.ts b/types/test/where.ts deleted file mode 100644 index c52467a895be..000000000000 --- a/types/test/where.ts +++ /dev/null @@ -1,298 +0,0 @@ -import { expectTypeOf } from "expect-type"; -import { AndOperator, fn, Model, Op, OrOperator, Sequelize, WhereOperators, WhereOptions, literal, where as whereFn } from 'sequelize'; -import Transaction from 'sequelize/lib/transaction'; - -class MyModel extends Model { - public hi!: number; -} - -// Simple options - -expectTypeOf({ - string: 'foo', - strings: ['foo'], - number: 1, - numbers: [1], - boolean: true, - buffer: Buffer.alloc(0), - buffers: [Buffer.alloc(0)], - null: null, - date: new Date() -}).toMatchTypeOf(); - -// Optional values -expectTypeOf<{ needed: number; optional?: number }>().toMatchTypeOf(); - -// Misusing optional values (typings allow this, sequelize will throw an error during runtime) -// This might be solved by updates to typescript itself (https://github.com/microsoft/TypeScript/issues/13195) -// expectTypeOf({ needed: 2, optional: undefined }).not.toMatchTypeOf(); - -// Operators - -expectTypeOf({ - [Op.and]: { a: 5 }, // AND (a = 5) -}).toMatchTypeOf(); -expectTypeOf({ - [Op.and]: { a: 5 }, // AND (a = 5) -}).toMatchTypeOf>(); - -expectTypeOf({ - [Op.or]: [{ a: 5 }, { a: 6 }], // (a = 5 OR a = 6) -}).toMatchTypeOf(); -expectTypeOf({ - [Op.or]: [{ a: 5 }, { a: 6 }], // (a = 5 OR a = 6) -}).toMatchTypeOf>(); - -expectTypeOf({ - [Op.eq]: 6, // = 6 - [Op.eq]: Sequelize.col('SOME_COL'), // = - [Op.gt]: 6, // > 6 - [Op.gt]: Sequelize.col('SOME_COL'), // > - [Op.gte]: 6, // >= 6 - [Op.gte]: Sequelize.col('SOME_COL'), // >= - [Op.lt]: 10, // < 10 - [Op.lt]: Sequelize.col('SOME_COL'), // < - [Op.lte]: 10, // <= 10 - [Op.lte]: Sequelize.col('SOME_COL'), // <= - [Op.ne]: 20, // != 20 - [Op.not]: true, // IS NOT TRUE - [Op.is]: null, // IS NULL - [Op.between]: [6, 10], // BETWEEN 6 AND 10 - [Op.notBetween]: [11, 15], // NOT BETWEEN 11 AND 15 - [Op.in]: [1, 2], // IN [1, 2] - [Op.notIn]: [1, 2], // NOT IN [1, 2] - [Op.like]: '%hat', // LIKE '%hat' - [Op.notLike]: '%hat', // NOT LIKE '%hat' - [Op.iLike]: '%hat', // ILIKE '%hat' (case insensitive) (PG only) - [Op.notILike]: '%hat', // NOT ILIKE '%hat' (PG only) - [Op.startsWith]: 'hat', - [Op.endsWith]: 'hat', - [Op.substring]: 'hat', - [Op.overlap]: [1, 2], // && [1, 2] (PG array overlap operator) - [Op.contains]: [1, 2], // @> [1, 2] (PG array contains operator) - [Op.contained]: [1, 2], // <@ [1, 2] (PG array contained by operator) - [Op.any]: [2, 3], // ANY ARRAY[2, 3]::INTEGER (PG only) - [Op.regexp]: '^[h|a|t]', // REGEXP/~ '^[h|a|t]' (MySQL/PG only) - [Op.notRegexp]: '^[h|a|t]', // NOT REGEXP/!~ '^[h|a|t]' (MySQL/PG only) - [Op.iRegexp]: '^[h|a|t]', // ~* '^[h|a|t]' (PG only) - [Op.notIRegexp]: '^[h|a|t]' // !~* '^[h|a|t]' (PG only) -} as const).toMatchTypeOf(); - -expectTypeOf({ - [Op.like]: { [Op.any]: ['cat', 'hat'] }, // LIKE ANY ARRAY['cat', 'hat'] - [Op.iLike]: { [Op.any]: ['cat', 'hat'] }, // LIKE ANY ARRAY['cat', 'hat'] - [Op.notLike]: { [Op.any]: ['cat', 'hat'] }, // LIKE ANY ARRAY['cat', 'hat'] - [Op.notILike]: { [Op.any]: ['cat', 'hat'] }, // LIKE ANY ARRAY['cat', 'hat'] -}).toMatchTypeOf(); - -// Complex where options via combinations - -expectTypeOf([ - { [Op.or]: [{ a: 5 }, { a: 6 }] }, - Sequelize.and(), - Sequelize.or(), - { [Op.and]: [] }, - { rank: Sequelize.and({ [Op.lt]: 1000 }, { [Op.eq]: null }) }, - { rank: Sequelize.or({ [Op.lt]: 1000 }, { [Op.eq]: null }) }, - { rank: { [Op.or]: { [Op.lt]: 1000, [Op.eq]: null } } }, - { - createdAt: { - [Op.lt]: new Date(), - [Op.gt]: new Date(Date.now() - 24 * 60 * 60 * 1000), - } - }, - { - [Op.or]: [ - { title: { [Op.like]: 'Boat%' } }, - { description: { [Op.like]: '%boat%' } } - ] - }, - { - meta: { - [Op.contains]: { - site: { - url: 'https://sequelize.org/' - } - } - }, - meta2: { - [Op.contains]: ['stringValue1', 'stringValue2', 'stringValue3'] - }, - meta3: { - [Op.contains]: [1, 2, 3, 4] - }, - }, - { - name: 'a project', - [Op.or]: [{ id: [1, 2, 3] }, { id: { [Op.gt]: 10 } }] - }, - { - id: { - [Op.or]: [[1, 2, 3], { [Op.gt]: 10 }] - }, - name: 'a project' - }, - { - id: { - [Op.or]: [[1, 2, 3], { [Op.gt]: 10 }] - }, - name: 'a project' - }, - { - name: 'a project', - type: { - [Op.and]: [['a', 'b'], { [Op.notLike]: '%z' }], - }, - }, - { - name: 'a project', - [Op.not]: [{ id: [1, 2, 3] }, { array: { [Op.contains]: [3, 4, 5] } }], - }, - { - meta: { - video: { - url: { - [Op.ne]: null, - }, - }, - }, - }, - { - 'meta.audio.length': { - [Op.gt]: 20, - }, - }, - { - [Op.and]: [{ id: [1, 2, 3] }, { array: { [Op.contains]: [3, 4, 5] } }], - }, - { - [Op.gt]: fn('NOW'), - }, - whereFn('test', { [Op.gt]: new Date() }), - literal('true'), - fn('LOWER', 'asd'), - { [Op.lt]: Sequelize.literal('SOME_STRING') } -]).toMatchTypeOf(); - -// Relations / Associations -// Find all projects with a least one task where task.state === project.task -MyModel.findAll({ - include: [ - { - model: MyModel, - where: { state: Sequelize.col('project.state') }, - }, - ], -}); - -{ - const where: WhereOptions = 0 as any; - MyModel.findOne({ - include: [ - { - include: [{ model: MyModel, where }], - model: MyModel, - where, - }, - ], - where, - }); - MyModel.destroy({ where }); - MyModel.update({ hi: 1 }, { where }); - - // Where as having option - MyModel.findAll({ having: where }); -} - -// From https://sequelize.org/master/en/v4/docs/models-usage/ - -async function test() { - // find multiple entries - let projects: MyModel[] = await MyModel.findAll(); - - // search for specific attributes - hash usage - projects = await MyModel.findAll({ where: { name: 'A MyModel', enabled: true } }) - - // search within a specific range - projects = await MyModel.findAll({ where: { id: [1, 2, 3] } }); - - // locks - projects = await MyModel.findAll({ lock: Transaction.LOCK.KEY_SHARE }); - - // locks on model - projects = await MyModel.findAll({ lock: { level: Transaction.LOCK.KEY_SHARE, of: MyModel} }); -} - -MyModel.findAll({ - where: { - id: { - // casting here to check a missing operator is not accepted as field name - [Op.eq]: 6, // id = 6 - [Op.eq]: Sequelize.col('SOME_COL'), // id = - [Op.and]: { a: 5 }, // AND (a = 5) - [Op.or]: [{ a: 5 }, { a: 6 }], // (a = 5 OR a = 6) - [Op.gt]: 6, // id > 6 - [Op.gt]: Sequelize.col('SOME_COL'), // id > - [Op.gte]: 6, // id >= 6 - [Op.gte]: Sequelize.col('SOME_COL'), // id >= - [Op.lt]: 10, // id < 10 - [Op.lt]: Sequelize.col('SOME_COL'), // id < - [Op.lte]: 10, // id <= 10 - [Op.lte]: Sequelize.col('SOME_COL'), // id <= - [Op.ne]: 20, // id != 20 - [Op.between]: [6, 10] || [new Date(), new Date()] || ["2020-01-01", "2020-12-31"], // BETWEEN 6 AND 10 - [Op.notBetween]: [11, 15], // NOT BETWEEN 11 AND 15 - [Op.in]: [1, 2], // IN [1, 2] - [Op.notIn]: [1, 2], // NOT IN [1, 2] - [Op.like]: '%hat', // LIKE '%hat' - [Op.notLike]: '%hat', // NOT LIKE '%hat' - [Op.iLike]: '%hat', // ILIKE '%hat' (case insensitive) (PG only) - [Op.notILike]: '%hat', // NOT ILIKE '%hat' (PG only) - [Op.overlap]: [1, 2], // && [1, 2] (PG array overlap operator) - [Op.contains]: [1, 2], // @> [1, 2] (PG array contains operator) - [Op.contained]: [1, 2], // <@ [1, 2] (PG array contained by operator) - [Op.any]: [2, 3], // ANY ARRAY[2, 3]::INTEGER (PG only) - [Op.adjacent]: [1, 2], - [Op.strictLeft]: [1, 2], - [Op.strictRight]: [1, 2], - [Op.noExtendLeft]: [1, 2], - [Op.noExtendRight]: [1, 2], - [Op.values]: [1, 2], - } as WhereOperators, - status: { - [Op.not]: false, // status NOT FALSE - }, - }, -}); - -Sequelize.where( - Sequelize.cast(Sequelize.col('SOME_COL'), 'INTEGER'), { - [Op.lt]: Sequelize.literal('LIT'), - [Op.any]: Sequelize.literal('LIT'), - [Op.gte]: Sequelize.literal('LIT'), - [Op.lt]: Sequelize.literal('LIT'), - [Op.lte]: Sequelize.literal('LIT'), - [Op.ne]: Sequelize.literal('LIT'), - [Op.not]: Sequelize.literal('LIT'), - [Op.in]: Sequelize.literal('LIT'), - [Op.notIn]: Sequelize.literal('LIT'), - [Op.like]: Sequelize.literal('LIT'), - [Op.notLike]: Sequelize.literal('LIT'), - [Op.iLike]: Sequelize.literal('LIT'), - [Op.overlap]: Sequelize.literal('LIT'), - [Op.contains]: Sequelize.literal('LIT'), - [Op.contained]: Sequelize.literal('LIT'), - [Op.gt]: Sequelize.literal('LIT'), - [Op.notILike]: Sequelize.literal('LIT'), - } -) - -Sequelize.where(Sequelize.col("ABS"), Op.is, null); - -Sequelize.where( - Sequelize.fn("ABS", Sequelize.col("age")), - Op.like, - Sequelize.fn("ABS", Sequelize.col("age")) -); - -Sequelize.where(Sequelize.col("ABS"), null); diff --git a/types/tsconfig.json b/types/tsconfig.json deleted file mode 100644 index 95b00268ae49..000000000000 --- a/types/tsconfig.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "compilerOptions": { - "strict": true, - "module": "commonjs", - "moduleResolution": "node", - "noEmit": true, - "lib": ["es2016"] - }, - "types": ["node"], - "include": ["lib/**/*.d.ts", "index.d.ts"] -} diff --git a/yarn.lock b/yarn.lock index 68a181e4ea09..df0630d12ab0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,63 +2,64 @@ # yarn lockfile v1 -"@azure/abort-controller@^1.0.0": - version "1.0.4" - resolved "https://registry.yarnpkg.com/@azure/abort-controller/-/abort-controller-1.0.4.tgz#fd3c4d46c8ed67aace42498c8e2270960250eafd" - integrity sha512-lNUmDRVGpanCsiUN3NWxFTdwmdFI53xwhkTFfHDGTYk46ca7Ind3nanJc+U6Zj9Tv+9nTCWRBscWEW1DyKOpTw== +"@ampproject/remapping@^2.2.0": + version "2.2.1" + resolved "https://registry.yarnpkg.com/@ampproject/remapping/-/remapping-2.2.1.tgz#99e8e11851128b8702cd57c33684f1d0f260b630" + integrity sha512-lFMjJTrFL3j7L9yBxwYfCq2k6qqwHyzuUl/XBnif78PWTJYyL/dfowQHWE3sp6U6ZzqWiiIZnpTMO96zhkjwtg== dependencies: - tslib "^2.0.0" + "@jridgewell/gen-mapping" "^0.3.0" + "@jridgewell/trace-mapping" "^0.3.9" -"@azure/core-asynciterator-polyfill@^1.0.0": - version "1.0.0" - resolved "https://registry.yarnpkg.com/@azure/core-asynciterator-polyfill/-/core-asynciterator-polyfill-1.0.0.tgz#dcccebb88406e5c76e0e1d52e8cc4c43a68b3ee7" - integrity sha512-kmv8CGrPfN9SwMwrkiBK9VTQYxdFQEGe0BmQk+M8io56P9KNzpAxcWE/1fxJj7uouwN4kXF0BHW8DNlgx+wtCg== +"@azure/abort-controller@^1.0.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@azure/abort-controller/-/abort-controller-1.1.0.tgz#788ee78457a55af8a1ad342acb182383d2119249" + integrity sha512-TrRLIoSQVzfAJX9H1JeFjzAoDGcoK1IYX1UImfceTZpsyYfWr09Ss1aHW1y5TrrR3iq6RZLBwJ3E24uwPhwahw== + dependencies: + tslib "^2.2.0" "@azure/core-auth@^1.1.4", "@azure/core-auth@^1.3.0": - version "1.3.2" - resolved "https://registry.yarnpkg.com/@azure/core-auth/-/core-auth-1.3.2.tgz#6a2c248576c26df365f6c7881ca04b7f6d08e3d0" - integrity sha512-7CU6DmCHIZp5ZPiZ9r3J17lTKMmYsm/zGvNkjArQwPkrLlZ1TZ+EUYfGgh2X31OLMVAQCTJZW4cXHJi02EbJnA== + version "1.4.0" + resolved "https://registry.yarnpkg.com/@azure/core-auth/-/core-auth-1.4.0.tgz#6fa9661c1705857820dbc216df5ba5665ac36a9e" + integrity sha512-HFrcTgmuSuukRf/EdPmqBrc5l6Q5Uu+2TbuhaKbgaCpP2TfAeiNaQPAadxO+CYBRHGUzIDteMAjFspFLDLnKVQ== dependencies: "@azure/abort-controller" "^1.0.0" tslib "^2.2.0" -"@azure/core-http@^2.0.0": - version "2.2.2" - resolved "https://registry.yarnpkg.com/@azure/core-http/-/core-http-2.2.2.tgz#573798f087d808d39aa71fd7c52b8d7b89f440da" - integrity sha512-V1DdoO9V/sFimKpdWoNBgsE+QUjQgpXYnxrTdUp5RyhsTJjvEVn/HKmTQXIHuLUUo6IyIWj+B+Dg4VaXse9dIA== +"@azure/core-http@^3.0.0": + version "3.0.2" + resolved "https://registry.yarnpkg.com/@azure/core-http/-/core-http-3.0.2.tgz#970c5a0ee27884d60a406eeec17a271413e45ff4" + integrity sha512-o1wR9JrmoM0xEAa0Ue7Sp8j+uJvmqYaGoHOCT5qaVYmvgmnZDC0OvQimPA/JR3u77Sz6D1y3Xmk1y69cDU9q9A== dependencies: "@azure/abort-controller" "^1.0.0" - "@azure/core-asynciterator-polyfill" "^1.0.0" "@azure/core-auth" "^1.3.0" "@azure/core-tracing" "1.0.0-preview.13" + "@azure/core-util" "^1.1.1" "@azure/logger" "^1.0.0" "@types/node-fetch" "^2.5.0" "@types/tunnel" "^0.0.3" form-data "^4.0.0" - node-fetch "^2.6.0" + node-fetch "^2.6.7" process "^0.11.10" - tough-cookie "^4.0.0" tslib "^2.2.0" tunnel "^0.0.6" uuid "^8.3.0" - xml2js "^0.4.19" + xml2js "^0.5.0" "@azure/core-lro@^2.2.0": - version "2.2.2" - resolved "https://registry.yarnpkg.com/@azure/core-lro/-/core-lro-2.2.2.tgz#1f81a712d6bea6912918c5157553e6c7883e08d9" - integrity sha512-pn30b+HyJHg0+G4ZRgpL3BJa6LQnKdKl1X4JDMpuVsX+kPxs2FNoweNqD3Li199ROroIvFbi6pE29y0J2vvyIg== + version "2.5.3" + resolved "https://registry.yarnpkg.com/@azure/core-lro/-/core-lro-2.5.3.tgz#6bb74e76dd84071d319abf7025e8abffef091f91" + integrity sha512-ubkOf2YCnVtq7KqEJQqAI8dDD5rH1M6OP5kW0KO/JQyTaxLA0N0pjFWvvaysCj9eHMNBcuuoZXhhl0ypjod2DA== dependencies: "@azure/abort-controller" "^1.0.0" - "@azure/core-tracing" "1.0.0-preview.13" + "@azure/core-util" "^1.2.0" "@azure/logger" "^1.0.0" tslib "^2.2.0" "@azure/core-paging@^1.1.1": - version "1.2.0" - resolved "https://registry.yarnpkg.com/@azure/core-paging/-/core-paging-1.2.0.tgz#3754da429e8687bdc3613c750e79a564582e802b" - integrity sha512-ZX1bCjm/MjKPCN6kQD/9GJErYSoKA8YWp6YWoo5EIzcTWlSBLXu3gNaBTUl8usGl+UShiKo7b4Gdy1NSTIlpZg== + version "1.5.0" + resolved "https://registry.yarnpkg.com/@azure/core-paging/-/core-paging-1.5.0.tgz#5a5b09353e636072e6a7fc38f7879e11d0afb15f" + integrity sha512-zqWdVIt+2Z+3wqxEOGzR5hXFZ8MGKK52x4vFLw8n58pR6ZfKRx3EXYTxTaYxYHc/PexPUTyimcTWFJbji9Z6Iw== dependencies: - "@azure/core-asynciterator-polyfill" "^1.0.0" tslib "^2.2.0" "@azure/core-tracing@1.0.0-preview.13": @@ -69,10 +70,18 @@ "@opentelemetry/api" "^1.0.1" tslib "^2.2.0" +"@azure/core-util@^1.1.1", "@azure/core-util@^1.2.0": + version "1.3.2" + resolved "https://registry.yarnpkg.com/@azure/core-util/-/core-util-1.3.2.tgz#3f8cfda1e87fac0ce84f8c1a42fcd6d2a986632d" + integrity sha512-2bECOUh88RvL1pMZTcc6OzfobBeWDBf5oBbhjIhT1MV9otMVWCzpOJkkiKtrnO88y5GGBelgY8At73KGAdbkeQ== + dependencies: + "@azure/abort-controller" "^1.0.0" + tslib "^2.2.0" + "@azure/logger@^1.0.0": - version "1.0.3" - resolved "https://registry.yarnpkg.com/@azure/logger/-/logger-1.0.3.tgz#6e36704aa51be7d4a1bae24731ea580836293c96" - integrity sha512-aK4s3Xxjrx3daZr3VylxejK3vG5ExXck5WOHDJ8in/k9AqlfIyFMMT1uG7u8mNjX+QRILTIn0/Xgschfh/dQ9g== + version "1.0.4" + resolved "https://registry.yarnpkg.com/@azure/logger/-/logger-1.0.4.tgz#28bc6d0e5b3c38ef29296b32d35da4e483593fa1" + integrity sha512-ustrPY8MryhloQj7OWGe+HrYx+aoiOxzbXTtgblbV3xwCqpzUK36phH3XNHQKj3EPonyFUuDTfR3qFhTEAuZEg== dependencies: tslib "^2.2.0" @@ -104,13 +113,13 @@ "@azure/ms-rest-js" "^1.8.7" adal-node "^0.1.28" -"@azure/storage-blob@^12.5.0": - version "12.8.0" - resolved "https://registry.yarnpkg.com/@azure/storage-blob/-/storage-blob-12.8.0.tgz#97b7ecc6c7b17bcbaf0281c79c16af6f512d6130" - integrity sha512-c8+Wz19xauW0bGkTCoqZH4dYfbtBniPiGiRQOn1ca6G5jsjr4azwaTk9gwjVY8r3vY2Taf95eivLzipfIfiS4A== +"@azure/storage-blob@^12.11.0": + version "12.14.0" + resolved "https://registry.yarnpkg.com/@azure/storage-blob/-/storage-blob-12.14.0.tgz#32d3e5fa3bb2a12d5d44b186aed11c8e78f00178" + integrity sha512-g8GNUDpMisGXzBeD+sKphhH5yLwesB4JkHr1U6be/X3F+cAMcyGLPD1P89g2M7wbEtUJWoikry1rlr83nNRBzg== dependencies: "@azure/abort-controller" "^1.0.0" - "@azure/core-http" "^2.0.0" + "@azure/core-http" "^3.0.0" "@azure/core-lro" "^2.2.0" "@azure/core-paging" "^1.1.1" "@azure/core-tracing" "1.0.0-preview.13" @@ -118,205 +127,192 @@ events "^3.0.0" tslib "^2.2.0" -"@babel/code-frame@^7.0.0", "@babel/code-frame@^7.16.0": - version "7.16.0" - resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.16.0.tgz#0dfc80309beec8411e65e706461c408b0bb9b431" - integrity sha512-IF4EOMEV+bfYwOmNxGzSnjR2EmQod7f1UXOpZM3l4i4o4QNwzjtJAu/HxdjHq0aYBvdqMuQEY1eg0nqW9ZPORA== +"@babel/code-frame@^7.0.0", "@babel/code-frame@^7.22.5": + version "7.22.5" + resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.22.5.tgz#234d98e1551960604f1246e6475891a570ad5658" + integrity sha512-Xmwn266vad+6DAqEB2A6V/CcZVp62BbwVmcOJc2RPuwih1kw02TjQvWVWlcKGbBPd+8/0V5DEkOcizRGYsspYQ== dependencies: - "@babel/highlight" "^7.16.0" + "@babel/highlight" "^7.22.5" -"@babel/compat-data@^7.16.0": - version "7.16.4" - resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.16.4.tgz#081d6bbc336ec5c2435c6346b2ae1fb98b5ac68e" - integrity sha512-1o/jo7D+kC9ZjHX5v+EHrdjl3PhxMrLSOTGsOdHJ+KL8HCaEK6ehrVL2RS6oHDZp+L7xLirLrPmQtEng769J/Q== +"@babel/compat-data@^7.22.5": + version "7.22.5" + resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.22.5.tgz#b1f6c86a02d85d2dd3368a2b67c09add8cd0c255" + integrity sha512-4Jc/YuIaYqKnDDz892kPIledykKg12Aw1PYX5i/TY28anJtacvM1Rrr8wbieB9GfEJwlzqT0hUEao0CxEebiDA== "@babel/core@^7.7.5": - version "7.16.0" - resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.16.0.tgz#c4ff44046f5fe310525cc9eb4ef5147f0c5374d4" - integrity sha512-mYZEvshBRHGsIAiyH5PzCFTCfbWfoYbO/jcSdXQSUQu1/pW0xDZAUP7KEc32heqWTAfAHhV9j1vH8Sav7l+JNQ== - dependencies: - "@babel/code-frame" "^7.16.0" - "@babel/generator" "^7.16.0" - "@babel/helper-compilation-targets" "^7.16.0" - "@babel/helper-module-transforms" "^7.16.0" - "@babel/helpers" "^7.16.0" - "@babel/parser" "^7.16.0" - "@babel/template" "^7.16.0" - "@babel/traverse" "^7.16.0" - "@babel/types" "^7.16.0" + version "7.22.5" + resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.22.5.tgz#d67d9747ecf26ee7ecd3ebae1ee22225fe902a89" + integrity sha512-SBuTAjg91A3eKOvD+bPEz3LlhHZRNu1nFOVts9lzDJTXshHTjII0BAtDS3Y2DAkdZdDKWVZGVwkDfc4Clxn1dg== + dependencies: + "@ampproject/remapping" "^2.2.0" + "@babel/code-frame" "^7.22.5" + "@babel/generator" "^7.22.5" + "@babel/helper-compilation-targets" "^7.22.5" + "@babel/helper-module-transforms" "^7.22.5" + "@babel/helpers" "^7.22.5" + "@babel/parser" "^7.22.5" + "@babel/template" "^7.22.5" + "@babel/traverse" "^7.22.5" + "@babel/types" "^7.22.5" convert-source-map "^1.7.0" debug "^4.1.0" gensync "^1.0.0-beta.2" - json5 "^2.1.2" + json5 "^2.2.2" semver "^6.3.0" - source-map "^0.5.0" -"@babel/generator@^7.16.0": - version "7.16.0" - resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.16.0.tgz#d40f3d1d5075e62d3500bccb67f3daa8a95265b2" - integrity sha512-RR8hUCfRQn9j9RPKEVXo9LiwoxLPYn6hNZlvUOR8tSnaxlD0p0+la00ZP9/SnRt6HchKr+X0fO2r8vrETiJGew== +"@babel/generator@^7.22.5": + version "7.22.5" + resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.22.5.tgz#1e7bf768688acfb05cf30b2369ef855e82d984f7" + integrity sha512-+lcUbnTRhd0jOewtFSedLyiPsD5tswKkbgcezOqqWFUVNEwoUTlpPOBmvhG7OXWLR4jMdv0czPGH5XbflnD1EA== dependencies: - "@babel/types" "^7.16.0" + "@babel/types" "^7.22.5" + "@jridgewell/gen-mapping" "^0.3.2" + "@jridgewell/trace-mapping" "^0.3.17" jsesc "^2.5.1" - source-map "^0.5.0" -"@babel/helper-compilation-targets@^7.16.0": - version "7.16.3" - resolved "https://registry.yarnpkg.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.16.3.tgz#5b480cd13f68363df6ec4dc8ac8e2da11363cbf0" - integrity sha512-vKsoSQAyBmxS35JUOOt+07cLc6Nk/2ljLIHwmq2/NM6hdioUaqEXq/S+nXvbvXbZkNDlWOymPanJGOc4CBjSJA== +"@babel/helper-compilation-targets@^7.22.5": + version "7.22.5" + resolved "https://registry.yarnpkg.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.22.5.tgz#fc7319fc54c5e2fa14b2909cf3c5fd3046813e02" + integrity sha512-Ji+ywpHeuqxB8WDxraCiqR0xfhYjiDE/e6k7FuIaANnoOFxAHskHChz4vA1mJC9Lbm01s1PVAGhQY4FUKSkGZw== dependencies: - "@babel/compat-data" "^7.16.0" - "@babel/helper-validator-option" "^7.14.5" - browserslist "^4.17.5" + "@babel/compat-data" "^7.22.5" + "@babel/helper-validator-option" "^7.22.5" + browserslist "^4.21.3" + lru-cache "^5.1.1" semver "^6.3.0" -"@babel/helper-function-name@^7.16.0": - version "7.16.0" - resolved "https://registry.yarnpkg.com/@babel/helper-function-name/-/helper-function-name-7.16.0.tgz#b7dd0797d00bbfee4f07e9c4ea5b0e30c8bb1481" - integrity sha512-BZh4mEk1xi2h4HFjWUXRQX5AEx4rvaZxHgax9gcjdLWdkjsY7MKt5p0otjsg5noXw+pB+clMCjw+aEVYADMjog== - dependencies: - "@babel/helper-get-function-arity" "^7.16.0" - "@babel/template" "^7.16.0" - "@babel/types" "^7.16.0" - -"@babel/helper-get-function-arity@^7.16.0": - version "7.16.0" - resolved "https://registry.yarnpkg.com/@babel/helper-get-function-arity/-/helper-get-function-arity-7.16.0.tgz#0088c7486b29a9cb5d948b1a1de46db66e089cfa" - integrity sha512-ASCquNcywC1NkYh/z7Cgp3w31YW8aojjYIlNg4VeJiHkqyP4AzIvr4qx7pYDb4/s8YcsZWqqOSxgkvjUz1kpDQ== - dependencies: - "@babel/types" "^7.16.0" - -"@babel/helper-hoist-variables@^7.16.0": - version "7.16.0" - resolved "https://registry.yarnpkg.com/@babel/helper-hoist-variables/-/helper-hoist-variables-7.16.0.tgz#4c9023c2f1def7e28ff46fc1dbcd36a39beaa81a" - integrity sha512-1AZlpazjUR0EQZQv3sgRNfM9mEVWPK3M6vlalczA+EECcPz3XPh6VplbErL5UoMpChhSck5wAJHthlj1bYpcmg== - dependencies: - "@babel/types" "^7.16.0" - -"@babel/helper-member-expression-to-functions@^7.16.0": - version "7.16.0" - resolved "https://registry.yarnpkg.com/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.16.0.tgz#29287040efd197c77636ef75188e81da8bccd5a4" - integrity sha512-bsjlBFPuWT6IWhl28EdrQ+gTvSvj5tqVP5Xeftp07SEuz5pLnsXZuDkDD3Rfcxy0IsHmbZ+7B2/9SHzxO0T+sQ== - dependencies: - "@babel/types" "^7.16.0" - -"@babel/helper-module-imports@^7.16.0": - version "7.16.0" - resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.16.0.tgz#90538e60b672ecf1b448f5f4f5433d37e79a3ec3" - integrity sha512-kkH7sWzKPq0xt3H1n+ghb4xEMP8k0U7XV3kkB+ZGy69kDk2ySFW1qPi06sjKzFY3t1j6XbJSqr4mF9L7CYVyhg== - dependencies: - "@babel/types" "^7.16.0" - -"@babel/helper-module-transforms@^7.16.0": - version "7.16.0" - resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.16.0.tgz#1c82a8dd4cb34577502ebd2909699b194c3e9bb5" - integrity sha512-My4cr9ATcaBbmaEa8M0dZNA74cfI6gitvUAskgDtAFmAqyFKDSHQo5YstxPbN+lzHl2D9l/YOEFqb2mtUh4gfA== - dependencies: - "@babel/helper-module-imports" "^7.16.0" - "@babel/helper-replace-supers" "^7.16.0" - "@babel/helper-simple-access" "^7.16.0" - "@babel/helper-split-export-declaration" "^7.16.0" - "@babel/helper-validator-identifier" "^7.15.7" - "@babel/template" "^7.16.0" - "@babel/traverse" "^7.16.0" - "@babel/types" "^7.16.0" - -"@babel/helper-optimise-call-expression@^7.16.0": - version "7.16.0" - resolved "https://registry.yarnpkg.com/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.16.0.tgz#cecdb145d70c54096b1564f8e9f10cd7d193b338" - integrity sha512-SuI467Gi2V8fkofm2JPnZzB/SUuXoJA5zXe/xzyPP2M04686RzFKFHPK6HDVN6JvWBIEW8tt9hPR7fXdn2Lgpw== - dependencies: - "@babel/types" "^7.16.0" - -"@babel/helper-replace-supers@^7.16.0": - version "7.16.0" - resolved "https://registry.yarnpkg.com/@babel/helper-replace-supers/-/helper-replace-supers-7.16.0.tgz#73055e8d3cf9bcba8ddb55cad93fedc860f68f17" - integrity sha512-TQxuQfSCdoha7cpRNJvfaYxxxzmbxXw/+6cS7V02eeDYyhxderSoMVALvwupA54/pZcOTtVeJ0xccp1nGWladA== - dependencies: - "@babel/helper-member-expression-to-functions" "^7.16.0" - "@babel/helper-optimise-call-expression" "^7.16.0" - "@babel/traverse" "^7.16.0" - "@babel/types" "^7.16.0" - -"@babel/helper-simple-access@^7.16.0": - version "7.16.0" - resolved "https://registry.yarnpkg.com/@babel/helper-simple-access/-/helper-simple-access-7.16.0.tgz#21d6a27620e383e37534cf6c10bba019a6f90517" - integrity sha512-o1rjBT/gppAqKsYfUdfHq5Rk03lMQrkPHG1OWzHWpLgVXRH4HnMM9Et9CVdIqwkCQlobnGHEJMsgWP/jE1zUiw== - dependencies: - "@babel/types" "^7.16.0" - -"@babel/helper-split-export-declaration@^7.16.0": - version "7.16.0" - resolved "https://registry.yarnpkg.com/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.16.0.tgz#29672f43663e936df370aaeb22beddb3baec7438" - integrity sha512-0YMMRpuDFNGTHNRiiqJX19GjNXA4H0E8jZ2ibccfSxaCogbm3am5WN/2nQNj0YnQwGWM1J06GOcQ2qnh3+0paw== - dependencies: - "@babel/types" "^7.16.0" - -"@babel/helper-validator-identifier@^7.15.7": - version "7.15.7" - resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.15.7.tgz#220df993bfe904a4a6b02ab4f3385a5ebf6e2389" - integrity sha512-K4JvCtQqad9OY2+yTU8w+E82ywk/fe+ELNlt1G8z3bVGlZfn/hOcQQsUhGhW/N+tb3fxK800wLtKOE/aM0m72w== - -"@babel/helper-validator-option@^7.14.5": - version "7.14.5" - resolved "https://registry.yarnpkg.com/@babel/helper-validator-option/-/helper-validator-option-7.14.5.tgz#6e72a1fff18d5dfcb878e1e62f1a021c4b72d5a3" - integrity sha512-OX8D5eeX4XwcroVW45NMvoYaIuFI+GQpA2a8Gi+X/U/cDUIRsV37qQfF905F0htTRCREQIB4KqPeaveRJUl3Ow== - -"@babel/helpers@^7.16.0": - version "7.16.3" - resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.16.3.tgz#27fc64f40b996e7074dc73128c3e5c3e7f55c43c" - integrity sha512-Xn8IhDlBPhvYTvgewPKawhADichOsbkZuzN7qz2BusOM0brChsyXMDJvldWaYMMUNiCQdQzNEioXTp3sC8Nt8w== - dependencies: - "@babel/template" "^7.16.0" - "@babel/traverse" "^7.16.3" - "@babel/types" "^7.16.0" - -"@babel/highlight@^7.16.0": - version "7.16.0" - resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.16.0.tgz#6ceb32b2ca4b8f5f361fb7fd821e3fddf4a1725a" - integrity sha512-t8MH41kUQylBtu2+4IQA3atqevA2lRgqA2wyVB/YiWmsDSuylZZuXOUy9ric30hfzauEFfdsuk/eXTRrGrfd0g== - dependencies: - "@babel/helper-validator-identifier" "^7.15.7" +"@babel/helper-environment-visitor@^7.22.5": + version "7.22.5" + resolved "https://registry.yarnpkg.com/@babel/helper-environment-visitor/-/helper-environment-visitor-7.22.5.tgz#f06dd41b7c1f44e1f8da6c4055b41ab3a09a7e98" + integrity sha512-XGmhECfVA/5sAt+H+xpSg0mfrHq6FzNr9Oxh7PSEBBRUb/mL7Kz3NICXb194rCqAEdxkhPT1a88teizAFyvk8Q== + +"@babel/helper-function-name@^7.22.5": + version "7.22.5" + resolved "https://registry.yarnpkg.com/@babel/helper-function-name/-/helper-function-name-7.22.5.tgz#ede300828905bb15e582c037162f99d5183af1be" + integrity sha512-wtHSq6jMRE3uF2otvfuD3DIvVhOsSNshQl0Qrd7qC9oQJzHvOL4qQXlQn2916+CXGywIjpGuIkoyZRRxHPiNQQ== + dependencies: + "@babel/template" "^7.22.5" + "@babel/types" "^7.22.5" + +"@babel/helper-hoist-variables@^7.22.5": + version "7.22.5" + resolved "https://registry.yarnpkg.com/@babel/helper-hoist-variables/-/helper-hoist-variables-7.22.5.tgz#c01a007dac05c085914e8fb652b339db50d823bb" + integrity sha512-wGjk9QZVzvknA6yKIUURb8zY3grXCcOZt+/7Wcy8O2uctxhplmUPkOdlgoNhmdVee2c92JXbf1xpMtVNbfoxRw== + dependencies: + "@babel/types" "^7.22.5" + +"@babel/helper-module-imports@^7.22.5": + version "7.22.5" + resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.22.5.tgz#1a8f4c9f4027d23f520bd76b364d44434a72660c" + integrity sha512-8Dl6+HD/cKifutF5qGd/8ZJi84QeAKh+CEe1sBzz8UayBBGg1dAIJrdHOcOM5b2MpzWL2yuotJTtGjETq0qjXg== + dependencies: + "@babel/types" "^7.22.5" + +"@babel/helper-module-transforms@^7.22.5": + version "7.22.5" + resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.22.5.tgz#0f65daa0716961b6e96b164034e737f60a80d2ef" + integrity sha512-+hGKDt/Ze8GFExiVHno/2dvG5IdstpzCq0y4Qc9OJ25D4q3pKfiIP/4Vp3/JvhDkLKsDK2api3q3fpIgiIF5bw== + dependencies: + "@babel/helper-environment-visitor" "^7.22.5" + "@babel/helper-module-imports" "^7.22.5" + "@babel/helper-simple-access" "^7.22.5" + "@babel/helper-split-export-declaration" "^7.22.5" + "@babel/helper-validator-identifier" "^7.22.5" + "@babel/template" "^7.22.5" + "@babel/traverse" "^7.22.5" + "@babel/types" "^7.22.5" + +"@babel/helper-simple-access@^7.22.5": + version "7.22.5" + resolved "https://registry.yarnpkg.com/@babel/helper-simple-access/-/helper-simple-access-7.22.5.tgz#4938357dc7d782b80ed6dbb03a0fba3d22b1d5de" + integrity sha512-n0H99E/K+Bika3++WNL17POvo4rKWZ7lZEp1Q+fStVbUi8nxPQEBOlTmCOxW/0JsS56SKKQ+ojAe2pHKJHN35w== + dependencies: + "@babel/types" "^7.22.5" + +"@babel/helper-split-export-declaration@^7.22.5": + version "7.22.5" + resolved "https://registry.yarnpkg.com/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.22.5.tgz#88cf11050edb95ed08d596f7a044462189127a08" + integrity sha512-thqK5QFghPKWLhAV321lxF95yCg2K3Ob5yw+M3VHWfdia0IkPXUtoLH8x/6Fh486QUvzhb8YOWHChTVen2/PoQ== + dependencies: + "@babel/types" "^7.22.5" + +"@babel/helper-string-parser@^7.22.5": + version "7.22.5" + resolved "https://registry.yarnpkg.com/@babel/helper-string-parser/-/helper-string-parser-7.22.5.tgz#533f36457a25814cf1df6488523ad547d784a99f" + integrity sha512-mM4COjgZox8U+JcXQwPijIZLElkgEpO5rsERVDJTc2qfCDfERyob6k5WegS14SX18IIjv+XD+GrqNumY5JRCDw== + +"@babel/helper-validator-identifier@^7.22.5": + version "7.22.5" + resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.5.tgz#9544ef6a33999343c8740fa51350f30eeaaaf193" + integrity sha512-aJXu+6lErq8ltp+JhkJUfk1MTGyuA4v7f3pA+BJ5HLfNC6nAQ0Cpi9uOquUj8Hehg0aUiHzWQbOVJGao6ztBAQ== + +"@babel/helper-validator-option@^7.22.5": + version "7.22.5" + resolved "https://registry.yarnpkg.com/@babel/helper-validator-option/-/helper-validator-option-7.22.5.tgz#de52000a15a177413c8234fa3a8af4ee8102d0ac" + integrity sha512-R3oB6xlIVKUnxNUxbmgq7pKjxpru24zlimpE8WK47fACIlM0II/Hm1RS8IaOI7NgCr6LNS+jl5l75m20npAziw== + +"@babel/helpers@^7.22.5": + version "7.22.5" + resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.22.5.tgz#74bb4373eb390d1ceed74a15ef97767e63120820" + integrity sha512-pSXRmfE1vzcUIDFQcSGA5Mr+GxBV9oiRKDuDxXvWQQBCh8HoIjs/2DlDB7H8smac1IVrB9/xdXj2N3Wol9Cr+Q== + dependencies: + "@babel/template" "^7.22.5" + "@babel/traverse" "^7.22.5" + "@babel/types" "^7.22.5" + +"@babel/highlight@^7.22.5": + version "7.22.5" + resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.22.5.tgz#aa6c05c5407a67ebce408162b7ede789b4d22031" + integrity sha512-BSKlD1hgnedS5XRnGOljZawtag7H1yPfQp0tdNJCHoH6AZ+Pcm9VvkrK59/Yy593Ypg0zMxH2BxD1VPYUQ7UIw== + dependencies: + "@babel/helper-validator-identifier" "^7.22.5" chalk "^2.0.0" js-tokens "^4.0.0" -"@babel/parser@^7.16.0", "@babel/parser@^7.16.3": - version "7.16.4" - resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.16.4.tgz#d5f92f57cf2c74ffe9b37981c0e72fee7311372e" - integrity sha512-6V0qdPUaiVHH3RtZeLIsc+6pDhbYzHR8ogA8w+f+Wc77DuXto19g2QUwveINoS34Uw+W8/hQDGJCx+i4n7xcng== - -"@babel/template@^7.16.0": - version "7.16.0" - resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.16.0.tgz#d16a35ebf4cd74e202083356fab21dd89363ddd6" - integrity sha512-MnZdpFD/ZdYhXwiunMqqgyZyucaYsbL0IrjoGjaVhGilz+x8YB++kRfygSOIj1yOtWKPlx7NBp+9I1RQSgsd5A== - dependencies: - "@babel/code-frame" "^7.16.0" - "@babel/parser" "^7.16.0" - "@babel/types" "^7.16.0" - -"@babel/traverse@^7.16.0", "@babel/traverse@^7.16.3": - version "7.16.3" - resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.16.3.tgz#f63e8a938cc1b780f66d9ed3c54f532ca2d14787" - integrity sha512-eolumr1vVMjqevCpwVO99yN/LoGL0EyHiLO5I043aYQvwOJ9eR5UsZSClHVCzfhBduMAsSzgA/6AyqPjNayJag== - dependencies: - "@babel/code-frame" "^7.16.0" - "@babel/generator" "^7.16.0" - "@babel/helper-function-name" "^7.16.0" - "@babel/helper-hoist-variables" "^7.16.0" - "@babel/helper-split-export-declaration" "^7.16.0" - "@babel/parser" "^7.16.3" - "@babel/types" "^7.16.0" +"@babel/parser@^7.22.5": + version "7.22.5" + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.22.5.tgz#721fd042f3ce1896238cf1b341c77eb7dee7dbea" + integrity sha512-DFZMC9LJUG9PLOclRC32G63UXwzqS2koQC8dkx+PLdmt1xSePYpbT/NbsrJy8Q/muXz7o/h/d4A7Fuyixm559Q== + +"@babel/template@^7.22.5": + version "7.22.5" + resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.22.5.tgz#0c8c4d944509875849bd0344ff0050756eefc6ec" + integrity sha512-X7yV7eiwAxdj9k94NEylvbVHLiVG1nvzCV2EAowhxLTwODV1jl9UzZ48leOC0sH7OnuHrIkllaBgneUykIcZaw== + dependencies: + "@babel/code-frame" "^7.22.5" + "@babel/parser" "^7.22.5" + "@babel/types" "^7.22.5" + +"@babel/traverse@^7.22.5": + version "7.22.5" + resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.22.5.tgz#44bd276690db6f4940fdb84e1cb4abd2f729ccd1" + integrity sha512-7DuIjPgERaNo6r+PZwItpjCZEa5vyw4eJGufeLxrPdBXBoLcCJCIasvK6pK/9DVNrLZTLFhUGqaC6X/PA007TQ== + dependencies: + "@babel/code-frame" "^7.22.5" + "@babel/generator" "^7.22.5" + "@babel/helper-environment-visitor" "^7.22.5" + "@babel/helper-function-name" "^7.22.5" + "@babel/helper-hoist-variables" "^7.22.5" + "@babel/helper-split-export-declaration" "^7.22.5" + "@babel/parser" "^7.22.5" + "@babel/types" "^7.22.5" debug "^4.1.0" globals "^11.1.0" -"@babel/types@^7.16.0": - version "7.16.0" - resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.16.0.tgz#db3b313804f96aadd0b776c4823e127ad67289ba" - integrity sha512-PJgg/k3SdLsGb3hhisFvtLOw5ts113klrpLuIPtCJIU+BB24fqq6lf8RWqKJEjzqXR9AEH1rIb5XTqwBHB+kQg== +"@babel/types@^7.22.5": + version "7.22.5" + resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.22.5.tgz#cd93eeaab025880a3a47ec881f4b096a5b786fbe" + integrity sha512-zo3MIHGOkPOfoRXitsgHLjEXmlDaD/5KU1Uzuc9GNiZPhSqVxVRtxuPaSBZDsYZ9qV88AjtMtWW7ww98loJ9KA== dependencies: - "@babel/helper-validator-identifier" "^7.15.7" + "@babel/helper-string-parser" "^7.22.5" + "@babel/helper-validator-identifier" "^7.22.5" to-fast-properties "^2.0.0" +"@colors/colors@1.5.0": + version "1.5.0" + resolved "https://registry.yarnpkg.com/@colors/colors/-/colors-1.5.0.tgz#bb504579c1cae923e6576a4f5da43d25f97bdbd9" + integrity sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ== + "@commitlint/cli@^15.0.0": version "15.0.0" resolved "https://registry.yarnpkg.com/@commitlint/cli/-/cli-15.0.0.tgz#8e78e86ee2b6955c1a5d140e734a6c171ce367ee" @@ -463,9 +459,9 @@ chalk "^4.0.0" "@dabh/diagnostics@^2.0.2": - version "2.0.2" - resolved "https://registry.yarnpkg.com/@dabh/diagnostics/-/diagnostics-2.0.2.tgz#290d08f7b381b8f94607dc8f471a12c675f9db31" - integrity sha512-+A1YivoVDNNVCdfozHSR8v/jyuuLTMXwjWuxPFlFlUapXoGc+Gj9mDlTDDfrwl7rXCl2tNZ0kE8sIBO6YOn96Q== + version "2.0.3" + resolved "https://registry.yarnpkg.com/@dabh/diagnostics/-/diagnostics-2.0.3.tgz#7f7e97ee9a725dffc7808d93668cc984e1dc477a" + integrity sha512-hrlQOIi7hAfzsMqlGSFyVucrx38O+j6wiGOf//H2ecvIEqYN4ADBSS2iLMh5UFyDunCNniUIPk/q3riFv45xRA== dependencies: colorspace "1.1.x" enabled "2.0.x" @@ -481,43 +477,106 @@ ts-node "^9" tslib "^2" -"@es-joy/jsdoccomment@0.13.0": - version "0.13.0" - resolved "https://registry.yarnpkg.com/@es-joy/jsdoccomment/-/jsdoccomment-0.13.0.tgz#90ffe2006981ff66d3f4fd2f05949487f0fca089" - integrity sha512-APVqbVPGOprb4BmjEnwbSzV+V2e/6DVIUnZG3zdW5uWXWkN0DKMCpiIy2TdBauoANKYO7RQpO8cTjIYNVSKwUA== +"@es-joy/jsdoccomment@~0.20.1": + version "0.20.1" + resolved "https://registry.yarnpkg.com/@es-joy/jsdoccomment/-/jsdoccomment-0.20.1.tgz#fe89f435f045ae5aaf89c7a4df3616c03e9d106e" + integrity sha512-oeJK41dcdqkvdZy/HctKklJNkt/jh+av3PZARrZEl+fs/8HaHeeYoAvEwOV0u5I6bArTF17JEsTZMY359e/nfQ== dependencies: comment-parser "1.3.0" esquery "^1.4.0" - jsdoc-type-pratt-parser "2.0.0" + jsdoc-type-pratt-parser "~2.2.3" -"@eslint/eslintrc@^1.0.5": - version "1.0.5" - resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-1.0.5.tgz#33f1b838dbf1f923bfa517e008362b78ddbbf318" - integrity sha512-BLxsnmK3KyPunz5wmCCpqy0YelEoxxGmH73Is+Z74oOTMtExcjkr3dDR6quwrjh1YspA8DH9gnX1o069KiS9AQ== +"@eslint-community/eslint-utils@^4.2.0": + version "4.4.0" + resolved "https://registry.yarnpkg.com/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz#a23514e8fb9af1269d5f7788aa556798d61c6b59" + integrity sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA== + dependencies: + eslint-visitor-keys "^3.3.0" + +"@eslint-community/regexpp@^4.4.0": + version "4.5.1" + resolved "https://registry.yarnpkg.com/@eslint-community/regexpp/-/regexpp-4.5.1.tgz#cdd35dce4fa1a89a4fd42b1599eb35b3af408884" + integrity sha512-Z5ba73P98O1KUYCCJTUeVpja9RcGoMdncZ6T49FCUl2lN38JtCJ+3WgIDBv0AuY4WChU5PmtJmOCTlN6FZTFKQ== + +"@eslint/eslintrc@^2.0.3": + version "2.0.3" + resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-2.0.3.tgz#4910db5505f4d503f27774bf356e3704818a0331" + integrity sha512-+5gy6OQfk+xx3q0d6jGZZC3f3KzAkXc/IanVxd1is/VIIziRqqt3ongQz0FiTUXqTk0c7aDB3OaFuKnuSoJicQ== dependencies: ajv "^6.12.4" debug "^4.3.2" - espree "^9.2.0" - globals "^13.9.0" - ignore "^4.0.6" + espree "^9.5.2" + globals "^13.19.0" + ignore "^5.2.0" import-fresh "^3.2.1" js-yaml "^4.1.0" - minimatch "^3.0.4" + minimatch "^3.1.2" strip-json-comments "^3.1.1" +"@eslint/js@8.42.0": + version "8.42.0" + resolved "https://registry.yarnpkg.com/@eslint/js/-/js-8.42.0.tgz#484a1d638de2911e6f5a30c12f49c7e4a3270fb6" + integrity sha512-6SWlXpWU5AvId8Ac7zjzmIOqMOba/JWY8XZ4A7q7Gn1Vlfg/SFFIlrtHXt9nPn4op9ZPAkl91Jao+QQv3r/ukw== + "@gar/promisify@^1.0.1": - version "1.1.2" - resolved "https://registry.yarnpkg.com/@gar/promisify/-/promisify-1.1.2.tgz#30aa825f11d438671d585bd44e7fd564535fc210" - integrity sha512-82cpyJyKRoQoRi+14ibCeGPu0CwypgtBAdBhq1WfvagpCZNKqwXbKwXllYSMG91DhmG4jt9gN8eP6lGOtozuaw== + version "1.1.3" + resolved "https://registry.yarnpkg.com/@gar/promisify/-/promisify-1.1.3.tgz#555193ab2e3bb3b6adc3d551c9c030d9e860daf6" + integrity sha512-k2Ty1JcVojjJFwrg/ThKi2ujJ7XNLYaFGNB/bWT9wGR+oSMJHMa5w+CUq6p/pVrKeNNgA7pCqEcjSnHVoqJQFw== -"@humanwhocodes/config-array@^0.9.2": - version "0.9.2" - resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.9.2.tgz#68be55c737023009dfc5fe245d51181bb6476914" - integrity sha512-UXOuFCGcwciWckOpmfKDq/GyhlTf9pN/BzG//x8p8zTOFEcGuA68ANXheFS0AGvy3qgZqLBUkMs7hqzqCKOVwA== +"@google-cloud/paginator@^3.0.7": + version "3.0.7" + resolved "https://registry.yarnpkg.com/@google-cloud/paginator/-/paginator-3.0.7.tgz#fb6f8e24ec841f99defaebf62c75c2e744dd419b" + integrity sha512-jJNutk0arIQhmpUUQJPJErsojqo834KcyB6X7a1mxuic8i1tKXxde8E69IZxNZawRIlZdIK2QY4WALvlK5MzYQ== + dependencies: + arrify "^2.0.0" + extend "^3.0.2" + +"@google-cloud/projectify@^3.0.0": + version "3.0.0" + resolved "https://registry.yarnpkg.com/@google-cloud/projectify/-/projectify-3.0.0.tgz#302b25f55f674854dce65c2532d98919b118a408" + integrity sha512-HRkZsNmjScY6Li8/kb70wjGlDDyLkVk3KvoEo9uIoxSjYLJasGiCch9+PqRVDOCGUFvEIqyogl+BeqILL4OJHA== + +"@google-cloud/promisify@^3.0.0": + version "3.0.1" + resolved "https://registry.yarnpkg.com/@google-cloud/promisify/-/promisify-3.0.1.tgz#8d724fb280f47d1ff99953aee0c1669b25238c2e" + integrity sha512-z1CjRjtQyBOYL+5Qr9DdYIfrdLBe746jRTYfaYU6MeXkqp7UfYs/jX16lFFVzZ7PGEJvqZNqYUEtb1mvDww4pA== + +"@google-cloud/storage@^6.9.3": + version "6.11.0" + resolved "https://registry.yarnpkg.com/@google-cloud/storage/-/storage-6.11.0.tgz#7217dd06184e609d1c444b7c930d76c6cffeb634" + integrity sha512-p5VX5K2zLTrMXlKdS1CiQNkKpygyn7CBFm5ZvfhVj6+7QUsjWvYx9YDMkYXdarZ6JDt4cxiu451y9QUIH82ZTw== + dependencies: + "@google-cloud/paginator" "^3.0.7" + "@google-cloud/projectify" "^3.0.0" + "@google-cloud/promisify" "^3.0.0" + abort-controller "^3.0.0" + async-retry "^1.3.3" + compressible "^2.0.12" + duplexify "^4.0.0" + ent "^2.2.0" + extend "^3.0.2" + gaxios "^5.0.0" + google-auth-library "^8.0.1" + mime "^3.0.0" + mime-types "^2.0.8" + p-limit "^3.0.1" + retry-request "^5.0.0" + teeny-request "^8.0.0" + uuid "^8.0.0" + +"@humanwhocodes/config-array@^0.11.10": + version "0.11.10" + resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.11.10.tgz#5a3ffe32cc9306365fb3fd572596cd602d5e12d2" + integrity sha512-KVVjQmNUepDVGXNuoRRdmmEjruj0KfiGSbS8LVc12LMsWDQzRXJ0qdhN8L8uUigKpfEHRhlaQFY0ib1tnUbNeQ== dependencies: "@humanwhocodes/object-schema" "^1.2.1" debug "^4.1.1" - minimatch "^3.0.4" + minimatch "^3.0.5" + +"@humanwhocodes/module-importer@^1.0.1": + version "1.0.1" + resolved "https://registry.yarnpkg.com/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz#af5b2691a22b44be847b0ca81641c5fb6ad0172c" + integrity sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA== "@humanwhocodes/object-schema@^1.2.1": version "1.2.1" @@ -545,11 +604,63 @@ resolved "https://registry.yarnpkg.com/@istanbuljs/schema/-/schema-0.1.3.tgz#e45e384e4b8ec16bce2fd903af78450f6bf7ec98" integrity sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA== +"@jridgewell/gen-mapping@^0.3.0", "@jridgewell/gen-mapping@^0.3.2": + version "0.3.3" + resolved "https://registry.yarnpkg.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.3.tgz#7e02e6eb5df901aaedb08514203b096614024098" + integrity sha512-HLhSWOLRi875zjjMG/r+Nv0oCW8umGb0BgEhyX3dDX3egwZtB8PqLnjz3yedt8R5StBrzcg4aBpnh8UA9D1BoQ== + dependencies: + "@jridgewell/set-array" "^1.0.1" + "@jridgewell/sourcemap-codec" "^1.4.10" + "@jridgewell/trace-mapping" "^0.3.9" + +"@jridgewell/resolve-uri@3.1.0": + version "3.1.0" + resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz#2203b118c157721addfe69d47b70465463066d78" + integrity sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w== + +"@jridgewell/set-array@^1.0.1": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@jridgewell/set-array/-/set-array-1.1.2.tgz#7c6cf998d6d20b914c0a55a91ae928ff25965e72" + integrity sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw== + +"@jridgewell/sourcemap-codec@1.4.14": + version "1.4.14" + resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz#add4c98d341472a289190b424efbdb096991bb24" + integrity sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw== + +"@jridgewell/sourcemap-codec@^1.4.10": + version "1.4.15" + resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz#d7c6e6755c78567a951e04ab52ef0fd26de59f32" + integrity sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg== + +"@jridgewell/trace-mapping@^0.3.17", "@jridgewell/trace-mapping@^0.3.9": + version "0.3.18" + resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.18.tgz#25783b2086daf6ff1dcb53c9249ae480e4dd4cd6" + integrity sha512-w+niJYzMHdd7USdiH2U6869nqhD2nbfZXND5Yp93qIbEmnDNk7PD48o+YchRVpzMU7M6jVCbenTR7PA1FLQ9pA== + dependencies: + "@jridgewell/resolve-uri" "3.1.0" + "@jridgewell/sourcemap-codec" "1.4.14" + "@js-joda/core@^2.0.0": version "2.0.0" resolved "https://registry.yarnpkg.com/@js-joda/core/-/core-2.0.0.tgz#e9a351ee6feb91262770e2a3d085aa0219ad6afb" integrity sha512-OWm/xa9O9e4ugzNHoRT3IsXZZYfaV6Ia1aRwctOmCQ2GYWMnhKBzMC1WomqCh/oGxEZKNtPy5xv5//VIAOgMqw== +"@mapbox/node-pre-gyp@^1.0.0": + version "1.0.10" + resolved "https://registry.yarnpkg.com/@mapbox/node-pre-gyp/-/node-pre-gyp-1.0.10.tgz#8e6735ccebbb1581e5a7e652244cadc8a844d03c" + integrity sha512-4ySo4CjzStuprMwk35H5pPbkymjv1SF3jGLj6rAHp/xT/RF7TL7bd9CTm1xDY49K2qF7jmR/g7k+SkLETP6opA== + dependencies: + detect-libc "^2.0.0" + https-proxy-agent "^5.0.0" + make-dir "^3.1.0" + node-fetch "^2.6.7" + nopt "^5.0.0" + npmlog "^5.0.1" + rimraf "^3.0.2" + semver "^7.3.5" + tar "^6.1.11" + "@nodelib/fs.scandir@2.1.5": version "2.1.5" resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5" @@ -563,7 +674,7 @@ resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz#5bd262af94e9d25bd1e71b05deed44876a222e8b" integrity sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A== -"@nodelib/fs.walk@^1.2.3": +"@nodelib/fs.walk@^1.2.3", "@nodelib/fs.walk@^1.2.8": version "1.2.8" resolved "https://registry.yarnpkg.com/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz#e95737e8bb6746ddedf69c556953494f196fe69a" integrity sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg== @@ -615,9 +726,9 @@ integrity sha512-3BGrt6FLjqM6br5AhWRKTr3u5GIVkjRYeAFrMp3HjnfICrg4xOrVRwFavKT6tsp++bq5dluL5t8ME/Nha/6c1Q== "@npmcli/config@^2.3.0": - version "2.3.2" - resolved "https://registry.yarnpkg.com/@npmcli/config/-/config-2.3.2.tgz#6027efc132fcc809abef749c2f2e13dc4dcd6e0b" - integrity sha512-2/9dj143BFgQR8qxJbYptd8k+4+Po2uHYq3H6498ynZcRu4LrsDlngov5HGrvo2+f0pe0fBJwDEP2rRtaW8bkw== + version "2.4.0" + resolved "https://registry.yarnpkg.com/@npmcli/config/-/config-2.4.0.tgz#1447b0274f9502871dabd3ab1d8302472d515b1f" + integrity sha512-fwxu/zaZnvBJohXM3igzqa3P1IVYWi5N343XcKvKkJbAx+rTqegS5tAul4NLiMPQh6WoS5a4er6oo/ieUx1f4g== dependencies: ini "^2.0.0" mkdirp-infer-owner "^2.0.0" @@ -633,9 +744,9 @@ ansi-styles "^4.3.0" "@npmcli/fs@^1.0.0": - version "1.0.0" - resolved "https://registry.yarnpkg.com/@npmcli/fs/-/fs-1.0.0.tgz#589612cfad3a6ea0feafcb901d29c63fd52db09f" - integrity sha512-8ltnOpRR/oJbOp8vaGUnipOi3bqkcW+sLHFlyXIr08OGHmVJLB1Hn7QtGXbYcpVtH1gAYZTlmDXtE4YV0+AMMQ== + version "1.1.1" + resolved "https://registry.yarnpkg.com/@npmcli/fs/-/fs-1.1.1.tgz#72f719fe935e687c56a4faecf3c03d06ba593257" + integrity sha512-8KG5RD0GVP4ydEzRn/I4BNDuxDtqVbOdm8675T49OIG/NGhaK0pjPX7ZcDlvKYbA+ulvVK3ztfcF4uBdOxuJbQ== dependencies: "@gar/promisify" "^1.0.1" semver "^7.3.5" @@ -730,19 +841,37 @@ dependencies: "@octokit/types" "^6.0.3" +"@octokit/auth-token@^3.0.0": + version "3.0.4" + resolved "https://registry.yarnpkg.com/@octokit/auth-token/-/auth-token-3.0.4.tgz#70e941ba742bdd2b49bdb7393e821dea8520a3db" + integrity sha512-TWFX7cZF2LXoCvdmJWY7XVPi74aSY0+FfBZNSXEXFkMpjcqsQwDSYVv5FhRFaI0V1ECnwbz4j59T/G+rXNWaIQ== + "@octokit/core@^3.5.1": - version "3.5.1" - resolved "https://registry.yarnpkg.com/@octokit/core/-/core-3.5.1.tgz#8601ceeb1ec0e1b1b8217b960a413ed8e947809b" - integrity sha512-omncwpLVxMP+GLpLPgeGJBF6IWJFjXDS5flY5VbppePYX9XehevbDykRH9PdCdvqt9TS5AOTiDide7h0qrkHjw== + version "3.6.0" + resolved "https://registry.yarnpkg.com/@octokit/core/-/core-3.6.0.tgz#3376cb9f3008d9b3d110370d90e0a1fcd5fe6085" + integrity sha512-7RKRKuA4xTjMhY+eG3jthb3hlZCsOwg3rztWh75Xc+ShDWOfDDATWbeZpAHBNRpm4Tv9WgBMOy1zEJYXG6NJ7Q== dependencies: "@octokit/auth-token" "^2.4.4" "@octokit/graphql" "^4.5.8" - "@octokit/request" "^5.6.0" + "@octokit/request" "^5.6.3" "@octokit/request-error" "^2.0.5" "@octokit/types" "^6.0.3" before-after-hook "^2.2.0" universal-user-agent "^6.0.0" +"@octokit/core@^4.2.1": + version "4.2.1" + resolved "https://registry.yarnpkg.com/@octokit/core/-/core-4.2.1.tgz#fee6341ad0ce60c29cc455e056cd5b500410a588" + integrity sha512-tEDxFx8E38zF3gT7sSMDrT1tGumDgsw5yPG6BBh/X+5ClIQfMH/Yqocxz1PnHx6CHyF6pxmovUTOfZAUvQ0Lvw== + dependencies: + "@octokit/auth-token" "^3.0.0" + "@octokit/graphql" "^5.0.0" + "@octokit/request" "^6.0.0" + "@octokit/request-error" "^3.0.0" + "@octokit/types" "^9.0.0" + before-after-hook "^2.2.0" + universal-user-agent "^6.0.0" + "@octokit/endpoint@^6.0.1": version "6.0.12" resolved "https://registry.yarnpkg.com/@octokit/endpoint/-/endpoint-6.0.12.tgz#3b4d47a4b0e79b1027fb8d75d4221928b2d05658" @@ -752,6 +881,15 @@ is-plain-object "^5.0.0" universal-user-agent "^6.0.0" +"@octokit/endpoint@^7.0.0": + version "7.0.6" + resolved "https://registry.yarnpkg.com/@octokit/endpoint/-/endpoint-7.0.6.tgz#791f65d3937555141fb6c08f91d618a7d645f1e2" + integrity sha512-5L4fseVRUsDFGR00tMWD/Trdeeihn999rTMGRMC1G/Ldi1uWlWJzI98H4Iak5DB/RVvQuyMYKqSK/R6mbSOQyg== + dependencies: + "@octokit/types" "^9.0.0" + is-plain-object "^5.0.0" + universal-user-agent "^6.0.0" + "@octokit/graphql@^4.5.8": version "4.8.0" resolved "https://registry.yarnpkg.com/@octokit/graphql/-/graphql-4.8.0.tgz#664d9b11c0e12112cbf78e10f49a05959aa22cc3" @@ -761,17 +899,39 @@ "@octokit/types" "^6.0.3" universal-user-agent "^6.0.0" -"@octokit/openapi-types@^11.2.0": - version "11.2.0" - resolved "https://registry.yarnpkg.com/@octokit/openapi-types/-/openapi-types-11.2.0.tgz#b38d7fc3736d52a1e96b230c1ccd4a58a2f400a6" - integrity sha512-PBsVO+15KSlGmiI8QAzaqvsNlZlrDlyAJYcrXBCvVUxCp7VnXjkwPoFHgjEJXx3WF9BAwkA6nfCUA7i9sODzKA== +"@octokit/graphql@^5.0.0": + version "5.0.6" + resolved "https://registry.yarnpkg.com/@octokit/graphql/-/graphql-5.0.6.tgz#9eac411ac4353ccc5d3fca7d76736e6888c5d248" + integrity sha512-Fxyxdy/JH0MnIB5h+UQ3yCoh1FG4kWXfFKkpWqjZHw/p+Kc8Y44Hu/kCgNBT6nU1shNumEchmW/sUO1JuQnPcw== + dependencies: + "@octokit/request" "^6.0.0" + "@octokit/types" "^9.0.0" + universal-user-agent "^6.0.0" + +"@octokit/openapi-types@^12.11.0": + version "12.11.0" + resolved "https://registry.yarnpkg.com/@octokit/openapi-types/-/openapi-types-12.11.0.tgz#da5638d64f2b919bca89ce6602d059f1b52d3ef0" + integrity sha512-VsXyi8peyRq9PqIz/tpqiL2w3w80OgVMwBHltTml3LmVvXiphgeqmY9mvBw9Wu7e0QWk/fqD37ux8yP5uVekyQ== + +"@octokit/openapi-types@^18.0.0": + version "18.0.0" + resolved "https://registry.yarnpkg.com/@octokit/openapi-types/-/openapi-types-18.0.0.tgz#f43d765b3c7533fd6fb88f3f25df079c24fccf69" + integrity sha512-V8GImKs3TeQRxRtXFpG2wl19V7444NIOTDF24AWuIbmNaNYOQMWRbjcGDXV5B+0n887fgDcuMNOmlul+k+oJtw== "@octokit/plugin-paginate-rest@^2.16.8": - version "2.17.0" - resolved "https://registry.yarnpkg.com/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-2.17.0.tgz#32e9c7cab2a374421d3d0de239102287d791bce7" - integrity sha512-tzMbrbnam2Mt4AhuyCHvpRkS0oZ5MvwwcQPYGtMv4tUa5kkzG58SVB0fcsLulOZQeRnOgdkZWkRUiyBlh0Bkyw== + version "2.21.3" + resolved "https://registry.yarnpkg.com/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-2.21.3.tgz#7f12532797775640dbb8224da577da7dc210c87e" + integrity sha512-aCZTEf0y2h3OLbrgKkrfFdjRL6eSOo8komneVQJnYecAxIej7Bafor2xhuDJOIFau4pk0i/P28/XgtbyPF0ZHw== dependencies: - "@octokit/types" "^6.34.0" + "@octokit/types" "^6.40.0" + +"@octokit/plugin-paginate-rest@^6.1.2": + version "6.1.2" + resolved "https://registry.yarnpkg.com/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-6.1.2.tgz#f86456a7a1fe9e58fec6385a85cf1b34072341f8" + integrity sha512-qhrmtQeHU/IivxucOV1bbI/xZyC/iOBhclokv7Sut5vnejAIAEXVcGQeRpQlU39E0WwK9lNvJHphHri/DB6lbQ== + dependencies: + "@octokit/tsconfig" "^1.0.2" + "@octokit/types" "^9.2.3" "@octokit/plugin-request-log@^1.0.4": version "1.0.4" @@ -779,13 +939,29 @@ integrity sha512-mLUsMkgP7K/cnFEw07kWqXGF5LKrOkD+lhCrKvPHXWDywAwuDUeDwWBpc69XK3pNX0uKiVt8g5z96PJ6z9xCFA== "@octokit/plugin-rest-endpoint-methods@^5.12.0": - version "5.13.0" - resolved "https://registry.yarnpkg.com/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-5.13.0.tgz#8c46109021a3412233f6f50d28786f8e552427ba" - integrity sha512-uJjMTkN1KaOIgNtUPMtIXDOjx6dGYysdIFhgA52x4xSadQCz3b/zJexvITDVpANnfKPW/+E0xkOvLntqMYpviA== + version "5.16.2" + resolved "https://registry.yarnpkg.com/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-5.16.2.tgz#7ee8bf586df97dd6868cf68f641354e908c25342" + integrity sha512-8QFz29Fg5jDuTPXVtey05BLm7OB+M8fnvE64RNegzX7U+5NUXcOcnpTIK0YfSHBg8gYd0oxIq3IZTe9SfPZiRw== dependencies: - "@octokit/types" "^6.34.0" + "@octokit/types" "^6.39.0" deprecation "^2.3.1" +"@octokit/plugin-retry@^4.1.3": + version "4.1.6" + resolved "https://registry.yarnpkg.com/@octokit/plugin-retry/-/plugin-retry-4.1.6.tgz#e33b1e520f0bd24d515c9901676b55df64dfc795" + integrity sha512-obkYzIgEC75r8+9Pnfiiqy3y/x1bc3QLE5B7qvv9wi9Kj0R5tGQFC6QMBg1154WQ9lAVypuQDGyp3hNpp15gQQ== + dependencies: + "@octokit/types" "^9.0.0" + bottleneck "^2.15.3" + +"@octokit/plugin-throttling@^5.2.3": + version "5.2.3" + resolved "https://registry.yarnpkg.com/@octokit/plugin-throttling/-/plugin-throttling-5.2.3.tgz#9f552a14dcee5c7326dd9dee64a71ea76b108814" + integrity sha512-C9CFg9mrf6cugneKiaI841iG8DOv6P5XXkjmiNNut+swePxQ7RWEdAZRp5rJoE1hjsIqiYcKa/ZkOQ+ujPI39Q== + dependencies: + "@octokit/types" "^9.0.0" + bottleneck "^2.15.3" + "@octokit/request-error@^2.0.5", "@octokit/request-error@^2.1.0": version "2.1.0" resolved "https://registry.yarnpkg.com/@octokit/request-error/-/request-error-2.1.0.tgz#9e150357831bfc788d13a4fd4b1913d60c74d677" @@ -795,19 +971,40 @@ deprecation "^2.0.0" once "^1.4.0" -"@octokit/request@^5.6.0": - version "5.6.2" - resolved "https://registry.yarnpkg.com/@octokit/request/-/request-5.6.2.tgz#1aa74d5da7b9e04ac60ef232edd9a7438dcf32d8" - integrity sha512-je66CvSEVf0jCpRISxkUcCa0UkxmFs6eGDRSbfJtAVwbLH5ceqF+YEyC8lj8ystKyZTy8adWr0qmkY52EfOeLA== +"@octokit/request-error@^3.0.0": + version "3.0.3" + resolved "https://registry.yarnpkg.com/@octokit/request-error/-/request-error-3.0.3.tgz#ef3dd08b8e964e53e55d471acfe00baa892b9c69" + integrity sha512-crqw3V5Iy2uOU5Np+8M/YexTlT8zxCfI+qu+LxUB7SZpje4Qmx3mub5DfEKSO8Ylyk0aogi6TYdf6kxzh2BguQ== + dependencies: + "@octokit/types" "^9.0.0" + deprecation "^2.0.0" + once "^1.4.0" + +"@octokit/request@^5.6.0", "@octokit/request@^5.6.3": + version "5.6.3" + resolved "https://registry.yarnpkg.com/@octokit/request/-/request-5.6.3.tgz#19a022515a5bba965ac06c9d1334514eb50c48b0" + integrity sha512-bFJl0I1KVc9jYTe9tdGGpAMPy32dLBXXo1dS/YwSCTL/2nd9XeHsY616RE3HPXDVk+a+dBuzyz5YdlXwcDTr2A== dependencies: "@octokit/endpoint" "^6.0.1" "@octokit/request-error" "^2.1.0" "@octokit/types" "^6.16.1" is-plain-object "^5.0.0" - node-fetch "^2.6.1" + node-fetch "^2.6.7" + universal-user-agent "^6.0.0" + +"@octokit/request@^6.0.0": + version "6.2.6" + resolved "https://registry.yarnpkg.com/@octokit/request/-/request-6.2.6.tgz#ff8f503c690f84e3ebd33d2d43e63c0a27ac50e0" + integrity sha512-T/waXf/xjie8Qn5IyFYAcI/HXvw9SPkcQWErGP9H471IWRDRCN+Gn/QOptPMAZRT4lJb2bLHxQfCXjU0mJRyng== + dependencies: + "@octokit/endpoint" "^7.0.0" + "@octokit/request-error" "^3.0.0" + "@octokit/types" "^9.0.0" + is-plain-object "^5.0.0" + node-fetch "^2.6.7" universal-user-agent "^6.0.0" -"@octokit/rest@^18.0.0", "@octokit/rest@^18.12.0": +"@octokit/rest@^18.12.0": version "18.12.0" resolved "https://registry.yarnpkg.com/@octokit/rest/-/rest-18.12.0.tgz#f06bc4952fc87130308d810ca9d00e79f6988881" integrity sha512-gDPiOHlyGavxr72y0guQEhLsemgVjwRePayJ+FcKc2SJqKUbxbkvf5kAZEWA/MKvsfYlQAMVzNJE3ezQcxMJ2Q== @@ -817,17 +1014,29 @@ "@octokit/plugin-request-log" "^1.0.4" "@octokit/plugin-rest-endpoint-methods" "^5.12.0" -"@octokit/types@^6.0.3", "@octokit/types@^6.16.1", "@octokit/types@^6.34.0": - version "6.34.0" - resolved "https://registry.yarnpkg.com/@octokit/types/-/types-6.34.0.tgz#c6021333334d1ecfb5d370a8798162ddf1ae8218" - integrity sha512-s1zLBjWhdEI2zwaoSgyOFoKSl109CUcVBCc7biPJ3aAf6LGLU6szDvi31JPU7bxfla2lqfhjbbg/5DdFNxOwHw== +"@octokit/tsconfig@^1.0.2": + version "1.0.2" + resolved "https://registry.yarnpkg.com/@octokit/tsconfig/-/tsconfig-1.0.2.tgz#59b024d6f3c0ed82f00d08ead5b3750469125af7" + integrity sha512-I0vDR0rdtP8p2lGMzvsJzbhdOWy405HcGovrspJ8RRibHnyRgggUSNO5AIox5LmqiwmatHKYsvj6VGFHkqS7lA== + +"@octokit/types@^6.0.3", "@octokit/types@^6.16.1", "@octokit/types@^6.34.0", "@octokit/types@^6.39.0", "@octokit/types@^6.40.0": + version "6.41.0" + resolved "https://registry.yarnpkg.com/@octokit/types/-/types-6.41.0.tgz#e58ef78d78596d2fb7df9c6259802464b5f84a04" + integrity sha512-eJ2jbzjdijiL3B4PrSQaSjuF2sPEQPVCPzBvTHJD9Nz+9dw2SGH4K4xeQJ77YfTq5bRQ+bD8wT11JbeDPmxmGg== + dependencies: + "@octokit/openapi-types" "^12.11.0" + +"@octokit/types@^9.0.0", "@octokit/types@^9.2.3": + version "9.3.2" + resolved "https://registry.yarnpkg.com/@octokit/types/-/types-9.3.2.tgz#3f5f89903b69f6a2d196d78ec35f888c0013cac5" + integrity sha512-D4iHGTdAnEEVsB8fl95m1hiz7D5YiRdQ9b/OEb3BYRVwbLsGHcRVPz+u+BgRLNk0Q0/4iZCBqDN96j2XNxfXrA== dependencies: - "@octokit/openapi-types" "^11.2.0" + "@octokit/openapi-types" "^18.0.0" "@opentelemetry/api@^1.0.1": - version "1.0.3" - resolved "https://registry.yarnpkg.com/@opentelemetry/api/-/api-1.0.3.tgz#13a12ae9e05c2a782f7b5e84c3cbfda4225eaf80" - integrity sha512-puWxACExDe9nxbBB3lOymQFrLYml2dVOrd7USiVRnSbgXE+KwBu+HxFvxrzfqsiSda9IWsXJG1ef7C1O2/GmKQ== + version "1.4.1" + resolved "https://registry.yarnpkg.com/@opentelemetry/api/-/api-1.4.1.tgz#ff22eb2e5d476fbc2450a196e40dd243cc20c28f" + integrity sha512-O2yRJce1GOc6PAy3QxFM4NzFiWzvScDC1/5ihYBL6BUEVdq0XMWN01sppE+H6bBXbaFYipjwFLEWLg5PaSOThA== "@semantic-release/commit-analyzer@^9.0.2": version "9.0.2" @@ -842,36 +1051,32 @@ lodash "^4.17.4" micromatch "^4.0.2" -"@semantic-release/error@^2.2.0": - version "2.2.0" - resolved "https://registry.yarnpkg.com/@semantic-release/error/-/error-2.2.0.tgz#ee9d5a09c9969eade1ec864776aeda5c5cddbbf0" - integrity sha512-9Tj/qn+y2j+sjCI3Jd+qseGtHjOAeg7dU2/lVcqIQ9TV3QDaDXDYXcoOHU+7o2Hwh8L8ymL4gfuO7KxDs3q2zg== - "@semantic-release/error@^3.0.0": version "3.0.0" resolved "https://registry.yarnpkg.com/@semantic-release/error/-/error-3.0.0.tgz#30a3b97bbb5844d695eb22f9d3aa40f6a92770c2" integrity sha512-5hiM4Un+tpl4cKw3lV4UgzJj+SmfNIDCLLw0TepzQxz9ZGV5ixnqkzIVF+3tp0ZHgcMKE+VNGHJjEeyFG2dcSw== "@semantic-release/github@^8.0.0": - version "8.0.2" - resolved "https://registry.yarnpkg.com/@semantic-release/github/-/github-8.0.2.tgz#80114a41f6ec8ab6c0d38a436b48ff3f2223ab16" - integrity sha512-wIbfhOeuxlYzMTjtSAa2xgr54n7ZuPAS2gadyTWBpUt2PNAPgla7A6XxCXJnaKPgfVF0iFfSk3B+KlVKk6ByVg== + version "8.1.0" + resolved "https://registry.yarnpkg.com/@semantic-release/github/-/github-8.1.0.tgz#c31fc5852d32975648445804d1984cd96e72c4d0" + integrity sha512-erR9E5rpdsz0dW1I7785JtndQuMWN/iDcemcptf67tBNOmBUN0b2YNOgcjYUnBpgRpZ5ozfBHrK7Bz+2ets/Dg== dependencies: - "@octokit/rest" "^18.0.0" - "@semantic-release/error" "^2.2.0" + "@octokit/core" "^4.2.1" + "@octokit/plugin-paginate-rest" "^6.1.2" + "@octokit/plugin-retry" "^4.1.3" + "@octokit/plugin-throttling" "^5.2.3" + "@semantic-release/error" "^3.0.0" aggregate-error "^3.0.0" - bottleneck "^2.18.1" debug "^4.0.0" dir-glob "^3.0.0" - fs-extra "^10.0.0" + fs-extra "^11.0.0" globby "^11.0.0" - http-proxy-agent "^5.0.0" - https-proxy-agent "^5.0.0" + http-proxy-agent "^7.0.0" + https-proxy-agent "^7.0.0" issue-parser "^6.0.0" lodash "^4.17.4" mime "^3.0.0" p-filter "^2.0.0" - p-retry "^4.0.0" url-join "^4.0.0" "@semantic-release/npm@^8.0.0": @@ -910,18 +1115,32 @@ read-pkg-up "^7.0.0" "@sinonjs/commons@^1.6.0", "@sinonjs/commons@^1.7.0", "@sinonjs/commons@^1.8.3": - version "1.8.3" - resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-1.8.3.tgz#3802ddd21a50a949b6721ddd72da36e67e7f1b2d" - integrity sha512-xkNcLAn/wZaX14RPlwizcKicDk9G3F8m2nU3L7Ukm5zBgTwiT0wsoFAHx9Jq56fJA1z/7uKGtCRu16sOUCLIHQ== + version "1.8.6" + resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-1.8.6.tgz#80c516a4dc264c2a69115e7578d62581ff455ed9" + integrity sha512-Ky+XkAkqPZSm3NLBeUng77EBQl3cmeJhITaGHdYH8kjVB+aun3S4XBRti2zt17mtt0mIUDiNxYeoJm6drVvBJQ== dependencies: type-detect "4.0.8" -"@sinonjs/fake-timers@^7.0.4", "@sinonjs/fake-timers@^7.1.0": - version "7.1.2" - resolved "https://registry.yarnpkg.com/@sinonjs/fake-timers/-/fake-timers-7.1.2.tgz#2524eae70c4910edccf99b2f4e6efc5894aff7b5" - integrity sha512-iQADsW4LBMISqZ6Ci1dupJL9pprqwcVFTcOsEmQOEhW+KLCVn/Y4Jrvg2k19fIHCp+iFprriYPTdRcQR8NbUPg== +"@sinonjs/commons@^2.0.0": + version "2.0.0" + resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-2.0.0.tgz#fd4ca5b063554307e8327b4564bd56d3b73924a3" + integrity sha512-uLa0j859mMrg2slwQYdO/AkrOfmH+X6LTVmNTS9CqexuE2IvVORIkSpJLqePAbEnKJ77aMmCwr1NUZ57120Xcg== dependencies: - "@sinonjs/commons" "^1.7.0" + type-detect "4.0.8" + +"@sinonjs/commons@^3.0.0": + version "3.0.0" + resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-3.0.0.tgz#beb434fe875d965265e04722ccfc21df7f755d72" + integrity sha512-jXBtWAF4vmdNmZgD5FoKsVLv3rPgDnLgPbU84LIJ3otV44vJlDRokVng5v8NFJdCf/da9legHcKaRuZs4L7faA== + dependencies: + type-detect "4.0.8" + +"@sinonjs/fake-timers@^10.0.2": + version "10.2.0" + resolved "https://registry.yarnpkg.com/@sinonjs/fake-timers/-/fake-timers-10.2.0.tgz#b3e322a34c5f26e3184e7f6115695f299c1b1194" + integrity sha512-OPwQlEdg40HAj5KNF8WW6q2KG4Z+cBCZb3m4ninfTZKaBmbIJodviQsDBoYMPHkOyJJMHnOJo5j2+LKDOhOACg== + dependencies: + "@sinonjs/commons" "^3.0.0" "@sinonjs/fake-timers@^8.1.0": version "8.1.0" @@ -931,18 +1150,29 @@ "@sinonjs/commons" "^1.7.0" "@sinonjs/samsam@^6.0.2": - version "6.0.2" - resolved "https://registry.yarnpkg.com/@sinonjs/samsam/-/samsam-6.0.2.tgz#a0117d823260f282c04bff5f8704bdc2ac6910bb" - integrity sha512-jxPRPp9n93ci7b8hMfJOFDPRLFYadN6FSpeROFTR4UNF4i5b+EK6m4QXPO46BDhFgRy1JuS87zAnFOzCUwMJcQ== + version "6.1.3" + resolved "https://registry.yarnpkg.com/@sinonjs/samsam/-/samsam-6.1.3.tgz#4e30bcd4700336363302a7d72cbec9b9ab87b104" + integrity sha512-nhOb2dWPeb1sd3IQXL/dVPnKHDOAFfvichtBf4xV00/rU1QbPCQqKMbvIheIjqwVjh7qIgf2AHTHi391yMOMpQ== dependencies: "@sinonjs/commons" "^1.6.0" lodash.get "^4.4.2" type-detect "^4.0.8" "@sinonjs/text-encoding@^0.7.1": - version "0.7.1" - resolved "https://registry.yarnpkg.com/@sinonjs/text-encoding/-/text-encoding-0.7.1.tgz#8da5c6530915653f3a1f38fd5f101d8c3f8079c5" - integrity sha512-+iTbntw2IZPb/anVDbypzfQa+ay64MW0Zo8aJ8gZPWMMK6/OubMVb6lUPMagqjOPnmtauXnFCACVl3O7ogjeqQ== + version "0.7.2" + resolved "https://registry.yarnpkg.com/@sinonjs/text-encoding/-/text-encoding-0.7.2.tgz#5981a8db18b56ba38ef0efb7d995b12aa7b51918" + integrity sha512-sXXKG+uL9IrKqViTtao2Ws6dy0znu9sOaP1di/jKGW1M6VssO8vlpXCQcpZ+jisQ1tTFAC5Jo/EOzFbggBagFQ== + +"@techteamer/ocsp@1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@techteamer/ocsp/-/ocsp-1.0.0.tgz#7b82b02093fbe351e915bb37685ac1ac5a1233d3" + integrity sha512-lNAOoFHaZN+4huo30ukeqVrUmfC+avoEBYQ11QAnAw1PFhnI5oBCg8O/TNiCoEWix7gNGBIEjrQwtPREqKMPog== + dependencies: + asn1.js "^5.4.1" + asn1.js-rfc2560 "^5.0.1" + asn1.js-rfc5280 "^3.0.0" + async "^3.2.1" + simple-lru-cache "^0.0.2" "@tootallnate/once@1": version "1.1.2" @@ -955,26 +1185,31 @@ integrity sha512-XCuKFP5PS55gnMVu3dty8KPatLqUoy/ZYzDzAGCQ8JNFCkLXzmI7vNHCR+XpbZaMWQK/vQubr7PkYq8g470J/A== "@types/chai@^4.3.0": - version "4.3.0" - resolved "https://registry.yarnpkg.com/@types/chai/-/chai-4.3.0.tgz#23509ebc1fa32f1b4d50d6a66c4032d5b8eaabdc" - integrity sha512-/ceqdqeRraGolFTcfoXNiqjyQhZzbINDngeoAq9GoHa8PPK1yNzTaxWjA6BFWp5Ua9JpXEMSS4s5i9tS0hOJtw== + version "4.3.5" + resolved "https://registry.yarnpkg.com/@types/chai/-/chai-4.3.5.tgz#ae69bcbb1bebb68c4ac0b11e9d8ed04526b3562b" + integrity sha512-mEo1sAde+UCE6b2hxn332f1g1E8WfYRu6p5SvTKr2ZKC1f7gFJXk4h5PyGP9Dt6gCaG8y8XhwnXWC6Iy2cmBng== -"@types/debug@^4.1.7": - version "4.1.7" - resolved "https://registry.yarnpkg.com/@types/debug/-/debug-4.1.7.tgz#7cc0ea761509124709b8b2d1090d8f6c17aadb82" - integrity sha512-9AonUzyTjXXhEOa0DnqpzZi6VHlqKMswga9EXjpXnnqxwLtdvPPtlO8evrI5D9S6asFRCQ6v+wpiUKbw+vKqyg== +"@types/debug@^4.1.8": + version "4.1.8" + resolved "https://registry.yarnpkg.com/@types/debug/-/debug-4.1.8.tgz#cef723a5d0a90990313faec2d1e22aee5eecb317" + integrity sha512-/vPO1EPOs306Cvhwv7KfVfYvOJqA/S/AXjaHQiJboCZzcNDb+TIJFN9/2C9DZ//ijSKWioNyUxD792QmDJ+HKQ== dependencies: "@types/ms" "*" -"@types/geojson@^7946.0.7": - version "7946.0.8" - resolved "https://registry.yarnpkg.com/@types/geojson/-/geojson-7946.0.8.tgz#30744afdb385e2945e22f3b033f897f76b1f12ca" - integrity sha512-1rkryxURpr6aWP7R786/UQOkJ3PcpQiWkAXBmdWc7ryFWqN6a4xfK7BtjXvFBKO9LjQ+MWQSWxYeZX1OApnArA== +"@types/geojson@^7946.0.8": + version "7946.0.10" + resolved "https://registry.yarnpkg.com/@types/geojson/-/geojson-7946.0.10.tgz#6dfbf5ea17142f7f9a043809f1cd4c448cb68249" + integrity sha512-Nmh0K3iWQJzniTuPRcJn5hxXkfB1T1pgB89SBig5PlJQU5yocazeu4jATJlaA0GYFKWMqDdvYemoSnF2pXgLVA== "@types/json-schema@^7.0.9": - version "7.0.9" - resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.9.tgz#97edc9037ea0c38585320b28964dde3b39e4660d" - integrity sha512-qcUXuemtEu+E5wZSJHNxUXeCZhAfXKQ41D+duX+VYPde7xyEVZci+/oXKJL13tnRs9lR2pr4fod59GT6/X1/yQ== + version "7.0.12" + resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.12.tgz#d70faba7039d5fca54c83c7dbab41051d2b6f6cb" + integrity sha512-Hr5Jfhc9eYOQNPYO5WLDq/n4jqijdHNlDXjuAQkkt+mWdQR+XJToOHrsD4cPaMXpn6KO7y2+wM8AZEs8VpBLVA== + +"@types/lodash@4.14.197": + version "4.14.197" + resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.197.tgz#e95c5ddcc814ec3e84c891910a01e0c8a378c54b" + integrity sha512-BMVOiWs0uNxHVlHBgzTIqJYmj+PgCo4euloGF+5m4okL3rEYzM2EEv78mw8zWSMM57dM7kVIgJ2QDvwHSoCI5g== "@types/minimist@^1.2.0": version "1.2.2" @@ -982,9 +1217,9 @@ integrity sha512-jhuKLIRrhvCPLqwPcx6INqmKeiA5EWrsCOPhrlFSrbrmU4ZMPjj5Ul/oLCMDO98XRUIwVm78xICz4EPCektzeQ== "@types/mocha@^9.0.0": - version "9.0.0" - resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-9.0.0.tgz#3205bcd15ada9bc681ac20bef64e9e6df88fd297" - integrity sha512-scN0hAWyLVAvLR9AyW7HoFF5sJZglyBsbPuHO4fv7JRvfmPBMfp1ozWqOf/e4wwPNxezBZXRfWzMb6iFLgEVRA== + version "9.1.1" + resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-9.1.1.tgz#e7c4f1001eefa4b8afbd1eee27a237fee3bf29c4" + integrity sha512-Z61JK7DKDtdKTWwLeElSEBcWGRLY8g95ic5FoQqI9CMx0ns/Ghep3B4DfcEimiKMvtamNVULVNKEsiwV3aQmXw== "@types/ms@*": version "0.7.31" @@ -992,27 +1227,27 @@ integrity sha512-iiUgKzV9AuaEkZqkOLDIvlQiL6ltuZd9tGcW3gwpnX8JbuiuhFlEGmmFXEXkN50Cvq7Os88IY2v0dkDqXYWVgA== "@types/node-fetch@^2.5.0": - version "2.5.12" - resolved "https://registry.yarnpkg.com/@types/node-fetch/-/node-fetch-2.5.12.tgz#8a6f779b1d4e60b7a57fb6fd48d84fb545b9cc66" - integrity sha512-MKgC4dlq4kKNa/mYrwpKfzQMB5X3ee5U6fSprkKpToBqBmX4nFZL9cW5jl6sWn+xpRJ7ypWh2yyqqr8UUCstSw== + version "2.6.4" + resolved "https://registry.yarnpkg.com/@types/node-fetch/-/node-fetch-2.6.4.tgz#1bc3a26de814f6bf466b25aeb1473fa1afe6a660" + integrity sha512-1ZX9fcN4Rvkvgv4E6PAY5WXUFWFcRWxZa3EW83UjycOB9ljJCedb2CupIP4RZMEwF/M3eTcCihbBRgwtGbg5Rg== dependencies: "@types/node" "*" form-data "^3.0.0" "@types/node@*": - version "16.11.11" - resolved "https://registry.yarnpkg.com/@types/node/-/node-16.11.11.tgz#6ea7342dfb379ea1210835bada87b3c512120234" - integrity sha512-KB0sixD67CeecHC33MYn+eYARkqTheIRNuu97y2XMjR7Wu3XibO1vaY6VBV6O/a89SPI81cEUIYT87UqUWlZNw== - -"@types/node@^14.14.28": - version "14.17.34" - resolved "https://registry.yarnpkg.com/@types/node/-/node-14.17.34.tgz#fe4b38b3f07617c0fa31ae923fca9249641038f0" - integrity sha512-USUftMYpmuMzeWobskoPfzDi+vkpe0dvcOBRNOscFrGxVp4jomnRxWuVohgqBow2xyIPC0S3gjxV/5079jhmDg== + version "20.3.1" + resolved "https://registry.yarnpkg.com/@types/node/-/node-20.3.1.tgz#e8a83f1aa8b649377bb1fb5d7bac5cb90e784dfe" + integrity sha512-EhcH/wvidPy1WeML3TtYFGR83UzjxeWRen9V402T8aUGYsCHOmfoisV3ZSg03gAFIbLq8TnWOJ0f4cALtnSEUg== "@types/node@^16.11.17": - version "16.11.17" - resolved "https://registry.yarnpkg.com/@types/node/-/node-16.11.17.tgz#ae146499772e33fc6382e1880bc567e41a528586" - integrity sha512-C1vTZME8cFo8uxY2ui41xcynEotVkczIVI5AjLmy5pkpBv/FtG+jhtOlfcPysI8VRVwoOMv6NJm44LGnoMSWkw== + version "16.18.36" + resolved "https://registry.yarnpkg.com/@types/node/-/node-16.18.36.tgz#0db5d7efc4760d36d0d1d22c85d1a53accd5dc27" + integrity sha512-8egDX8dE50XyXWH6C6PRCNkTP106DuUrvdrednFouDSmCi7IOvrqr0frznfZaHifHH/3aq/7a7v9N4wdXMqhBQ== + +"@types/node@^17.0.10": + version "17.0.45" + resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.45.tgz#2c0fafd78705e7a18b7906b5201a522719dc5190" + integrity sha512-w+tIMs3rq2afQdsPJlODhoUEKzFP1ayaoyl1CcnwtIlsVe7K7bA1NGm4s3PraqTLlXnbIN84zuBlxBWo1u9BLw== "@types/node@^8.0.47": version "8.10.66" @@ -1029,17 +1264,27 @@ resolved "https://registry.yarnpkg.com/@types/parse-json/-/parse-json-4.0.0.tgz#2f8bb441434d163b35fb8ffdccd7138927ffb8c0" integrity sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA== -"@types/retry@^0.12.0": - version "0.12.1" - resolved "https://registry.yarnpkg.com/@types/retry/-/retry-0.12.1.tgz#d8f1c0d0dc23afad6dc16a9e993a0865774b4065" - integrity sha512-xoDlM2S4ortawSWORYqsdU+2rxdh4LRW9ytc3zmT37RIKQh6IHyKwwtKhKis9ah8ol07DCkZxPt8BBvPjC6v4g== +"@types/semver@^7.3.12": + version "7.5.0" + resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.5.0.tgz#591c1ce3a702c45ee15f47a42ade72c2fd78978a" + integrity sha512-G8hZ6XJiHnuhQKR7ZmysCeJWE08o8T0AXtk5darsCaTVsYZhhgUrq53jizaR2FvsoeCwJhlmwTjkXBY5Pn/ZHw== "@types/sinon@^10.0.6": - version "10.0.6" - resolved "https://registry.yarnpkg.com/@types/sinon/-/sinon-10.0.6.tgz#bc3faff5154e6ecb69b797d311b7cf0c1b523a1d" - integrity sha512-6EF+wzMWvBNeGrfP3Nx60hhx+FfwSg1JJBLAAP/IdIUq0EYkqCYf70VT3PhuhPX9eLD+Dp+lNdpb/ZeHG8Yezg== + version "10.0.15" + resolved "https://registry.yarnpkg.com/@types/sinon/-/sinon-10.0.15.tgz#513fded9c3cf85e589bbfefbf02b2a0541186b48" + integrity sha512-3lrFNQG0Kr2LDzvjyjB6AMJk4ge+8iYhQfdnSwIwlG88FUOV43kPcQqDZkDa/h3WSZy6i8Fr0BSjfQtB1B3xuQ== dependencies: - "@sinonjs/fake-timers" "^7.1.0" + "@types/sinonjs__fake-timers" "*" + +"@types/sinonjs__fake-timers@*": + version "8.1.2" + resolved "https://registry.yarnpkg.com/@types/sinonjs__fake-timers/-/sinonjs__fake-timers-8.1.2.tgz#bf2e02a3dbd4aecaf95942ecd99b7402e03fad5e" + integrity sha512-9GcLXF0/v3t80caGs5p2rRfkB+a8VBGLJZVih6CNFkx8IZ994wiKKLSRs9nuFwk1HevWs/1mnUmkApGrSGsShA== + +"@types/triple-beam@^1.3.2": + version "1.3.2" + resolved "https://registry.yarnpkg.com/@types/triple-beam/-/triple-beam-1.3.2.tgz#38ecb64f01aa0d02b7c8f4222d7c38af6316fef8" + integrity sha512-txGIh+0eDFzKGC25zORnswy+br1Ha7hj5cMVwKIU7+s0U2AxxJru/jZSMU6OC9MJWP6+pc/hc6ZjyZShpsyY2g== "@types/tunnel@^0.0.3": version "0.0.3" @@ -1048,80 +1293,94 @@ dependencies: "@types/node" "*" -"@types/validator@^13.7.1": - version "13.7.1" - resolved "https://registry.yarnpkg.com/@types/validator/-/validator-13.7.1.tgz#cdab1b4779f6b1718a08de89d92d2603b71950cb" - integrity sha512-I6OUIZ5cYRk5lp14xSOAiXjWrfVoMZVjDuevBYgQDYzZIjsf2CAISpEcXOkFAtpAHbmWIDLcZObejqny/9xq5Q== +"@types/validator@^13.7.17": + version "13.7.17" + resolved "https://registry.yarnpkg.com/@types/validator/-/validator-13.7.17.tgz#0a6d1510395065171e3378a4afc587a3aefa7cc1" + integrity sha512-aqayTNmeWrZcvnG2MG9eGYI6b7S5fl+yKgPs6bAjOTwPS316R5SxBGKvtSExfyoJU7pIeHJfsHI0Ji41RVMkvQ== "@typescript-eslint/eslint-plugin@^5.8.1": - version "5.8.1" - resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.8.1.tgz#97dfaa39f38e99f86801fdf34f9f1bed66704258" - integrity sha512-wTZ5oEKrKj/8/366qTM366zqhIKAp6NCMweoRONtfuC07OAU9nVI2GZZdqQ1qD30WAAtcPdkH+npDwtRFdp4Rw== - dependencies: - "@typescript-eslint/experimental-utils" "5.8.1" - "@typescript-eslint/scope-manager" "5.8.1" - debug "^4.3.2" - functional-red-black-tree "^1.0.1" - ignore "^5.1.8" - regexpp "^3.2.0" - semver "^7.3.5" + version "5.59.11" + resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.59.11.tgz#8d466aa21abea4c3f37129997b198d141f09e76f" + integrity sha512-XxuOfTkCUiOSyBWIvHlUraLw/JT/6Io1365RO6ZuI88STKMavJZPNMU0lFcUTeQXEhHiv64CbxYxBNoDVSmghg== + dependencies: + "@eslint-community/regexpp" "^4.4.0" + "@typescript-eslint/scope-manager" "5.59.11" + "@typescript-eslint/type-utils" "5.59.11" + "@typescript-eslint/utils" "5.59.11" + debug "^4.3.4" + grapheme-splitter "^1.0.4" + ignore "^5.2.0" + natural-compare-lite "^1.4.0" + semver "^7.3.7" tsutils "^3.21.0" -"@typescript-eslint/experimental-utils@5.8.1": - version "5.8.1" - resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-5.8.1.tgz#01861eb2f0749f07d02db342b794145a66ed346f" - integrity sha512-fbodVnjIDU4JpeXWRDsG5IfIjYBxEvs8EBO8W1+YVdtrc2B9ppfof5sZhVEDOtgTfFHnYQJDI8+qdqLYO4ceww== - dependencies: - "@types/json-schema" "^7.0.9" - "@typescript-eslint/scope-manager" "5.8.1" - "@typescript-eslint/types" "5.8.1" - "@typescript-eslint/typescript-estree" "5.8.1" - eslint-scope "^5.1.1" - eslint-utils "^3.0.0" - "@typescript-eslint/parser@^5.8.1": - version "5.8.1" - resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-5.8.1.tgz#380f5f1e596b540059998aa3fc80d78f0f9b0d0a" - integrity sha512-K1giKHAjHuyB421SoXMXFHHVI4NdNY603uKw92++D3qyxSeYvC10CBJ/GE5Thpo4WTUvu1mmJI2/FFkz38F2Gw== - dependencies: - "@typescript-eslint/scope-manager" "5.8.1" - "@typescript-eslint/types" "5.8.1" - "@typescript-eslint/typescript-estree" "5.8.1" - debug "^4.3.2" - -"@typescript-eslint/scope-manager@5.8.1": - version "5.8.1" - resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.8.1.tgz#7fc0604f7ade8833e4d42cebaa1e2debf8b932e4" - integrity sha512-DGxJkNyYruFH3NIZc3PwrzwOQAg7vvgsHsHCILOLvUpupgkwDZdNq/cXU3BjF4LNrCsVg0qxEyWasys5AiJ85Q== - dependencies: - "@typescript-eslint/types" "5.8.1" - "@typescript-eslint/visitor-keys" "5.8.1" + version "5.59.11" + resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-5.59.11.tgz#af7d4b7110e3068ce0b97550736de455e4250103" + integrity sha512-s9ZF3M+Nym6CAZEkJJeO2TFHHDsKAM3ecNkLuH4i4s8/RCPnF5JRip2GyviYkeEAcwGMJxkqG9h2dAsnA1nZpA== + dependencies: + "@typescript-eslint/scope-manager" "5.59.11" + "@typescript-eslint/types" "5.59.11" + "@typescript-eslint/typescript-estree" "5.59.11" + debug "^4.3.4" + +"@typescript-eslint/scope-manager@5.59.11": + version "5.59.11" + resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.59.11.tgz#5d131a67a19189c42598af9fb2ea1165252001ce" + integrity sha512-dHFOsxoLFtrIcSj5h0QoBT/89hxQONwmn3FOQ0GOQcLOOXm+MIrS8zEAhs4tWl5MraxCY3ZJpaXQQdFMc2Tu+Q== + dependencies: + "@typescript-eslint/types" "5.59.11" + "@typescript-eslint/visitor-keys" "5.59.11" + +"@typescript-eslint/type-utils@5.59.11": + version "5.59.11" + resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-5.59.11.tgz#5eb67121808a84cb57d65a15f48f5bdda25f2346" + integrity sha512-LZqVY8hMiVRF2a7/swmkStMYSoXMFlzL6sXV6U/2gL5cwnLWQgLEG8tjWPpaE4rMIdZ6VKWwcffPlo1jPfk43g== + dependencies: + "@typescript-eslint/typescript-estree" "5.59.11" + "@typescript-eslint/utils" "5.59.11" + debug "^4.3.4" + tsutils "^3.21.0" -"@typescript-eslint/types@5.8.1": - version "5.8.1" - resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.8.1.tgz#04c6b49ebc8c99238238a6b8b43f2fc613983b5a" - integrity sha512-L/FlWCCgnjKOLefdok90/pqInkomLnAcF9UAzNr+DSqMC3IffzumHTQTrINXhP1gVp9zlHiYYjvozVZDPleLcA== +"@typescript-eslint/types@5.59.11": + version "5.59.11" + resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.59.11.tgz#1a9018fe3c565ba6969561f2a49f330cf1fe8db1" + integrity sha512-epoN6R6tkvBYSc+cllrz+c2sOFWkbisJZWkOE+y3xHtvYaOE6Wk6B8e114McRJwFRjGvYdJwLXQH5c9osME/AA== -"@typescript-eslint/typescript-estree@5.8.1": - version "5.8.1" - resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.8.1.tgz#a592855be688e7b729a1e9411d7d74ec992ed6ef" - integrity sha512-26lQ8l8tTbG7ri7xEcCFT9ijU5Fk+sx/KRRyyzCv7MQ+rZZlqiDPtMKWLC8P7o+dtCnby4c+OlxuX1tp8WfafQ== +"@typescript-eslint/typescript-estree@5.59.11": + version "5.59.11" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.59.11.tgz#b2caaa31725e17c33970c1197bcd54e3c5f42b9f" + integrity sha512-YupOpot5hJO0maupJXixi6l5ETdrITxeo5eBOeuV7RSKgYdU3G5cxO49/9WRnJq9EMrB7AuTSLH/bqOsXi7wPA== dependencies: - "@typescript-eslint/types" "5.8.1" - "@typescript-eslint/visitor-keys" "5.8.1" - debug "^4.3.2" - globby "^11.0.4" + "@typescript-eslint/types" "5.59.11" + "@typescript-eslint/visitor-keys" "5.59.11" + debug "^4.3.4" + globby "^11.1.0" is-glob "^4.0.3" - semver "^7.3.5" + semver "^7.3.7" tsutils "^3.21.0" -"@typescript-eslint/visitor-keys@5.8.1": - version "5.8.1" - resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.8.1.tgz#58a2c566265d5511224bc316149890451c1bbab0" - integrity sha512-SWgiWIwocK6NralrJarPZlWdr0hZnj5GXHIgfdm8hNkyKvpeQuFyLP6YjSIe9kf3YBIfU6OHSZLYkQ+smZwtNg== +"@typescript-eslint/utils@5.59.11": + version "5.59.11" + resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.59.11.tgz#9dbff49dc80bfdd9289f9f33548f2e8db3c59ba1" + integrity sha512-didu2rHSOMUdJThLk4aZ1Or8IcO3HzCw/ZvEjTTIfjIrcdd5cvSIwwDy2AOlE7htSNp7QIZ10fLMyRCveesMLg== + dependencies: + "@eslint-community/eslint-utils" "^4.2.0" + "@types/json-schema" "^7.0.9" + "@types/semver" "^7.3.12" + "@typescript-eslint/scope-manager" "5.59.11" + "@typescript-eslint/types" "5.59.11" + "@typescript-eslint/typescript-estree" "5.59.11" + eslint-scope "^5.1.1" + semver "^7.3.7" + +"@typescript-eslint/visitor-keys@5.59.11": + version "5.59.11" + resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.59.11.tgz#dca561ddad169dc27d62396d64f45b2d2c3ecc56" + integrity sha512-KGYniTGG3AMTuKF9QBD7EIrvufkB6O6uX3knP73xbKLMpH+QRPcgnCxjWXSHjMRuOxFLovljqQgQpR0c7GvjoA== dependencies: - "@typescript-eslint/types" "5.8.1" - eslint-visitor-keys "^3.0.0" + "@typescript-eslint/types" "5.59.11" + eslint-visitor-keys "^3.3.0" JSONStream@^1.0.4: version "1.3.5" @@ -1134,44 +1393,51 @@ JSONStream@^1.0.4: abab@^1.0.0: version "1.0.4" resolved "https://registry.yarnpkg.com/abab/-/abab-1.0.4.tgz#5faad9c2c07f60dd76770f71cf025b62a63cfd4e" - integrity sha1-X6rZwsB/YN12dw9xzwJbYqY8/U4= + integrity sha512-I+Wi+qiE2kUXyrRhNsWv6XsjUTBJjSoVSctKNBfLG5zG/Xe7Rjbxf13+vqYHNTwHaFU+FtSlVxOCTiMEVtPv0A== abbrev@1, abbrev@~1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.1.tgz#f8f2c887ad10bf67f634f005b6987fed3179aac8" integrity sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q== +abort-controller@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/abort-controller/-/abort-controller-3.0.0.tgz#eaf54d53b62bae4138e809ca225c8439a6efb392" + integrity sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg== + dependencies: + event-target-shim "^5.0.0" + acorn-globals@^1.0.4: version "1.0.9" resolved "https://registry.yarnpkg.com/acorn-globals/-/acorn-globals-1.0.9.tgz#55bb5e98691507b74579d0513413217c380c54cf" - integrity sha1-VbtemGkVB7dFedBRNBMhfDgMVM8= + integrity sha512-j3/4pkfih8W4NK22gxVSXcEonTpAHOHh0hu5BoZrKcOsW/4oBPxTi4Yk3SAj+FhC1f3+bRTkXdm4019gw1vg9g== dependencies: acorn "^2.1.0" -acorn-jsx@^5.3.1: +acorn-jsx@^5.3.2: version "5.3.2" resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.3.2.tgz#7ed5bb55908b3b2f1bc55c6af1653bada7f07937" integrity sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ== +acorn-walk@^8.2.0: + version "8.2.0" + resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.2.0.tgz#741210f2e2426454508853a2f44d0ab83b7f69c1" + integrity sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA== + acorn@^2.1.0, acorn@^2.4.0: version "2.7.0" resolved "https://registry.yarnpkg.com/acorn/-/acorn-2.7.0.tgz#ab6e7d9d886aaca8b085bc3312b79a198433f0e7" - integrity sha1-q259nYhqrKiwhbwzEreaGYQz8Oc= + integrity sha512-pXK8ez/pVjqFdAgBkF1YPVRacuLQ9EXBKaKWaeh58WNfMkCmZhOZzu+NtKSPD5PHmCCHheQ5cD29qM1K4QTxIg== -acorn@^8.6.0: - version "8.6.0" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.6.0.tgz#e3692ba0eb1a0c83eaa4f37f5fa7368dd7142895" - integrity sha512-U1riIR+lBSNi3IbxtaHOIKdH8sLFv3NYfNv8sg7ZsNhcfl4HF2++BfqqrNAxoCLQW1iiylOj76ecnaUxz+z9yw== - -acorn@^8.7.0: - version "8.7.0" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.7.0.tgz#90951fde0f8f09df93549481e5fc141445b791cf" - integrity sha512-V/LGr1APy+PXIwKebEWrkZPwoeoF+w1jiOBUmuxuiUIaOHtob8Qc9BTrYo7VuI5fR8tqsy+buA2WFooR5olqvQ== +acorn@^8.7.0, acorn@^8.8.0: + version "8.9.0" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.9.0.tgz#78a16e3b2bcc198c10822786fa6679e245db5b59" + integrity sha512-jaVNAFBHNLXspO543WnNNPZFRtavh3skAkITqD0/2aeMkKZTN+254PyhwxFYrk3vQ1xfY+2wbesJMs/JC8/PwQ== adal-node@^0.1.28: version "0.1.28" resolved "https://registry.yarnpkg.com/adal-node/-/adal-node-0.1.28.tgz#468c4bb3ebbd96b1270669f4b9cba4e0065ea485" - integrity sha1-RoxLs+u9lrEnBmn0ucuk4AZepIU= + integrity sha512-98nQ5MQSyJR0ZY/R0Mue/cv4OkebRyKz4hS40GdkZU42Bq49ldHeup7UeAo/0vROMB57CX2et6IF0U/Pe1rY3A== dependencies: "@types/node" "^8.0.47" async ">=0.6.0" @@ -1183,27 +1449,27 @@ adal-node@^0.1.28: xmldom ">= 0.1.x" xpath.js "~1.1.0" -agent-base@6, agent-base@^6.0.2: +agent-base@6, agent-base@^6.0.0, agent-base@^6.0.2: version "6.0.2" resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-6.0.2.tgz#49fff58577cfee3f37176feab4c22e00f86d7f77" integrity sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ== dependencies: debug "4" -agent-base@^4.3.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-4.3.0.tgz#8165f01c436009bccad0b1d122f05ed770efc6ee" - integrity sha512-salcGninV0nPrwpGNn4VTXBb1SOuXQBiqbrNXoeizJsHrsL6ERFM2Ne3JUSBWRE6aeNJI2ROP/WEEIDUiDe3cg== +agent-base@^7.0.2, agent-base@^7.1.0: + version "7.1.0" + resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-7.1.0.tgz#536802b76bc0b34aa50195eb2442276d613e3434" + integrity sha512-o/zjMZRhJxny7OyEF+Op8X+efiELC7k7yOjMzgfzVqOzXqkBkWI79YoTdOtsuWd5BWhAGAuOY/Xa6xpiaWXiNg== dependencies: - es6-promisify "^5.0.0" + debug "^4.3.4" agentkeepalive@^4.1.3: - version "4.1.4" - resolved "https://registry.yarnpkg.com/agentkeepalive/-/agentkeepalive-4.1.4.tgz#d928028a4862cb11718e55227872e842a44c945b" - integrity sha512-+V/rGa3EuU74H6wR04plBb7Ks10FbtUQgRj/FQOG7uUIEuaINI+AiqJR1k6t3SVNs7o7ZjIdus6706qqzVq8jQ== + version "4.3.0" + resolved "https://registry.yarnpkg.com/agentkeepalive/-/agentkeepalive-4.3.0.tgz#bb999ff07412653c1803b3ced35e50729830a255" + integrity sha512-7Epl1Blf4Sy37j4v9f9FjICCh4+KAQOyXgHEwlyBiAQLbhKdq/i2QQU3amQalS/wPhdPzDXPL5DMR5bkn+YeWg== dependencies: debug "^4.1.0" - depd "^1.1.2" + depd "^2.0.0" humanize-ms "^1.2.1" aggregate-error@^3.0.0: @@ -1229,11 +1495,6 @@ ansi-colors@3.2.3: resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-3.2.3.tgz#57d35b8686e851e2cc04c403f1c00203976a1813" integrity sha512-LEHHyuhlPY3TmuUYMh2oz89lTShfvgbmzaBcxve9t/9Wuy7Dwf4yoAKcND7KFT1HAQfqZ12qtc+DUrBMeKF9nw== -ansi-colors@^4.1.1: - version "4.1.1" - resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-4.1.1.tgz#cbb9ae256bf750af1eab344f229aa27fe94ba348" - integrity sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA== - ansi-escapes@^4.3.0, ansi-escapes@^4.3.1: version "4.3.2" resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-4.3.2.tgz#6b2291d1db7d98b6521d5f1efa42d0f3a9feb65e" @@ -1244,17 +1505,17 @@ ansi-escapes@^4.3.0, ansi-escapes@^4.3.1: ansi-regex@^2.0.0: version "2.1.1" resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df" - integrity sha1-w7M6te42DYbg5ijwRorn7yfWVN8= + integrity sha512-TIGnTpdo+E3+pCyAluZvtED5p5wCqLdezCyhPZzKPcxvFplEt4i+W7OONCKgeZFT3+y5NZZfOOS/Bdcanm1MYA== ansi-regex@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-3.0.0.tgz#ed0317c322064f79466c02966bddb605ab37d998" - integrity sha1-7QMXwyIGT3lGbAKWa922Bas32Zg= + version "3.0.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-3.0.1.tgz#123d6479e92ad45ad897d4054e3c7ca7db4944e1" + integrity sha512-+O9Jct8wf++lXxxFc4hc8LsjaSq0HFzzL7cVsw8pRDIPdjKD2mT4ytDZlLuSBZ4cLKZFXIrMGO7DbQCtMJJMKw== ansi-regex@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-4.1.0.tgz#8b9f8f08cf1acb843756a839ca8c7e3168c51997" - integrity sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg== + version "4.1.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-4.1.1.tgz#164daac87ab2d6f6db3a29875e2d1766582dabed" + integrity sha512-ILlv4k/3f6vfQ4OoP2AGvirOktlQ98ZEL1k9FaQjxa3L1abBgbuTDAdPOpvbGncC0BTVQrl+OM8xZGK6tWXt7g== ansi-regex@^5.0.1: version "5.0.1" @@ -1269,7 +1530,7 @@ ansi-regex@^6.0.1: ansi-styles@^2.2.1: version "2.2.1" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe" - integrity sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4= + integrity sha512-kmCevFghRiWM7HB5zTPULl4r9bVFSWjz62MhqizDGUrq2NWuNMQyuv4tHHoKJHs69M/MF64lEcHdYIocrdWQYA== ansi-styles@^3.2.0, ansi-styles@^3.2.1: version "3.2.1" @@ -1286,24 +1547,29 @@ ansi-styles@^4.0.0, ansi-styles@^4.1.0, ansi-styles@^4.3.0: color-convert "^2.0.1" ansi-styles@^6.0.0: - version "6.1.0" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-6.1.0.tgz#87313c102b8118abd57371afab34618bf7350ed3" - integrity sha512-VbqNsoz55SYGczauuup0MFUyXNQviSpFTj1RQtFzmQLk18qbVSpTFFGMT293rmDaQuKCT6InmbuEyUne4mTuxQ== + version "6.2.1" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-6.2.1.tgz#0e62320cf99c21afff3b3012192546aacbfb05c5" + integrity sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug== ansicolors@~0.3.2: version "0.3.2" resolved "https://registry.yarnpkg.com/ansicolors/-/ansicolors-0.3.2.tgz#665597de86a9ffe3aa9bfbe6cae5c6ea426b4979" - integrity sha1-ZlWX3oap/+Oqm/vmyuXG6kJrSXk= + integrity sha512-QXu7BPrP29VllRxH8GwB7x5iX5qWKAAMLqKQGWTeLWVlNHNOpVMJ91dsxQAIWXpjuW5wqvxu3Jd/nRjrJ+0pqg== ansistyles@~0.1.3: version "0.1.3" resolved "https://registry.yarnpkg.com/ansistyles/-/ansistyles-0.1.3.tgz#5de60415bda071bb37127854c864f41b23254539" - integrity sha1-XeYEFb2gcbs3EnhUyGT0GyMlRTk= + integrity sha512-6QWEyvMgIXX0eO972y7YPBLSBsq7UWKFAoNNTLGaOJ9bstcEL9sCbcjf96dVfNDdUsRoGOK82vWFJlKApXds7g== + +any-promise@^1.0.0, any-promise@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/any-promise/-/any-promise-1.3.0.tgz#abc6afeedcea52e809cdc0376aed3ce39635d17f" + integrity sha512-7UvmKalWRt1wgjL1RrGxoSJW/0QZFIegpeGvZG9kjp8vrRu55XTHbwnqq2GpXm9uLbcuhxm3IqX9OB4MZR1b2A== anymatch@~3.1.1: - version "3.1.2" - resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.2.tgz#c0557c096af32f106198f4f4e2a383537e378716" - integrity sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg== + version "3.1.3" + resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.3.tgz#790c58b19ba1720a84205b57c618d5ad8524973e" + integrity sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw== dependencies: normalize-path "^3.0.0" picomatch "^2.0.4" @@ -1311,7 +1577,7 @@ anymatch@~3.1.1: append-buffer@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/append-buffer/-/append-buffer-1.0.2.tgz#d8220cf466081525efea50614f3de6514dfa58f1" - integrity sha1-2CIM9GYIFSXv6lBhTz3mUU36WPE= + integrity sha512-WLbYiXzD3y/ATLZFufV/rZvWdZOs+Z/+5v1rBZ463Jn398pa6kcde27cvozYnBoxXblGZTFfoPpsaEw0orU5BA== dependencies: buffer-equal "^1.0.0" @@ -1335,7 +1601,7 @@ aproba@^1.0.3: archy@^1.0.0, archy@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/archy/-/archy-1.0.0.tgz#f9c8c13757cc1dd7bc379ac77b2c62a5c2868c40" - integrity sha1-+cjBN1fMHde8N5rHeyxipcKGjEA= + integrity sha512-Xg+9RwCg/0p32teKdGMPTPnVXKD0w3DfHnFTficozsAgsvq2XenPJq/MYpzzQ/v8zrOyJn6Ds39VA4JIDwFfqw== are-we-there-yet@^2.0.0: version "2.0.0" @@ -1345,6 +1611,14 @@ are-we-there-yet@^2.0.0: delegates "^1.0.0" readable-stream "^3.6.0" +are-we-there-yet@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/are-we-there-yet/-/are-we-there-yet-3.0.1.tgz#679df222b278c64f2cdba1175cdc00b0d96164bd" + integrity sha512-QZW4EDmGwlYur0Yyf/b2uGucHQMa8aFUP7eu9ddR73vvhFyt4V0Vl3QHPcTNJ8l6qYOBdxgXdnBXQrHilfRQBg== + dependencies: + delegates "^1.0.0" + readable-stream "^3.6.0" + are-we-there-yet@~1.1.2: version "1.1.7" resolved "https://registry.yarnpkg.com/are-we-there-yet/-/are-we-there-yet-1.1.7.tgz#b15474a932adab4ff8a50d9adfa7e4e926f21146" @@ -1373,49 +1647,59 @@ argparse@^2.0.1: argv-formatter@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/argv-formatter/-/argv-formatter-1.0.0.tgz#a0ca0cbc29a5b73e836eebe1cbf6c5e0e4eb82f9" - integrity sha1-oMoMvCmltz6Dbuvhy/bF4OTrgvk= + integrity sha512-F2+Hkm9xFaRg+GkaNnbwXNDV5O6pnCFEmqyhvfC/Ic5LbgOWjJh3L+mN/s91rxVL3znE7DYVpW0GJFT+4YBgWw== + +array-buffer-byte-length@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/array-buffer-byte-length/-/array-buffer-byte-length-1.0.0.tgz#fabe8bc193fea865f317fe7807085ee0dee5aead" + integrity sha512-LPuwb2P+NrQw3XhxGc36+XSvuBPopovXYTR9Ew++Du9Yb/bx5AzBfrIsBoj0EZUifjQU+sHL21sseZ3jerWO/A== + dependencies: + call-bind "^1.0.2" + is-array-buffer "^3.0.1" array-ify@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/array-ify/-/array-ify-1.0.0.tgz#9e528762b4a9066ad163a6962a364418e9626ece" - integrity sha1-nlKHYrSpBmrRY6aWKjZEGOlibs4= + integrity sha512-c5AMf34bKdvPhQ7tBGhqkgKNUzMr4WUs+WDtC2ZUGOUncbxKMTvqxYctiseW3+L4bA8ec+GcZ6/A/FW4m8ukng== array-union@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/array-union/-/array-union-2.1.0.tgz#b798420adbeb1de828d84acd8a2e23d3efe85e8d" integrity sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw== +array.prototype.reduce@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/array.prototype.reduce/-/array.prototype.reduce-1.0.5.tgz#6b20b0daa9d9734dd6bc7ea66b5bbce395471eac" + integrity sha512-kDdugMl7id9COE8R7MHF5jWk7Dqt/fs4Pv+JXoICnYwqpjjjbUurz6w5fT5IG6brLdJhv6/VoHB0H7oyIBXd+Q== + dependencies: + call-bind "^1.0.2" + define-properties "^1.1.4" + es-abstract "^1.20.4" + es-array-method-boxes-properly "^1.0.0" + is-string "^1.0.7" + arrify@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d" - integrity sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0= + integrity sha512-3CYzex9M9FGQjCGMGyi6/31c8GJbgb0qGyrx5HWxPd0aCwh4cB2YjMb2Xf9UuoogrMrlO9cTqnB5rI5GHZTcUA== + +arrify@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/arrify/-/arrify-2.0.1.tgz#c9655e9331e0abcd588d2a7cad7e9956f66701fa" + integrity sha512-3duEwti880xqi4eAMN8AyR4a0ByT90zoYdLlevfrvU43vb0YZwZVfxOgxWrLXXXpyugL0hNZc9G6BiB5B3nUug== asap@^2.0.0: version "2.0.6" resolved "https://registry.yarnpkg.com/asap/-/asap-2.0.6.tgz#e50347611d7e690943208bbdafebcbc2fb866d46" - integrity sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY= + integrity sha512-BSHWgDSAiKs50o2Re8ppvp3seVHXSRM44cdSsT9FfNEUUZLOGWVCsiWaRPWM1Znn+mqZ1OfVZ3z3DWEzSp7hRA== -asn1.js-rfc2560@^4.0.0: - version "4.0.6" - resolved "https://registry.yarnpkg.com/asn1.js-rfc2560/-/asn1.js-rfc2560-4.0.6.tgz#0975ce84768a8401e95884ad13e2d00e7b25a280" - integrity sha512-ysf48ni+f/efNPilq4+ApbifUPcSW/xbDeQAh055I+grr2gXgNRQqHew7kkO70WSMQ2tEOURVwsK+dJqUNjIIg== - dependencies: - asn1.js-rfc5280 "^2.0.0" - -asn1.js-rfc2560@^5.0.0: +asn1.js-rfc2560@^5.0.0, asn1.js-rfc2560@^5.0.1: version "5.0.1" resolved "https://registry.yarnpkg.com/asn1.js-rfc2560/-/asn1.js-rfc2560-5.0.1.tgz#cff99b903e714756b29503ad49de01c72f131e60" integrity sha512-1PrVg6kuBziDN3PGFmRk3QrjpKvP9h/Hv5yMrFZvC1kpzP6dQRzf5BpKstANqHBkaOUmTpakJWhicTATOA/SbA== dependencies: asn1.js-rfc5280 "^3.0.0" -asn1.js-rfc5280@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/asn1.js-rfc5280/-/asn1.js-rfc5280-2.0.1.tgz#072f3dfc03f86d1faae7485c6197584ba2bb5ddc" - integrity sha512-1e2ypnvTbYD/GdxWK77tdLBahvo1fZUHlQJqAVUuZWdYj0rdjGcf2CWYUtbsyRYpYUMwMWLZFUtLxog8ZXTrcg== - dependencies: - asn1.js "^4.5.0" - asn1.js-rfc5280@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/asn1.js-rfc5280/-/asn1.js-rfc5280-3.0.0.tgz#94e60498d5d4984b842d1a825485837574ccc902" @@ -1423,16 +1707,7 @@ asn1.js-rfc5280@^3.0.0: dependencies: asn1.js "^5.0.0" -asn1.js@^4.5.0, asn1.js@^4.8.0: - version "4.10.1" - resolved "https://registry.yarnpkg.com/asn1.js/-/asn1.js-4.10.1.tgz#b9c2bf5805f1e64aadeed6df3a2bfafb5a73f5a0" - integrity sha512-p32cOF5q0Zqs9uBiONKYLm6BClCoBCM5O9JfeUSlnQLBTxYdTK+pW+nXflm8UkKd2UYlEbYz5qEi0JuZR9ckSw== - dependencies: - bn.js "^4.0.0" - inherits "^2.0.1" - minimalistic-assert "^1.0.0" - -asn1.js@^5.0.0: +asn1.js@^5.0.0, asn1.js@^5.4.1: version "5.4.1" resolved "https://registry.yarnpkg.com/asn1.js/-/asn1.js-5.4.1.tgz#11a980b84ebb91781ce35b0fdc2ee294e3783f07" integrity sha512-+I//4cYPccV8LdmBLiX8CYvf9Sp3vQsrqu2QNXRcrbiWvcx/UdlFiqUJJzxRQxgsZmvhXhn4cSKeSmoFjVdupA== @@ -1452,13 +1727,20 @@ asn1@~0.2.3: assert-plus@1.0.0, assert-plus@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-1.0.0.tgz#f12e0f3c5d77b0b1cdd9146942e4e96c1e4dd525" - integrity sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU= + integrity sha512-NfJ4UzBCcQGLDlQq7nHxH+tv3kyZ0hHQqF5BO6J7tNJeP5do1llPr8dZ8zHonfhAu0PHAdMkSo+8o0wxg9lZWw== assertion-error@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/assertion-error/-/assertion-error-1.1.0.tgz#e60b6b0e8f301bd97e5375215bda406c85118c0b" integrity sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw== +ast-types@^0.13.2: + version "0.13.4" + resolved "https://registry.yarnpkg.com/ast-types/-/ast-types-0.13.4.tgz#ee0d77b343263965ecc3fb62da16e7222b2b6782" + integrity sha512-x1FCFnFifvYDDzTaLII71vG5uvDwgtmDTEVWAxrgeiR8VjMONcCXJx7E+USjDtHlwFmt9MysbqgF9b9Vjr6w+w== + dependencies: + tslib "^2.0.1" + astral-regex@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/astral-regex/-/astral-regex-2.0.0.tgz#483143c567aeed4785759c0865786dc77d7d2e31" @@ -1471,57 +1753,80 @@ async-hook-jl@^1.7.6: dependencies: stack-chain "^1.3.7" -async@>=0.6.0, async@^3.1.0: - version "3.2.2" - resolved "https://registry.yarnpkg.com/async/-/async-3.2.2.tgz#2eb7671034bb2194d45d30e31e24ec7e7f9670cd" - integrity sha512-H0E+qZaDEfx/FY4t7iLRv1W2fFI6+pyCeTw1uN20AQPiwqwM6ojPxHxdLv4z8hi2DtnW9BOckSspLucW7pIE5g== +async-retry@^1.3.3: + version "1.3.3" + resolved "https://registry.yarnpkg.com/async-retry/-/async-retry-1.3.3.tgz#0e7f36c04d8478e7a58bdbed80cedf977785f280" + integrity sha512-wfr/jstw9xNi/0teMHrRW7dsz3Lt5ARhYNZ2ewpadnhaIp5mbALhOAP+EAdsC7t4Z6wqsDVv9+W6gm1Dk9mEyw== + dependencies: + retry "0.13.1" -async@^1.5.2: - version "1.5.2" - resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a" - integrity sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo= +async@>=0.6.0, async@^3.2.1, async@^3.2.3: + version "3.2.4" + resolved "https://registry.yarnpkg.com/async/-/async-3.2.4.tgz#2d22e00f8cddeb5fde5dd33522b56d1cf569a81c" + integrity sha512-iAB+JbDEGXhyIUavoDl9WP/Jj106Kz9DEn1DPgYw5ruDn0e3Wgi3sKFm55sASdGBNOQB8F59d9qQ7deqrHA8wQ== asynckit@^0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" - integrity sha1-x57Zf380y48robyXkLzDZkdLS3k= + integrity sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q== + +available-typed-arrays@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz#92f95616501069d07d10edb2fc37d3e1c65123b7" + integrity sha512-DMD0KiN46eipeziST1LPP/STfDU0sufISXmjSgvVsoU2tqxctQeASejWcfNtxYKqETM1UxQ8sp2OrSBWpHY6sw== aws-sdk@^2.878.0: - version "2.1042.0" - resolved "https://registry.yarnpkg.com/aws-sdk/-/aws-sdk-2.1042.0.tgz#c3385bf6cbb8f97c2cde427c0ab3d9720fa4b82a" - integrity sha512-JWjs6+Zhuo990WYH1iQR1njGOvoCFzaf2azX/zh3JdL7QNwzdqczoODMj0wb22831/7EoPDGaXHqp7aQwDsxwA== + version "2.1398.0" + resolved "https://registry.yarnpkg.com/aws-sdk/-/aws-sdk-2.1398.0.tgz#8627ff0e8b39d656dd9b8eeabc6699fdfe0f4d0a" + integrity sha512-jiHAhKPPKDHZdwsbY9FD/WfX9RfQ7+7eKvXyXr7BYf0JIShok4TWan/iLdNWCtU0BhXYl+bfG9W0pG4rwJ9Ivg== dependencies: buffer "4.9.2" events "1.1.1" ieee754 "1.1.13" - jmespath "0.15.0" + jmespath "0.16.0" querystring "0.2.0" sax "1.2.1" url "0.10.3" - uuid "3.3.2" - xml2js "0.4.19" + util "^0.12.4" + uuid "8.0.0" + xml2js "0.5.0" aws-sign2@~0.7.0: version "0.7.0" resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.7.0.tgz#b46e890934a9591f2d2f6f86d7e6a9f1b3fe76a8" - integrity sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg= + integrity sha512-08kcGqnYf/YmjoRhfxyu+CLxBjUtHLXLXX/vUfx9l2LYzG3c1m61nrpyFUZI6zeS+Li/wWMMidD9KgrqtGq3mA== aws4@^1.8.0: - version "1.11.0" - resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.11.0.tgz#d61f46d83b2519250e2784daf5b09479a8b41c59" - integrity sha512-xh1Rl34h6Fi1DC2WWKfxUTVqRsNnr6LsKz2+hfwDxQJWmrx8+c7ylaqBMcHfl1U1r2dsifOvKX3LQuLNZ+XSvA== + version "1.12.0" + resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.12.0.tgz#ce1c9d143389679e253b314241ea9aa5cec980d3" + integrity sha512-NmWvPnx0F1SfrQbYwOi7OeaNGokp9XhzNioJ/CSBs8Qa4vxug81mhJEAVZwxXuBmYB5KDRfMq/F3RR0BIU7sWg== -axios@^0.21.1, axios@^0.21.4: +axios@^0.21.1: version "0.21.4" resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.4.tgz#c67b90dc0568e5c1cf2b0b858c43ba28e2eda575" integrity sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg== dependencies: follow-redirects "^1.14.0" +axios@^0.26.1: + version "0.26.1" + resolved "https://registry.yarnpkg.com/axios/-/axios-0.26.1.tgz#1ede41c51fcf51bbbd6fd43669caaa4f0495aaa9" + integrity sha512-fPwcX4EvnSHuInCMItEhAGnaSEXRBjtzh9fOtsE6E1G6p7vl7edEeZe11QHf18+6+9gR5PbKV/sGKNaD8YaMeA== + dependencies: + follow-redirects "^1.14.8" + +axios@^0.27.2: + version "0.27.2" + resolved "https://registry.yarnpkg.com/axios/-/axios-0.27.2.tgz#207658cc8621606e586c85db4b41a750e756d972" + integrity sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ== + dependencies: + follow-redirects "^1.14.9" + form-data "^4.0.0" + babel-code-frame@^6.26.0: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.26.0.tgz#63fd43f7dc1e3bb7ce35947db8fe369a3f58c74b" - integrity sha1-Y/1D99weO7fONZR9uP42mj9Yx0s= + integrity sha512-XqYMR2dfdGMW+hd0IUZ2PwK+fGeFkOxZJ0wY+JaQAHzt1Zx8LcvpiZD2NiGkEG8qx0CfkAOr5xt76d1e8vG90g== dependencies: chalk "^1.1.3" esutils "^2.0.2" @@ -1530,7 +1835,7 @@ babel-code-frame@^6.26.0: babel-generator@6.11.4: version "6.11.4" resolved "https://registry.yarnpkg.com/babel-generator/-/babel-generator-6.11.4.tgz#14f6933abb20c62666d27e3b7b9f5b9dc0712a9a" - integrity sha1-FPaTOrsgxiZm0n47e59bncBxKpo= + integrity sha512-JFBWXdE89s4V3E8kZroEEsnQF2A4/+55IzciGjnAATXj7HTMSum3SrW7QRYGSDLWTTQF+hhD3BmC2UFGgtM0Yw== dependencies: babel-messages "^6.8.0" babel-runtime "^6.9.0" @@ -1556,14 +1861,14 @@ babel-generator@6.26.1: babel-messages@^6.23.0, babel-messages@^6.8.0: version "6.23.0" resolved "https://registry.yarnpkg.com/babel-messages/-/babel-messages-6.23.0.tgz#f3cdf4703858035b2a2951c6ec5edf6c62f2630e" - integrity sha1-8830cDhYA1sqKVHG7F7fbGLyYw4= + integrity sha512-Bl3ZiA+LjqaMtNYopA9TYE9HP1tQ+E5dLxE0XrAzcIJeK2UqF0/EaqXwBn9esd4UmTfEab+P+UYQ1GnioFIb/w== dependencies: babel-runtime "^6.22.0" babel-runtime@^6.22.0, babel-runtime@^6.26.0, babel-runtime@^6.9.0: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.26.0.tgz#965c7058668e82b55d7bfe04ff2337bc8b5647fe" - integrity sha1-llxwWGaOgrVde/4E/yM3vItWR/4= + integrity sha512-ITKNuq2wKlW1fJg9sSW52eepoYgZBggvOAHC0u/CYu/qxQ9EVzThCgR69BnSXLHjy2f7SY5zaQ4yt7H9ZVxY2g== dependencies: core-js "^2.4.0" regenerator-runtime "^0.11.0" @@ -1571,7 +1876,7 @@ babel-runtime@^6.22.0, babel-runtime@^6.26.0, babel-runtime@^6.9.0: babel-traverse@6.26.0: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-traverse/-/babel-traverse-6.26.0.tgz#46a9cbd7edcc62c8e5c064e2d2d8d0f4035766ee" - integrity sha1-RqnL1+3MYsjlwGTi0tjQ9ANXZu4= + integrity sha512-iSxeXx7apsjCHe9c7n8VtRXGzI2Bk1rBSOJgCCjfyXb6v1aCqE1KSEpq/8SXuVN8Ka/Rh1WDTF0MDzkvTA4MIA== dependencies: babel-code-frame "^6.26.0" babel-messages "^6.23.0" @@ -1586,7 +1891,7 @@ babel-traverse@6.26.0: babel-types@^6.10.2, babel-types@^6.26.0: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-types/-/babel-types-6.26.0.tgz#a3b073f94ab49eb6fa55cd65227a334380632497" - integrity sha1-o7Bz+Uq0nrb6Vc1lInozQ4BjJJc= + integrity sha512-zhe3V/26rCWsEZK8kZN+HaQj5yQ1CilTObixFzKW1UWjqG7618Twz6YEsCnjfg5gBcJh02DrpCkS9h98ZqDY+g== dependencies: babel-runtime "^6.26.0" esutils "^2.0.2" @@ -1603,7 +1908,7 @@ balanced-match@^1.0.0: resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== -base64-js@^1.0.2: +base64-js@^1.0.2, base64-js@^1.3.0: version "1.5.1" resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a" integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA== @@ -1611,14 +1916,19 @@ base64-js@^1.0.2: bcrypt-pbkdf@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz#a4301d389b6a43f9b67ff3ca11a3f6637e360e9e" - integrity sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4= + integrity sha512-qeFIXtP4MSoi6NLqO12WfqARWWuCKi2Rn/9hJLEmtB5yTNr9DqFWkJRCf2qShWzPeAMRnOgCrq0sg/KLv5ES9w== dependencies: tweetnacl "^0.14.3" before-after-hook@^2.2.0: - version "2.2.2" - resolved "https://registry.yarnpkg.com/before-after-hook/-/before-after-hook-2.2.2.tgz#a6e8ca41028d90ee2c24222f201c90956091613e" - integrity sha512-3pZEU3NT5BFUo/AD5ERPWOgQOCZITni6iavr5AUw5AUwQjMlI0kzu5btnyD39AF0gUEsDPwJT+oY1ORBJijPjQ== + version "2.2.3" + resolved "https://registry.yarnpkg.com/before-after-hook/-/before-after-hook-2.2.3.tgz#c51e809c81a4e354084422b9b26bad88249c517c" + integrity sha512-NzUnlZexiaH/46WDhANlyR2bXRopNg4F/zuSA3OpZnllCUgRaOF2znDioDWrmbNVsuZk6l9pMquQB38cfBZwkQ== + +better-eval@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/better-eval/-/better-eval-1.3.0.tgz#a957cabcb50b6b0e40620136acaf8e06806d95d0" + integrity sha512-rQdKZHTWok2uC3wHyGwoV6mOxhnOyp07iHhyWQlS+U5zkYyhOEOT6Ri4Q0vPThTqCYs6RCbtAfTbPG+lUZkocw== big-integer@^1.6.17, big-integer@^1.6.43, big-integer@^1.6.51: version "1.6.51" @@ -1628,7 +1938,12 @@ big-integer@^1.6.17, big-integer@^1.6.43, big-integer@^1.6.51: bignumber.js@^2.4.0: version "2.4.0" resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-2.4.0.tgz#838a992da9f9d737e0f4b2db0be62bb09dd0c5e8" - integrity sha1-g4qZLan51zfg9LLbC+YrsJ3Qxeg= + integrity sha512-uw4ra6Cv483Op/ebM0GBKKfxZlSmn6NgFRby5L3yGTlunLj53KQgndDlqy2WVFOwgvurocApYkSud0aO+mvrpQ== + +bignumber.js@^9.0.0: + version "9.1.1" + resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-9.1.1.tgz#c4df7dc496bd849d4c9464344c1aa74228b4dac6" + integrity sha512-pHm4LsMJ6lzgNGVfZHjMoO8sdoRhOzOH4MLmY65Jg70bpxCKu5iOHNJyfF6OyvYw7t8Fpf35RuzUyqnQsj8Vig== bin-links@^2.2.1: version "2.3.0" @@ -1650,7 +1965,7 @@ binary-extensions@^2.0.0, binary-extensions@^2.2.0: binary@~0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/binary/-/binary-0.3.0.tgz#9f60553bc5ce8c3386f3b553cff47462adecaa79" - integrity sha1-n2BVO8XOjDOG87VTz/R0Yq3sqnk= + integrity sha512-D4H1y5KYwpJgK8wk1Cue5LLPgmwHKYSChkbspQg5JtVuR5ulGckxfR62H3AE9UDkdMC8yyXlqYihuz3Aqg2XZg== dependencies: buffers "~0.1.1" chainsaw "~0.1.0" @@ -1658,7 +1973,7 @@ binary@~0.3.0: binascii@0.0.2: version "0.0.2" resolved "https://registry.yarnpkg.com/binascii/-/binascii-0.0.2.tgz#a7f8a8801dbccf8b1756b743daa0fee9e2d9e0ee" - integrity sha1-p/iogB28z4sXVrdD2qD+6eLZ4O4= + integrity sha512-rA2CrUl1+6yKrn+XgLs8Hdy18OER1UW146nM+ixzhQXDY+Bd3ySkyIJGwF2a4I45JwbvF1mDL/nWkqBwpOcdBA== bindings@^1.5.0: version "1.5.0" @@ -1685,19 +2000,24 @@ bl@^3.0.0: bluebird@~3.4.1: version "3.4.7" resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.4.7.tgz#f72d760be09b7f76d08ed8fae98b289a8d05fab3" - integrity sha1-9y12C+Cbf3bQjtj66Ysomo0F+rM= + integrity sha512-iD3898SR7sWVRHbiQv+sHUtHnMvC1o3nW5rAcqnq3uOn07DSAppZYUkIGslDz6gXC7HfunPe7YVBgoEJASPcHA== bn.js@^4.0.0: version "4.12.0" resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.12.0.tgz#775b3f278efbb9718eec7361f483fb36fbbfea88" integrity sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA== +bn.js@^5.2.1: + version "5.2.1" + resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.2.1.tgz#0bc527a6a0d18d0aa8d5b0538ce4a77dccfa7b70" + integrity sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ== + boolbase@^1.0.0, boolbase@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/boolbase/-/boolbase-1.0.0.tgz#68dff5fbe60c51eb37725ea9e3ed310dcc1e776e" - integrity sha1-aN/1++YMUes3cl6p4+0xDcwed24= + integrity sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww== -bottleneck@^2.18.1: +bottleneck@^2.15.3: version "2.19.5" resolved "https://registry.yarnpkg.com/bottleneck/-/bottleneck-2.19.5.tgz#5df0b90f59fd47656ebe63c78a98419205cadd91" integrity sha512-VHiNCbI1lKdl44tGrhNfU3lup0Tj/ZBMJB5/2ZbNXRCPuRCO7ed2mgcK4r17y+KB2EfuYuRaVlwNbAeaWGSpbw== @@ -1710,7 +2030,7 @@ brace-expansion@^1.1.7: balanced-match "^1.0.0" concat-map "0.0.1" -braces@^3.0.1, braces@~3.0.2: +braces@^3.0.2, braces@~3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107" integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== @@ -1720,23 +2040,22 @@ braces@^3.0.1, braces@~3.0.2: browser-request@^0.3.3: version "0.3.3" resolved "https://registry.yarnpkg.com/browser-request/-/browser-request-0.3.3.tgz#9ece5b5aca89a29932242e18bf933def9876cc17" - integrity sha1-ns5bWsqJopkyJC4Yv5M975h2zBc= + integrity sha512-YyNI4qJJ+piQG6MMEuo7J3Bzaqssufx04zpEKYfSrl/1Op59HWali9zMtBpXnkmqMcOuWJPZvudrm9wISmnCbg== browser-stdout@1.3.1: version "1.3.1" resolved "https://registry.yarnpkg.com/browser-stdout/-/browser-stdout-1.3.1.tgz#baa559ee14ced73452229bad7326467c61fabd60" integrity sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw== -browserslist@^4.17.5: - version "4.18.1" - resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.18.1.tgz#60d3920f25b6860eb917c6c7b185576f4d8b017f" - integrity sha512-8ScCzdpPwR2wQh8IT82CA2VgDwjHyqMovPBZSNH54+tm4Jk2pCuv90gmAdH6J84OCRWi0b4gMe6O6XPXuJnjgQ== +browserslist@^4.21.3: + version "4.21.9" + resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.21.9.tgz#e11bdd3c313d7e2a9e87e8b4b0c7872b13897635" + integrity sha512-M0MFoZzbUrRU4KNfCrDLnvyE7gub+peetoTid3TBIqtunaDJyXlwhakT+/VkvSXcfIzFfK/nkCs4nmyTmxdNSg== dependencies: - caniuse-lite "^1.0.30001280" - electron-to-chromium "^1.3.896" - escalade "^3.1.1" - node-releases "^2.0.1" - picocolors "^1.0.0" + caniuse-lite "^1.0.30001503" + electron-to-chromium "^1.4.431" + node-releases "^2.0.12" + update-browserslist-db "^1.0.11" buffer-alloc-unsafe@^1.1.0: version "1.1.0" @@ -1754,17 +2073,17 @@ buffer-alloc@^1.2.0: buffer-equal-constant-time@1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz#f8e71132f7ffe6e01a5c9697a4c6f3e48d5cc819" - integrity sha1-+OcRMvf/5uAaXJaXpMbz5I1cyBk= + integrity sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA== buffer-equal@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/buffer-equal/-/buffer-equal-1.0.0.tgz#59616b498304d556abd466966b22eeda3eca5fbe" - integrity sha1-WWFrSYME1Var1GaWayLu2j7KX74= + version "1.0.1" + resolved "https://registry.yarnpkg.com/buffer-equal/-/buffer-equal-1.0.1.tgz#2f7651be5b1b3f057fcd6e7ee16cf34767077d90" + integrity sha512-QoV3ptgEaQpvVwbXdSO39iqPQTCxSF7A5U99AxbHYqUdCizL/lH2Z0A2y6nbZucxMEOtNyZfG2s6gsVugGpKkg== buffer-fill@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/buffer-fill/-/buffer-fill-1.0.0.tgz#f8f78b76789888ef39f205cd637f68e702122b2c" - integrity sha1-+PeLdniYiO858gXNY39o5wISKyw= + integrity sha512-T7zexNBwiiaCOGDg9xNX9PBmjrubblRkENuptryuI64URkXDFum9il/JGL8Lm8wYfAXpredVXXZz7eMHilimiQ== buffer-from@^1.0.0: version "1.1.2" @@ -1793,12 +2112,17 @@ buffer@4.9.2: buffers@~0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/buffers/-/buffers-0.1.1.tgz#b24579c3bed4d6d396aeee6d9a8ae7f5482ab7bb" - integrity sha1-skV5w77U1tOWru5tmorn9Ugqt7s= + integrity sha512-9q/rDEGSb/Qsvv2qvzIzdluL5k7AaJOTrw23z9reQthrbF7is4CtlT0DXyO1oei2DCp4uojjzQ7igaSHp1kAEQ== builtins@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/builtins/-/builtins-1.0.3.tgz#cb94faeb61c8696451db36534e1422f94f0aee88" - integrity sha1-y5T662HIaWRR2zZTThQi+U8K7og= + integrity sha512-uYBjakWipfaO/bXI7E8rq6kpwHRZK5cNYrUv2OzZSI/FvmdMyXJ2tG9dKcjEC5YHmHpUAwsargWIZNWdxb/bnQ== + +bytes@3.1.2: + version "3.1.2" + resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.1.2.tgz#8b0beeb98605adf1b128fa4386403c009e0221a5" + integrity sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg== cacache@^15.0.3, cacache@^15.0.5, cacache@^15.2.0, cacache@^15.3.0: version "15.3.0" @@ -1861,15 +2185,15 @@ camelcase@^5.0.0, camelcase@^5.3.1: resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320" integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg== -caniuse-lite@^1.0.30001280: - version "1.0.30001283" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001283.tgz#8573685bdae4d733ef18f78d44ba0ca5fe9e896b" - integrity sha512-9RoKo841j1GQFSJz/nCXOj0sD7tHBtlowjYlrqIUS812x9/emfBLBt6IyMz1zIaYc/eRL8Cs6HPUVi2Hzq4sIg== +caniuse-lite@^1.0.30001503: + version "1.0.30001503" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001503.tgz#88b6ff1b2cf735f1f3361dc1a15b59f0561aa398" + integrity sha512-Sf9NiF+wZxPfzv8Z3iS0rXM1Do+iOy2Lxvib38glFX+08TCYYYGR5fRJXk4d77C4AYwhUjgYgMsMudbh2TqCKw== cardinal@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/cardinal/-/cardinal-2.1.1.tgz#7cc1055d822d212954d07b085dea251cc7bc5505" - integrity sha1-fMEFXYItISlU0HsIXeolHMe8VQU= + integrity sha512-JSr5eOgoEymtYHBjNWyjrMqet9Am2miJhlfKNdqLp6zoeAh0KN5dRAcxlecj5mAJrmQomgiOBj35xHLrFjqBpw== dependencies: ansicolors "~0.3.2" redeyed "~2.1.0" @@ -1877,7 +2201,7 @@ cardinal@^2.1.1: caseless@~0.12.0: version "0.12.0" resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc" - integrity sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw= + integrity sha512-4tYFyifaFfGacoiObjJegolkwSU4xQNGbVgUiNYVUxbQ2x2lUsFvY4hVgVzGiIe6WLOPqycWXA40l+PWsxthUw== chai-as-promised@^7.1.1: version "7.1.1" @@ -1893,29 +2217,30 @@ chai-datetime@^1.8.0: dependencies: chai ">1.9.0" -chai@>1.9.0, chai@^4.3.4: - version "4.3.4" - resolved "https://registry.yarnpkg.com/chai/-/chai-4.3.4.tgz#b55e655b31e1eac7099be4c08c21964fce2e6c49" - integrity sha512-yS5H68VYOCtN1cjfwumDSuzn/9c+yza4f3reKXlE5rUg7SFcCEy90gJvydNgOYtblyf4Zi6jIWRnXOgErta0KA== +chai@>1.9.0, chai@^4.3.7: + version "4.3.7" + resolved "https://registry.yarnpkg.com/chai/-/chai-4.3.7.tgz#ec63f6df01829088e8bf55fca839bcd464a8ec51" + integrity sha512-HLnAzZ2iupm25PlN0xFreAlBA5zaBSv3og0DdeGA4Ar6h6rJ3A0rolRUKJhSF2V10GZKDgWF/VmAEsNWjCRB+A== dependencies: assertion-error "^1.1.0" check-error "^1.0.2" - deep-eql "^3.0.1" + deep-eql "^4.1.2" get-func-name "^2.0.0" + loupe "^2.3.1" pathval "^1.1.1" type-detect "^4.0.5" chainsaw@~0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/chainsaw/-/chainsaw-0.1.0.tgz#5eab50b28afe58074d0d58291388828b5e5fbc98" - integrity sha1-XqtQsor+WAdNDVgpE4iCi15fvJg= + integrity sha512-75kWfWt6MEKNC8xYXIdRpDehRYY/tNSgwKaJq+dbbDcxORuVrrQ+SEHoWsniVn9XPYfP4gmdWIeDk/4YNp1rNQ== dependencies: traverse ">=0.3.0 <0.4" chalk@^1.1.3: version "1.1.3" resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98" - integrity sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg= + integrity sha512-U3lRVLMSlsCfjqYPbLyVv11M9CPW4I728d6TCKMAOJueEeB9/8o+eSsMnxPJD+Q+K909sdESg7C+tIkoH6on1A== dependencies: ansi-styles "^2.2.1" escape-string-regexp "^1.0.2" @@ -1943,23 +2268,24 @@ chalk@^4.0.0, chalk@^4.1.0, chalk@^4.1.2: check-error@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/check-error/-/check-error-1.0.2.tgz#574d312edd88bb5dd8912e9286dd6c0aed4aac82" - integrity sha1-V00xLt2Iu13YkS6Sht1sCu1KrII= + integrity sha512-BrgHpW9NURQgzoNyjfq0Wu6VFO6D7IZEmJNdtgNqpzGG8RuNFHt2jQxWlAs4HMe119chBnv+34syEZtc6IhLtA== -cheerio-select@^1.5.0: - version "1.5.0" - resolved "https://registry.yarnpkg.com/cheerio-select/-/cheerio-select-1.5.0.tgz#faf3daeb31b17c5e1a9dabcee288aaf8aafa5823" - integrity sha512-qocaHPv5ypefh6YNxvnbABM07KMxExbtbfuJoIie3iZXX1ERwYmJcIiRrr9H05ucQP1k28dav8rpdDgjQd8drg== +cheerio-select@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/cheerio-select/-/cheerio-select-2.1.0.tgz#4d8673286b8126ca2a8e42740d5e3c4884ae21b4" + integrity sha512-9v9kG0LvzrlcungtnJtpGNxY+fzECQKhK4EGJX2vByejiMX84MFNQw4UxPJl3bFbTMw+Dfs37XaIkCwTZfLh4g== dependencies: - css-select "^4.1.3" - css-what "^5.0.1" - domelementtype "^2.2.0" - domhandler "^4.2.0" - domutils "^2.7.0" + boolbase "^1.0.0" + css-select "^5.1.0" + css-what "^6.1.0" + domelementtype "^2.3.0" + domhandler "^5.0.3" + domutils "^3.0.1" cheerio@0.20.0: version "0.20.0" resolved "https://registry.yarnpkg.com/cheerio/-/cheerio-0.20.0.tgz#5c710f2bab95653272842ba01c6ea61b3545ec35" - integrity sha1-XHEPK6uVZTJyhCugHG6mGzVF7DU= + integrity sha512-e5jCTzJc28MWkrLLjB1mu3ks7rDQJLC5y/JMdQkOAEX/dmJk62rC6Xae1yvOO4xyCxLpzcth3jIZ7nypmjQ/0w== dependencies: css-select "~1.2.0" dom-serializer "~0.1.0" @@ -1972,7 +2298,7 @@ cheerio@0.20.0: cheerio@0.22.0: version "0.22.0" resolved "https://registry.yarnpkg.com/cheerio/-/cheerio-0.22.0.tgz#a9baa860a3f9b595a6b81b1a86873121ed3a269e" - integrity sha1-qbqoYKP5tZWmuBsahocxIe06Jp4= + integrity sha512-8/MzidM6G/TgRelkzDG13y3Y9LxBjCb+8yOEZ9+wwq5gVF2w2pV0wmHvjfT0RvuxGyR7UEuK36r+yYMbT4uKgA== dependencies: css-select "~1.2.0" dom-serializer "~0.1.0" @@ -1994,7 +2320,7 @@ cheerio@0.22.0: cheerio@1.0.0-rc.2: version "1.0.0-rc.2" resolved "https://registry.yarnpkg.com/cheerio/-/cheerio-1.0.0-rc.2.tgz#4b9f53a81b27e4d5dac31c0ffd0cfa03cc6830db" - integrity sha1-S59TqBsn5NXawxwP/Qz6A8xoMNs= + integrity sha512-9LDHQy1jHc/eXMzPN6/oah9Qba4CjdKECC7YYEE/2zge/tsGwt19NQp5NFdfd5Lx6TZlyC5SXNQkG41P9r6XDg== dependencies: css-select "~1.2.0" dom-serializer "~0.1.0" @@ -2004,17 +2330,17 @@ cheerio@1.0.0-rc.2: parse5 "^3.0.1" cheerio@^1.0.0-rc.10: - version "1.0.0-rc.10" - resolved "https://registry.yarnpkg.com/cheerio/-/cheerio-1.0.0-rc.10.tgz#2ba3dcdfcc26e7956fc1f440e61d51c643379f3e" - integrity sha512-g0J0q/O6mW8z5zxQ3A8E8J1hUgp4SMOvEoW/x84OwyHKe/Zccz83PVT4y5Crcr530FV6NgmKI1qvGTKVl9XXVw== - dependencies: - cheerio-select "^1.5.0" - dom-serializer "^1.3.2" - domhandler "^4.2.0" - htmlparser2 "^6.1.0" - parse5 "^6.0.1" - parse5-htmlparser2-tree-adapter "^6.0.1" - tslib "^2.2.0" + version "1.0.0-rc.12" + resolved "https://registry.yarnpkg.com/cheerio/-/cheerio-1.0.0-rc.12.tgz#788bf7466506b1c6bf5fae51d24a2c4d62e47683" + integrity sha512-VqR8m68vM46BNnuZ5NtnGBKIE/DfN0cRIzg9n40EIq9NOv90ayxLBXA8fXC5gquFRGJSTRqBq25Jt2ECLR431Q== + dependencies: + cheerio-select "^2.1.0" + dom-serializer "^2.0.0" + domhandler "^5.0.3" + domutils "^3.0.1" + htmlparser2 "^8.0.1" + parse5 "^7.0.0" + parse5-htmlparser2-tree-adapter "^7.0.0" chokidar@3.3.0: version "3.3.0" @@ -2056,7 +2382,7 @@ clean-stack@^2.0.0: cli-columns@^3.1.2: version "3.1.2" resolved "https://registry.yarnpkg.com/cli-columns/-/cli-columns-3.1.2.tgz#6732d972979efc2ae444a1f08e08fa139c96a18e" - integrity sha1-ZzLZcpee/CrkRKHwjgj6E5yWoY4= + integrity sha512-iQYpDgpPPmCjn534ikQOhi+ydP6uMar+DtJ6a0In4aGL/PKqWfao75s6eF81quQQaz7isGz+goNECLARRZswdg== dependencies: string-width "^2.0.0" strip-ansi "^3.0.1" @@ -2069,14 +2395,13 @@ cli-cursor@^3.1.0: restore-cursor "^3.1.0" cli-table3@^0.6.0: - version "0.6.0" - resolved "https://registry.yarnpkg.com/cli-table3/-/cli-table3-0.6.0.tgz#b7b1bc65ca8e7b5cef9124e13dc2b21e2ce4faee" - integrity sha512-gnB85c3MGC7Nm9I/FkiasNBOKjOiO1RNuXXarQms37q4QMpWdlbBgD/VnOStA2faG1dpXMv31RFApjX1/QdgWQ== + version "0.6.3" + resolved "https://registry.yarnpkg.com/cli-table3/-/cli-table3-0.6.3.tgz#61ab765aac156b52f222954ffc607a6f01dbeeb2" + integrity sha512-w5Jac5SykAeZJKntOxJCrm63Eg5/4dhMWIcuTbo9rpE+brgaSZo0RuNJZeOyMgsUdhDeojvgyQLmjI+K50ZGyg== dependencies: - object-assign "^4.1.0" string-width "^4.2.0" optionalDependencies: - colors "^1.1.2" + "@colors/colors" "1.5.0" cli-truncate@^2.1.0: version "2.1.0" @@ -2121,25 +2446,34 @@ cliui@^7.0.2: strip-ansi "^6.0.0" wrap-ansi "^7.0.0" +cliui@^8.0.1: + version "8.0.1" + resolved "https://registry.yarnpkg.com/cliui/-/cliui-8.0.1.tgz#0c04b075db02cbfe60dc8e6cf2f5486b1a3608aa" + integrity sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ== + dependencies: + string-width "^4.2.0" + strip-ansi "^6.0.1" + wrap-ansi "^7.0.0" + clone-buffer@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/clone-buffer/-/clone-buffer-1.0.0.tgz#e3e25b207ac4e701af721e2cb5a16792cac3dc58" - integrity sha1-4+JbIHrE5wGvch4staFnksrD3Fg= + integrity sha512-KLLTJWrvwIP+OPfMn0x2PheDEP20RPUcGXj/ERegTgdmPEZylALQldygiqrPPu8P45uNuPs7ckmReLY6v/iA5g== clone-stats@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/clone-stats/-/clone-stats-1.0.0.tgz#b3782dff8bb5474e18b9b6bf0fdfe782f8777680" - integrity sha1-s3gt/4u1R04Yuba/D9/ngvh3doA= + integrity sha512-au6ydSpg6nsrigcZ4m8Bc9hxjeW+GJ8xh5G3BJCMt4WXe1H10UNaVOamqQTmrx1kjVuxAHIQSNU6hY4Nsn9/ag== clone@^1.0.2: version "1.0.4" resolved "https://registry.yarnpkg.com/clone/-/clone-1.0.4.tgz#da309cc263df15994c688ca902179ca3c7cd7c7e" - integrity sha1-2jCcwmPfFZlMaIypAheco8fNfH4= + integrity sha512-JQHZ2QMW6l3aH/j6xCqQThY/9OH4D/9ls34cgkUBiEeocRTU04tHfKPBsUK1PqZCUQM7GiA0IIXJSuXHI64Kbg== clone@^2.1.1: version "2.1.2" resolved "https://registry.yarnpkg.com/clone/-/clone-2.1.2.tgz#1b7f4b9f591f1e8f83670401600345a02887435f" - integrity sha1-G39Ln1kfHo+DZwQBYANFoCiHQ18= + integrity sha512-3Pe/CF1Nn94hyhIYpjtiLhdCoEoz0DqQ+988E9gmeEdQZlojxnOb74wctFyuwWQHzqyf9X7C7MG8juUpqBJT8w== cloneable-readable@^1.0.0: version "1.1.3" @@ -2169,7 +2503,7 @@ cmd-shim@^4.0.1: code-point-at@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77" - integrity sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c= + integrity sha512-RpAVKQA5T63xEj6/giIbUEtZwJ4UFIc3ZtvEkiaUERylqe8xb5IvqcgOurZLahv93CLKfxcw5YI+DZcUBRyLXA== color-convert@^1.9.0, color-convert@^1.9.3: version "1.9.3" @@ -2188,17 +2522,17 @@ color-convert@^2.0.1: color-logger@0.0.3: version "0.0.3" resolved "https://registry.yarnpkg.com/color-logger/-/color-logger-0.0.3.tgz#d9b22dd1d973e166b18bf313f9f481bba4df2018" - integrity sha1-2bIt0dlz4Waxi/MT+fSBu6TfIBg= + integrity sha512-s4oriek7VTdSmDbS5chJhNui3uUzlk/mU39V4HnOUv0KphRXpIj73lq4wY5f8l/x+WtHUhiV+FCzsrNO1w6REA== color-logger@0.0.6: version "0.0.6" resolved "https://registry.yarnpkg.com/color-logger/-/color-logger-0.0.6.tgz#e56245ef29822657110c7cb75a9cd786cb69ed1b" - integrity sha1-5WJF7ymCJlcRDHy3WpzXhstp7Rs= + integrity sha512-0iBj3eHRYnor8EJi3oQ1kixbr7B2Sbw1InxjsYZxS+q2H+Ii69m3ARYSJeYIqmf/QRtFhWnR1v97wp8N7ABubw== color-name@1.1.3: version "1.1.3" resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" - integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU= + integrity sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw== color-name@^1.0.0, color-name@~1.1.4: version "1.1.4" @@ -2206,14 +2540,14 @@ color-name@^1.0.0, color-name@~1.1.4: integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== color-string@^1.6.0: - version "1.8.2" - resolved "https://registry.yarnpkg.com/color-string/-/color-string-1.8.2.tgz#08bd49fa5f3889c27b0c670052ed746dd7a671de" - integrity sha512-w5ZkKRdLsc5NOYsmnpS2DpyRW71npwZGwbRpLrJTuqjfTs2Bhrba7UiV59IX9siBlCPl2pne5NtiwnVWUzvYFA== + version "1.9.1" + resolved "https://registry.yarnpkg.com/color-string/-/color-string-1.9.1.tgz#4467f9146f036f855b764dfb5bf8582bf342c7a4" + integrity sha512-shrVawQFojnZv6xM40anx4CkoDP+fZsw/ZerEMsW/pyzsRbElpsL/DBVW7q3ExxwusdNXI3lXpuhEZkzs8p5Eg== dependencies: color-name "^1.0.0" simple-swizzle "^0.2.2" -color-support@^1.1.2: +color-support@^1.1.2, color-support@^1.1.3: version "1.1.3" resolved "https://registry.yarnpkg.com/color-support/-/color-support-1.1.3.tgz#93834379a1cc9a0c61f82f52f0d04322251bd5a2" integrity sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg== @@ -2227,14 +2561,9 @@ color@^3.1.3: color-string "^1.6.0" colorette@^2.0.16: - version "2.0.16" - resolved "https://registry.yarnpkg.com/colorette/-/colorette-2.0.16.tgz#713b9af84fdb000139f04546bd4a93f62a5085da" - integrity sha512-hUewv7oMjCp+wkBv5Rm0v87eJhq4woh5rSR+42YSQJKecCqgIqNkZ6lAlQms/BwHPJA5NKMRlpxPRv0n8HQW6g== - -colors@^1.1.2, colors@^1.2.1: - version "1.4.0" - resolved "https://registry.yarnpkg.com/colors/-/colors-1.4.0.tgz#c50491479d4c1bdaed2c9ced32cf7c7dc2360f78" - integrity sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA== + version "2.0.20" + resolved "https://registry.yarnpkg.com/colorette/-/colorette-2.0.20.tgz#9eb793e6833067f7235902fcd3b09917a000a95a" + integrity sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w== colorspace@1.1.x: version "1.1.4" @@ -2247,7 +2576,7 @@ colorspace@1.1.x: columnify@~1.5.4: version "1.5.4" resolved "https://registry.yarnpkg.com/columnify/-/columnify-1.5.4.tgz#4737ddf1c7b69a8a7c340570782e947eec8e78bb" - integrity sha1-Rzfd8ce2mop8NAVweC6UfuyOeLs= + integrity sha512-rFl+iXVT1nhLQPfGDw+3WcS8rmm7XsLKUmhsGE3ihzzpIikeGrTaZPIRKYWeLsLBypsHzjXIvYEltVUZS84XxQ== dependencies: strip-ansi "^3.0.0" wcwidth "^1.0.0" @@ -2259,7 +2588,12 @@ combined-stream@^1.0.6, combined-stream@^1.0.8, combined-stream@~1.0.6: dependencies: delayed-stream "~1.0.0" -commander@^8.3.0, commander@~8.3.0: +commander@^9.3.0: + version "9.5.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-9.5.0.tgz#bc08d1eb5cedf7ccb797a96199d41c7bc3e60d30" + integrity sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ== + +commander@~8.3.0: version "8.3.0" resolved "https://registry.yarnpkg.com/commander/-/commander-8.3.0.tgz#4837ea1b2da67b9c616a67afbb0fafee567bca66" integrity sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww== @@ -2277,7 +2611,7 @@ common-ancestor-path@^1.0.1: commondir@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/commondir/-/commondir-1.0.1.tgz#ddd800da0c66127393cca5950ea968a3aaf1253b" - integrity sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs= + integrity sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg== compare-func@^2.0.0: version "2.0.0" @@ -2287,15 +2621,27 @@ compare-func@^2.0.0: array-ify "^1.0.0" dot-prop "^5.1.0" +compressible@^2.0.12: + version "2.0.18" + resolved "https://registry.yarnpkg.com/compressible/-/compressible-2.0.18.tgz#af53cca6b070d4c3c0750fbd77286a6d7cc46fba" + integrity sha512-AF3r7P5dWxL8MxyITRMlORQNaOA2IkAFaTr4k7BUumjPtRpGDTZpl0Pb1XCO6JeDCBdp126Cgs9sMxqSjgYyRg== + dependencies: + mime-db ">= 1.43.0 < 2" + concat-map@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" - integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s= + integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg== console-control-strings@^1.0.0, console-control-strings@^1.1.0, console-control-strings@~1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/console-control-strings/-/console-control-strings-1.1.0.tgz#3d7cf4464db6446ea644bf4b39507f9851008e8e" - integrity sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4= + integrity sha512-ty/fTekppD2fIwRvnZAVdeOiGd1c7YXEixbgJTNzqcxJWKQnjJ/V1bNEEE6hygpM3WjwHFUVK6HTjWSzV4a8sQ== + +content-type@^1.0.2: + version "1.0.5" + resolved "https://registry.yarnpkg.com/content-type/-/content-type-1.0.5.tgz#8b773162656d1d1086784c8f23a54ce6d73d7918" + integrity sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA== conventional-changelog-angular@^5.0.0, conventional-changelog-angular@^5.0.11: version "5.0.13" @@ -2306,13 +2652,13 @@ conventional-changelog-angular@^5.0.0, conventional-changelog-angular@^5.0.11: q "^1.5.1" conventional-changelog-writer@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/conventional-changelog-writer/-/conventional-changelog-writer-5.0.0.tgz#c4042f3f1542f2f41d7d2e0d6cad23aba8df8eec" - integrity sha512-HnDh9QHLNWfL6E1uHz6krZEQOgm8hN7z/m7tT16xwd802fwgMN0Wqd7AQYVkhpsjDUx/99oo+nGgvKF657XP5g== + version "5.0.1" + resolved "https://registry.yarnpkg.com/conventional-changelog-writer/-/conventional-changelog-writer-5.0.1.tgz#e0757072f045fe03d91da6343c843029e702f359" + integrity sha512-5WsuKUfxW7suLblAbFnxAcrvf6r+0b7GvNaWUwUIk0bXMnENP/PEieGKVUQrjPqwPT4o3EPAASBXiY6iHooLOQ== dependencies: conventional-commits-filter "^2.0.7" dateformat "^3.0.0" - handlebars "^4.7.6" + handlebars "^4.7.7" json-stringify-safe "^5.0.1" lodash "^4.17.15" meow "^8.0.0" @@ -2329,9 +2675,9 @@ conventional-commits-filter@^2.0.0, conventional-commits-filter@^2.0.7: modify-values "^1.0.0" conventional-commits-parser@^3.2.2, conventional-commits-parser@^3.2.3: - version "3.2.3" - resolved "https://registry.yarnpkg.com/conventional-commits-parser/-/conventional-commits-parser-3.2.3.tgz#fc43704698239451e3ef35fd1d8ed644f46bd86e" - integrity sha512-YyRDR7On9H07ICFpRm/igcdjIqebXbvf4Cff+Pf0BrBys1i1EOzx9iFXNlAbdrLAR8jf7bkUYkDAr8pEy0q4Pw== + version "3.2.4" + resolved "https://registry.yarnpkg.com/conventional-commits-parser/-/conventional-commits-parser-3.2.4.tgz#a7d3b77758a202a9b2293d2112a8d8052c740972" + integrity sha512-nK7sAtfi+QXbxHCYfhpZsfRtaitZLIA6889kFIouLvz6repszQDgxBu7wf2WbU+Dco7sAnNCJYERCwt54WPC2Q== dependencies: JSONStream "^1.0.4" is-text-path "^1.0.1" @@ -2341,11 +2687,14 @@ conventional-commits-parser@^3.2.2, conventional-commits-parser@^3.2.3: through2 "^4.0.0" convert-source-map@^1.5.0, convert-source-map@^1.7.0: - version "1.8.0" - resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.8.0.tgz#f3373c32d21b4d780dd8004514684fb791ca4369" - integrity sha512-+OQdjP49zViI/6i7nIJpA8rAl4sV/JdPfU9nZs3VqOwGIgizICvuN2ru6fMd+4llL0tar18UYJXfZ/TWtmhUjA== - dependencies: - safe-buffer "~5.1.1" + version "1.9.0" + resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.9.0.tgz#7faae62353fb4213366d0ca98358d22e8368b05f" + integrity sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A== + +copy-to@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/copy-to/-/copy-to-2.0.1.tgz#2680fbb8068a48d08656b6098092bdafc906f4a5" + integrity sha512-3DdaFaU/Zf1AnpLiFDeNCD4TOWe3Zl2RZaTzUvWiIk5ERzcCodOE20Vqq4fzCbNoHURFHT4/us/Lfq+S2zyY4w== copyfiles@^2.4.1: version "2.4.1" @@ -2368,7 +2717,7 @@ core-js@^2.4.0: core-util-is@1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" - integrity sha1-tf1UIgqivFq1eqtxQMlAdUUDwac= + integrity sha512-3lqz5YjWTYnW6dlDa5TLaTCcShfar1e40rmcJVwCBJC6mWlFuj0eCHIElmG1g5kyuJ/GD+8Wn4FFCcz4gJPfaQ== core-util-is@~1.0.0: version "1.0.3" @@ -2376,9 +2725,9 @@ core-util-is@~1.0.0: integrity sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ== cosmiconfig@^7.0.0: - version "7.0.1" - resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-7.0.1.tgz#714d756522cace867867ccb4474c5d01bbae5d6d" - integrity sha512-a1YWNUV2HwGimB7dU2s1wUMurNKjpx60HxBB6xUM8Re+2s1g1IIfJvFR0/iCF+XHdE0GMTKTuLR32UQff4TEyQ== + version "7.1.0" + resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-7.1.0.tgz#1443b9afa596b670082ea46cbd8f6a62b84635f6" + integrity sha512-AdmX6xUzdNASswsFtmwSt7Vj8po9IuqXm0UXz7QKPuEUmPB4XyjGfaAr2PSuELMwkRMVH1EpIkX5bTZGRB3eCA== dependencies: "@types/parse-json" "^4.0.0" import-fresh "^3.2.1" @@ -2412,21 +2761,21 @@ crypto-random-string@^2.0.0: resolved "https://registry.yarnpkg.com/crypto-random-string/-/crypto-random-string-2.0.0.tgz#ef2a7a966ec11083388369baa02ebead229b30d5" integrity sha512-v1plID3y9r/lPhviJ1wrXpLeyUIGAZ2SHNYTEapm7/8A9nLPoyvVp3RK/EPFqn5kEznyWgYZNsRtYYIWbuG8KA== -css-select@^4.1.3: - version "4.1.3" - resolved "https://registry.yarnpkg.com/css-select/-/css-select-4.1.3.tgz#a70440f70317f2669118ad74ff105e65849c7067" - integrity sha512-gT3wBNd9Nj49rAbmtFHj1cljIAOLYSX1nZ8CB7TBO3INYckygm5B7LISU/szY//YmdiSLbJvDLOx9VnMVpMBxA== +css-select@^5.1.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/css-select/-/css-select-5.1.0.tgz#b8ebd6554c3637ccc76688804ad3f6a6fdaea8a6" + integrity sha512-nwoRF1rvRRnnCqqY7updORDsuqKzqYJ28+oSMaJMMgOauh3fvwHqMS7EZpIPqK8GL+g9mKxF1vP/ZjSeNjEVHg== dependencies: boolbase "^1.0.0" - css-what "^5.0.0" - domhandler "^4.2.0" - domutils "^2.6.0" - nth-check "^2.0.0" + css-what "^6.1.0" + domhandler "^5.0.2" + domutils "^3.0.1" + nth-check "^2.0.1" css-select@~1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/css-select/-/css-select-1.2.0.tgz#2b3a110539c5355f1cd8d314623e870b121ec858" - integrity sha1-KzoRBTnFNV8c2NMUYj6HCxIeyFg= + integrity sha512-dUQOBoqdR7QwV90WysXPLXG5LO7nhYBgiWVfxF80DKPF8zx1t/pUd2FYy73emg3zrjtM6dzmYgbHKfV2rxiHQA== dependencies: boolbase "~1.0.0" css-what "2.1" @@ -2438,10 +2787,10 @@ css-what@2.1: resolved "https://registry.yarnpkg.com/css-what/-/css-what-2.1.3.tgz#a6d7604573365fe74686c3f311c56513d88285f2" integrity sha512-a+EPoD+uZiNfh+5fxw2nO9QwFa6nJe2Or35fGY6Ipw1R3R4AGz1d1TEZrCegvw2YTmZ0jXirGYlzxxpYSHwpEg== -css-what@^5.0.0, css-what@^5.0.1: - version "5.1.0" - resolved "https://registry.yarnpkg.com/css-what/-/css-what-5.1.0.tgz#3f7b707aadf633baf62c2ceb8579b545bb40f7fe" - integrity sha512-arSMRWIIFY0hV8pIxZMEfmMI47Wj3R/aWpZDDxWYCPEiOMv6tfOrnpDtgxBYPEQD4V0Y/958+1TdC3iWTFcUPw== +css-what@^6.1.0: + version "6.1.0" + resolved "https://registry.yarnpkg.com/css-what/-/css-what-6.1.0.tgz#fb5effcf76f1ddea2c81bdfaa4de44e79bac70f4" + integrity sha512-HTUrgRJ7r4dsZKU6GjmpfRK1O76h97Z8MfS1G0FozR+oF2kG6Vfe8JE6zwrkbxigziPHinCJ+gCPjA9EaBDtRw== cssom@0.3.x, "cssom@>= 0.3.0 < 0.4.0": version "0.3.8" @@ -2451,7 +2800,7 @@ cssom@0.3.x, "cssom@>= 0.3.0 < 0.4.0": "cssstyle@>= 0.2.29 < 0.3.0": version "0.2.37" resolved "https://registry.yarnpkg.com/cssstyle/-/cssstyle-0.2.37.tgz#541097234cb2513c83ceed3acddc27ff27987d54" - integrity sha1-VBCXI0yyUTyDzu06zdwn/yeYfVQ= + integrity sha512-FUpKc+1FNBsHUr9IsfSGCovr8VuGOiiuzlgCyppKBjJi2jYTOFLN3oiiNRMIvYqbFzF38mqKj4BgcevzU5/kIA== dependencies: cssom "0.3.x" @@ -2463,14 +2812,19 @@ dargs@^7.0.0: dashdash@^1.12.0: version "1.14.1" resolved "https://registry.yarnpkg.com/dashdash/-/dashdash-1.14.1.tgz#853cfa0f7cbe2fed5de20326b8dd581035f6e2f0" - integrity sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA= + integrity sha512-jRFi8UDGo6j+odZiEpjazZaWqEal3w/basFjQHQEwVtZJGDpxbH1MeYluwCS8Xq5wmLJooDlMgvVarmWfGM44g== dependencies: assert-plus "^1.0.0" +data-uri-to-buffer@3: + version "3.0.1" + resolved "https://registry.yarnpkg.com/data-uri-to-buffer/-/data-uri-to-buffer-3.0.1.tgz#594b8973938c5bc2c33046535785341abc4f3636" + integrity sha512-WboRycPNsVw3B3TL559F7kuBUM4d8CgMEvk6xEJlOp7OBPjt6G7z8WMWlD2rOFZLk6OYfFIUGsCOWzcQH9K2og== + date-utils@*: version "1.2.21" resolved "https://registry.yarnpkg.com/date-utils/-/date-utils-1.2.21.tgz#61fb16cdc1274b3c9acaaffe9fc69df8720a2b64" - integrity sha1-YfsWzcEnSzyayq/+n8ad+HIKK2Q= + integrity sha512-wJMBjqlwXR0Iv0wUo/lFbhSQ7MmG1hl36iuxuE91kW+5b5sWbase73manEqNH9sOLFAMG83B4ffNKq9/Iq0FVA== dateformat@^3.0.0: version "3.0.3" @@ -2484,21 +2838,21 @@ debug@3.2.6: dependencies: ms "^2.1.1" -debug@4, debug@^4.0.0, debug@^4.1.0, debug@^4.1.1, debug@^4.3.1, debug@^4.3.2, debug@^4.3.3: - version "4.3.3" - resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.3.tgz#04266e0b70a98d4462e6e288e38259213332b664" - integrity sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q== +debug@4, debug@^4.0.0, debug@^4.1.0, debug@^4.1.1, debug@^4.3.2, debug@^4.3.3, debug@^4.3.4: + version "4.3.4" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" + integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== dependencies: ms "2.1.2" -debug@^2.6.8: +debug@^2.6.8, debug@^2.6.9: version "2.6.9" resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" integrity sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA== dependencies: ms "2.0.0" -debug@^3.1.0, debug@^3.2.6: +debug@^3.2.6: version "3.2.7" resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.7.tgz#72580b7e9145fb39b6676f9c5e5fb100b934179a" integrity sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ== @@ -2508,12 +2862,12 @@ debug@^3.1.0, debug@^3.2.6: debuglog@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/debuglog/-/debuglog-1.0.1.tgz#aa24ffb9ac3df9a2351837cfb2d279360cd78492" - integrity sha1-qiT/uaw9+aI1GDfPstJ5NgzXhJI= + integrity sha512-syBZ+rnAK3EgMsH2aYEOLUW7mZSY9Gb+0wUMCFsZvcmiz+HigA0LOcq/HoQqVuGG+EKykunc7QG2bzrponfaSw== decamelize-keys@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/decamelize-keys/-/decamelize-keys-1.1.0.tgz#d171a87933252807eb3cb61dc1c1445d078df2d9" - integrity sha1-0XGoeTMlKAfrPLYdwcFEXQeN8tk= + version "1.1.1" + resolved "https://registry.yarnpkg.com/decamelize-keys/-/decamelize-keys-1.1.1.tgz#04a2d523b2f18d80d0158a43b895d56dff8d19d8" + integrity sha512-WiPxgEirIV0/eIOMcnFBA3/IJZAZqKnwAwWyvvdi4lsr1WCN22nhdf/3db3DoZcUjTV2SqfzIwNyp6y2xs3nmg== dependencies: decamelize "^1.1.0" map-obj "^1.0.0" @@ -2521,12 +2875,12 @@ decamelize-keys@^1.1.0: decamelize@^1.1.0, decamelize@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" - integrity sha1-9lNNFRSCabIDUue+4m9QH5oZEpA= + integrity sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA== -deep-eql@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/deep-eql/-/deep-eql-3.0.1.tgz#dfc9404400ad1c8fe023e7da1df1c147c4b444df" - integrity sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw== +deep-eql@^4.1.2: + version "4.1.3" + resolved "https://registry.yarnpkg.com/deep-eql/-/deep-eql-4.1.3.tgz#7c7775513092f7df98d8df9996dd085eb668cc6d" + integrity sha512-WaEtAOpRA1MQ0eohqZjpGD8zdI0Ovsm8mmFhaDN8dvDZzyoUMcYDnf5Y6iu7HTXxf8JDS23qWa4a+hKCDyOPzw== dependencies: type-detect "^4.0.0" @@ -2541,30 +2895,48 @@ deep-is@^0.1.3, deep-is@~0.1.3: integrity sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ== default-require-extensions@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/default-require-extensions/-/default-require-extensions-3.0.0.tgz#e03f93aac9b2b6443fc52e5e4a37b3ad9ad8df96" - integrity sha512-ek6DpXq/SCpvjhpFsLFRVtIxJCRw6fUR42lYMVZuUMK7n8eMz4Uh5clckdBjEpLhn/gEBZo7hDJnJcwdKLKQjg== + version "3.0.1" + resolved "https://registry.yarnpkg.com/default-require-extensions/-/default-require-extensions-3.0.1.tgz#bfae00feeaeada68c2ae256c62540f60b80625bd" + integrity sha512-eXTJmRbm2TIt9MgWTsOH1wEuhew6XGZcMeGKCtLedIg/NCsg1iBePXkceTdK4Fii7pzmN9tGsZhKzZ4h7O/fxw== dependencies: strip-bom "^4.0.0" +default-user-agent@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/default-user-agent/-/default-user-agent-1.0.0.tgz#16c46efdcaba3edc45f24f2bd4868b01b7c2adc6" + integrity sha512-bDF7bg6OSNcSwFWPu4zYKpVkJZQYVrAANMYB8bc9Szem1D0yKdm4sa/rOCs2aC9+2GMqQ7KnwtZRvDhmLF0dXw== + dependencies: + os-name "~1.0.3" + defaults@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/defaults/-/defaults-1.0.3.tgz#c656051e9817d9ff08ed881477f3fe4019f3ef7d" - integrity sha1-xlYFHpgX2f8I7YgUd/P+QBnz730= + version "1.0.4" + resolved "https://registry.yarnpkg.com/defaults/-/defaults-1.0.4.tgz#b0b02062c1e2aa62ff5d9528f0f98baa90978d7a" + integrity sha512-eFuaLoy/Rxalv2kr+lqMlUnrDWV+3j4pljOIJgLIhI058IQfWJ7vXhyEIHu+HtC738klGALYxOKDO0bQP3tg8A== dependencies: clone "^1.0.2" -define-properties@^1.1.2, define-properties@^1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.3.tgz#cf88da6cbee26fe6db7094f61d870cbd84cee9f1" - integrity sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ== +define-properties@^1.1.2, define-properties@^1.1.3, define-properties@^1.1.4, define-properties@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.2.0.tgz#52988570670c9eacedd8064f4a990f2405849bd5" + integrity sha512-xvqAVKGfT1+UAvPwKTVw/njhdQ8ZhXK4lI0bCIuCMrp2up9nPnaDftrLtmpTazqd1o+UY4zgzU+avtMbDP+ldA== dependencies: - object-keys "^1.0.12" + has-property-descriptors "^1.0.0" + object-keys "^1.1.1" + +degenerator@^3.0.2: + version "3.0.4" + resolved "https://registry.yarnpkg.com/degenerator/-/degenerator-3.0.4.tgz#07ccf95bc11044a37a6efc2f66029fb636e31f24" + integrity sha512-Z66uPeBfHZAHVmue3HPfyKu2Q0rC2cRxbTOsvmU/po5fvvcx27W4mIu9n0PUlQih4oUYvcG1BsbtVv8x7KDOSw== + dependencies: + ast-types "^0.13.2" + escodegen "^1.8.1" + esprima "^4.0.0" + vm2 "^3.9.17" del@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/del/-/del-6.0.0.tgz#0b40d0332cea743f1614f818be4feb717714c952" - integrity sha512-1shh9DQ23L16oXSZKB2JxpL7iMy2E0S9d517ptA1P8iw0alkPtQcrKH7ru31rYtKwF499HkTu+DRzq3TCKDFRQ== + version "6.1.1" + resolved "https://registry.yarnpkg.com/del/-/del-6.1.1.tgz#3b70314f1ec0aa325c6b14eb36b95786671edb7a" + integrity sha512-ua8BhapfP0JUJKC/zV9yHHDW/rDoDxP4Zhn3AkA6/xT6gY7jYXJiaeyBZznYVujhZZET+UgcbZiQ7sN3WqcImg== dependencies: globby "^11.0.1" graceful-fs "^4.2.4" @@ -2583,29 +2955,19 @@ delay@^5.0.0: delayed-stream@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" - integrity sha1-3zrhmayt+31ECqrgsp4icrJOxhk= + integrity sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ== delegates@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/delegates/-/delegates-1.0.0.tgz#84c6e159b81904fdca59a0ef44cd870d31250f9a" - integrity sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o= - -denque@^1.5.0: - version "1.5.1" - resolved "https://registry.yarnpkg.com/denque/-/denque-1.5.1.tgz#07f670e29c9a78f8faecb2566a1e2c11929c5cbf" - integrity sha512-XwE+iZ4D6ZUB7mfYRMb5wByE8L74HCn30FBN7sWnXksWc1LO1bPDl67pBR9o/kC4z/xSNAwkMYcGgqDV3BE3Hw== + integrity sha512-bd2L678uiWATM6m5Z1VzNCErI3jiGzt6HGY8OVICs40JQq/HALfbyNJmp0UDakEY4pMMaN0Ly5om/B1VI/+xfQ== denque@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/denque/-/denque-2.0.1.tgz#bcef4c1b80dc32efe97515744f21a4229ab8934a" - integrity sha512-tfiWc6BQLXNLpNiR5iGd0Ocu3P3VpxfzFiqubLgMfhfOw9WyvgJBd46CClNn9k3qfbjvT//0cf7AlYRX/OslMQ== - -depd@^1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.2.tgz#9bcd52e14c097763e749b274c4346ed2e560b5a9" - integrity sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak= + version "2.1.0" + resolved "https://registry.yarnpkg.com/denque/-/denque-2.1.0.tgz#e93e1a6569fb5e66f16a3c2a2964617d349d6ab1" + integrity sha512-HVQE3AAb/pxF8fQAoiqpvg9i3evqug3hoiwakOyZAwJm+6vZehbkYXZ0l4JxS+I3QxM97v5aaRNhj8v5oBhekw== -depd@^2.0.0: +depd@2.0.0, depd@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/depd/-/depd-2.0.0.tgz#b696163cc757560d09cf22cc8fad1571b79e76df" integrity sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw== @@ -2615,10 +2977,15 @@ deprecation@^2.0.0, deprecation@^2.3.1: resolved "https://registry.yarnpkg.com/deprecation/-/deprecation-2.3.1.tgz#6368cbdb40abf3373b525ac87e4a260c3a700919" integrity sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ== +destroy@^1.0.4: + version "1.2.0" + resolved "https://registry.yarnpkg.com/destroy/-/destroy-1.2.0.tgz#4803735509ad8be552934c67df614f94e66fa015" + integrity sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg== + detect-indent@^3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/detect-indent/-/detect-indent-3.0.1.tgz#9dc5e5ddbceef8325764b9451b02bc6d54084f75" - integrity sha1-ncXl3bzu+DJXZLlFGwK8bVQIT3U= + integrity sha512-xo3WP66SNbr1Eim85s/qyH0ZL8PQUwp86HWm0S1l8WnJ/zjT6T3w1nwNA0yOZeuvOemupEYvpvF6BIdYRuERJQ== dependencies: get-stdin "^4.0.1" minimist "^1.1.0" @@ -2627,14 +2994,19 @@ detect-indent@^3.0.1: detect-indent@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/detect-indent/-/detect-indent-4.0.0.tgz#f76d064352cdf43a1cb6ce619c4ee3a9475de208" - integrity sha1-920GQ1LN9Docts5hnE7jqUdd4gg= + integrity sha512-BDKtmHlOzwI7iRuEkhzsnPoi5ypEhWAJB5RvHWe1kMr06js3uK5B3734i3ui5Yd+wOJV1cpE4JnivPD283GU/A== dependencies: repeating "^2.0.0" +detect-libc@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-2.0.1.tgz#e1897aa88fa6ad197862937fbc0441ef352ee0cd" + integrity sha512-463v3ZeIrcWtdgIg6vI6XUncguvr2TnGl4SzDXinkt9mSLpBJKXT3mW6xT3VQdDN11+WVs29pgvivTc4Lp8v+w== + dezalgo@^1.0.0: - version "1.0.3" - resolved "https://registry.yarnpkg.com/dezalgo/-/dezalgo-1.0.3.tgz#7f742de066fc748bc8db820569dddce49bf0d456" - integrity sha1-f3Qt4Gb8dIvI24IFad3c5Jvw1FY= + version "1.0.4" + resolved "https://registry.yarnpkg.com/dezalgo/-/dezalgo-1.0.4.tgz#751235260469084c132157dfa857f386d4c33d81" + integrity sha512-rXSP0bf+5n0Qonsb+SVVfNfIsimO4HEtmnIpPHY8Q1UCzKlQrDMfdobr8nJOOsRgWCyMRqeSBQzmWUMq7zvVig== dependencies: asap "^2.0.0" wrappy "1" @@ -2650,9 +3022,14 @@ diff@^4.0.1: integrity sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A== diff@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/diff/-/diff-5.0.0.tgz#7ed6ad76d859d030787ec35855f5b1daf31d852b" - integrity sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w== + version "5.1.0" + resolved "https://registry.yarnpkg.com/diff/-/diff-5.1.0.tgz#bc52d298c5ea8df9194800224445ed43ffc87e40" + integrity sha512-D+mk+qE8VC/PAUrlAU34N+VfXev0ghe5ywmpqrawphmVZc1bEfn56uo9qpyGp1p4xpzOHkSW4ztBd6L7Xx4ACw== + +digest-header@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/digest-header/-/digest-header-1.1.0.tgz#e16ab6cf4545bc4eea878c8c35acd1b89664d800" + integrity sha512-glXVh42vz40yZb9Cq2oMOt70FIoWiv+vxNvdKdU8CwjLad25qHM3trLxhl9bVjdr6WaslIXhWpn0NO8T/67Qjg== dir-glob@^3.0.0, dir-glob@^3.0.1: version "3.0.1" @@ -2676,14 +3053,14 @@ dom-serializer@0: domelementtype "^2.0.1" entities "^2.0.0" -dom-serializer@^1.0.1, dom-serializer@^1.3.2: - version "1.3.2" - resolved "https://registry.yarnpkg.com/dom-serializer/-/dom-serializer-1.3.2.tgz#6206437d32ceefaec7161803230c7a20bc1b4d91" - integrity sha512-5c54Bk5Dw4qAxNOI1pFEizPSjVsx5+bpJKmL2kPn8JhBUq2q09tTCa3mjijun2NfK78NMouDYNMBkOrPZiS+ig== +dom-serializer@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/dom-serializer/-/dom-serializer-2.0.0.tgz#e41b802e1eedf9f6cae183ce5e622d789d7d8e53" + integrity sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg== dependencies: - domelementtype "^2.0.1" - domhandler "^4.2.0" - entities "^2.0.0" + domelementtype "^2.3.0" + domhandler "^5.0.2" + entities "^4.2.0" dom-serializer@~0.1.0: version "0.1.1" @@ -2698,15 +3075,15 @@ domelementtype@1, domelementtype@^1.3.0, domelementtype@^1.3.1: resolved "https://registry.yarnpkg.com/domelementtype/-/domelementtype-1.3.1.tgz#d048c44b37b0d10a7f2a3d5fee3f4333d790481f" integrity sha512-BSKB+TSpMpFI/HOxCNr1O8aMOTZ8hT3pM3GQ0w/mWRmkhEDSFJkkyzz4XQsBV44BChwGkrDfMyjVD0eA2aFV3w== -domelementtype@^2.0.1, domelementtype@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/domelementtype/-/domelementtype-2.2.0.tgz#9a0b6c2782ed6a1c7323d42267183df9bd8b1d57" - integrity sha512-DtBMo82pv1dFtUmHyr48beiuq792Sxohr+8Hm9zoxklYPfa6n0Z3Byjj2IV7bmr2IyqClnqEQhfgHJJ5QF0R5A== +domelementtype@^2.0.1, domelementtype@^2.3.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/domelementtype/-/domelementtype-2.3.0.tgz#5c45e8e869952626331d7aab326d01daf65d589d" + integrity sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw== domhandler@2.3: version "2.3.0" resolved "https://registry.yarnpkg.com/domhandler/-/domhandler-2.3.0.tgz#2de59a0822d5027fabff6f032c2b25a2a8abe738" - integrity sha1-LeWaCCLVAn+r/28DLCsloqir5zg= + integrity sha512-q9bUwjfp7Eif8jWxxxPSykdRZAb6GkguBGSgvvCrhI9wB71W2K/Kvv4E61CF/mcCfnVJDeDWx/Vb/uAqbDj6UQ== dependencies: domelementtype "1" @@ -2717,17 +3094,17 @@ domhandler@^2.3.0: dependencies: domelementtype "1" -domhandler@^4.0.0, domhandler@^4.2.0: - version "4.2.2" - resolved "https://registry.yarnpkg.com/domhandler/-/domhandler-4.2.2.tgz#e825d721d19a86b8c201a35264e226c678ee755f" - integrity sha512-PzE9aBMsdZO8TK4BnuJwH0QT41wgMbRzuZrHUcpYncEjmQazq8QEaBWgLG7ZyC/DAZKEgglpIA6j4Qn/HmxS3w== +domhandler@^5.0.2, domhandler@^5.0.3: + version "5.0.3" + resolved "https://registry.yarnpkg.com/domhandler/-/domhandler-5.0.3.tgz#cc385f7f751f1d1fc650c21374804254538c7d31" + integrity sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w== dependencies: - domelementtype "^2.2.0" + domelementtype "^2.3.0" domutils@1.5, domutils@1.5.1: version "1.5.1" resolved "https://registry.yarnpkg.com/domutils/-/domutils-1.5.1.tgz#dcd8488a26f563d61079e48c9f7b7e32373682cf" - integrity sha1-3NhIiib1Y9YQeeSMn3t+Mjc2gs8= + integrity sha512-gSu5Oi/I+3wDENBsOWBiRK1eoGxcywYSqg3rR960/+EfY0CF4EX1VPkgHOZ3WiS/Jg2DtliF6BhWcHlfpYUcGw== dependencies: dom-serializer "0" domelementtype "1" @@ -2740,14 +3117,14 @@ domutils@^1.5.1: dom-serializer "0" domelementtype "1" -domutils@^2.5.2, domutils@^2.6.0, domutils@^2.7.0: - version "2.8.0" - resolved "https://registry.yarnpkg.com/domutils/-/domutils-2.8.0.tgz#4437def5db6e2d1f5d6ee859bd95ca7d02048135" - integrity sha512-w96Cjofp72M5IIhpjgobBimYEfoPjx1Vx0BSX9P30WBdZW2WIKU0T1Bd0kz2eNZ9ikjKgHbEyKx8BB6H1L3h3A== +domutils@^3.0.1: + version "3.1.0" + resolved "https://registry.yarnpkg.com/domutils/-/domutils-3.1.0.tgz#c47f551278d3dc4b0b1ab8cbb42d751a6f0d824e" + integrity sha512-H78uMmQtI2AhgDJjWeQmHwJJ2bLPD3GMmO7Zja/ZZh84wkm+4ut+IUnUdRa8uCGX88DiVx1j6FRe1XfxEgjEZA== dependencies: - dom-serializer "^1.0.1" - domelementtype "^2.2.0" - domhandler "^4.2.0" + dom-serializer "^2.0.0" + domelementtype "^2.3.0" + domhandler "^5.0.3" dot-prop@^5.1.0: version "5.3.0" @@ -2756,15 +3133,15 @@ dot-prop@^5.1.0: dependencies: is-obj "^2.0.0" -dottie@^2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/dottie/-/dottie-2.0.2.tgz#cc91c0726ce3a054ebf11c55fbc92a7f266dd154" - integrity sha512-fmrwR04lsniq/uSr8yikThDTrM7epXHBAAjH9TbeH3rEA8tdCO7mRzB9hdmdGyJCxF8KERo9CITcm3kGuoyMhg== +dottie@^2.0.6: + version "2.0.6" + resolved "https://registry.yarnpkg.com/dottie/-/dottie-2.0.6.tgz#34564ebfc6ec5e5772272d466424ad5b696484d4" + integrity sha512-iGCHkfUc5kFekGiqhe8B/mdaurD+lakO9txNnTvKtA6PISrw86LgqHvRzWYPyoE2Ph5aMIrCw9/uko6XHTKCwA== duplexer2@~0.1.0, duplexer2@~0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/duplexer2/-/duplexer2-0.1.4.tgz#8b12dab878c0d69e3e7891051662a32fc6bddcc1" - integrity sha1-ixLauHjA1p4+eJEFFmKjL8a93ME= + integrity sha512-asLFVfWWtJ90ZyOUHMqk7/S2w2guQKxUI2itj3d92ADHhxUSbCMGi1f1cBcJ7xM1To+pE/Khbwo1yuNbMEPKeA== dependencies: readable-stream "^2.0.2" @@ -2778,25 +3155,45 @@ duplexify@^3.6.0: readable-stream "^2.0.0" stream-shift "^1.0.0" +duplexify@^4.0.0: + version "4.1.2" + resolved "https://registry.yarnpkg.com/duplexify/-/duplexify-4.1.2.tgz#18b4f8d28289132fa0b9573c898d9f903f81c7b0" + integrity sha512-fz3OjcNCHmRP12MJoZMPglx8m4rrFP8rovnk4vT8Fs+aonZoCwGg10dSsQsfP/E62eZcPTMSMP6686fu9Qlqtw== + dependencies: + end-of-stream "^1.4.1" + inherits "^2.0.3" + readable-stream "^3.1.1" + stream-shift "^1.0.0" + +eastasianwidth@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/eastasianwidth/-/eastasianwidth-0.2.0.tgz#696ce2ec0aa0e6ea93a397ffcf24aa7840c827cb" + integrity sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA== + ecc-jsbn@~0.1.1: version "0.1.2" resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz#3a83a904e54353287874c564b7549386849a98c9" - integrity sha1-OoOpBOVDUyh4dMVkt1SThoSamMk= + integrity sha512-eh9O+hwRHNbG4BLTjEl3nw044CkGm5X6LoaCf7LPp7UU8Qrt47JYNi6nPX8xjW97TKGKm1ouctg0QSpZe9qrnw== dependencies: jsbn "~0.1.0" safer-buffer "^2.1.0" -ecdsa-sig-formatter@1.0.11: +ecdsa-sig-formatter@1.0.11, ecdsa-sig-formatter@^1.0.11: version "1.0.11" resolved "https://registry.yarnpkg.com/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz#ae0f0fa2d85045ef14a817daa3ce9acd0489e5bf" integrity sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ== dependencies: safe-buffer "^5.0.1" -electron-to-chromium@^1.3.896: - version "1.4.5" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.5.tgz#912e8fd1645edee2f0f212558f40916eb538b1f9" - integrity sha512-YKaB+t8ul5crdh6OeqT2qXdxJGI0fAYb6/X8pDIyye+c3a7ndOCk5gVeKX+ABwivCGNS56vOAif3TN0qJMpEHw== +ee-first@~1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" + integrity sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow== + +electron-to-chromium@^1.4.431: + version "1.4.432" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.432.tgz#154a69d5ead974347f534aea4d28b03c7149fd7b" + integrity sha512-yz3U/khQgAFT2HURJA3/F4fKIyO2r5eK09BQzBZFd6BvBSSaRuzKc2ZNBHtJcO75/EKiRYbVYJZ2RB0P4BuD2g== emitter-listener@^1.0.1: version "1.1.2" @@ -2832,24 +3229,22 @@ encoding@^0.1.12: dependencies: iconv-lite "^0.6.2" -end-of-stream@^1.0.0, end-of-stream@^1.1.0: +end-of-stream@^1.0.0, end-of-stream@^1.1.0, end-of-stream@^1.4.1: version "1.4.4" resolved "https://registry.yarnpkg.com/end-of-stream/-/end-of-stream-1.4.4.tgz#5ae64a5f45057baf3626ec14da0ca5e4b2431eb0" integrity sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q== dependencies: once "^1.4.0" -enquirer@^2.3.5: - version "2.3.6" - resolved "https://registry.yarnpkg.com/enquirer/-/enquirer-2.3.6.tgz#2a7fe5dd634a1e4125a975ec994ff5456dc3734d" - integrity sha512-yjNnPr315/FjS4zIsUxYguYUPP2e1NK4d7E7ZOLiyYCcbFBiTMyID+2wvm2w6+pZ/odMA7cRkjhsPbltwBOrLg== - dependencies: - ansi-colors "^4.1.1" +ent@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/ent/-/ent-2.2.0.tgz#e964219325a21d05f44466a2f686ed6ce5f5dd1d" + integrity sha512-GHrMyVZQWvTIdDtpiEXdHZnFQKzeO09apj8Cbl4pKWy4i0Oprcq17usfDt5aO63swf0JOeMWjWQE/LzgSRuWpA== entities@1.0: version "1.0.0" resolved "https://registry.yarnpkg.com/entities/-/entities-1.0.0.tgz#b2987aa3821347fcde642b24fdfc9e4fb712bf26" - integrity sha1-sph6o4ITR/zeZCsk/fyeT7cSvyY= + integrity sha512-LbLqfXgJMmy81t+7c14mnulFHJ170cM6E+0vMXR9k/ZiZwgX8i5pNgjTCX3SO4VeUsFLV+8InixoretwU+MjBQ== entities@^1.1.1, entities@~1.1.1: version "1.1.2" @@ -2861,15 +3256,20 @@ entities@^2.0.0: resolved "https://registry.yarnpkg.com/entities/-/entities-2.2.0.tgz#098dc90ebb83d8dffa089d55256b351d34c4da55" integrity sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A== +entities@^4.2.0, entities@^4.4.0: + version "4.5.0" + resolved "https://registry.yarnpkg.com/entities/-/entities-4.5.0.tgz#5d268ea5e7113ec74c4d033b79ea5a35a488fb48" + integrity sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw== + entities@~2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/entities/-/entities-2.1.0.tgz#992d3129cf7df6870b96c57858c249a120f8b8b5" integrity sha512-hCx1oky9PFrJ611mf0ifBLBRW8lUUVRlFolb5gWRfIELabBlbp9xZvrqZLZAs+NxFnbfQoeGd8wDkygjg7U85w== env-ci@^5.0.0: - version "5.4.1" - resolved "https://registry.yarnpkg.com/env-ci/-/env-ci-5.4.1.tgz#814387ddd6857b37472ef612361f34d720c29a18" - integrity sha512-xyuCtyFZLpnW5aH0JstETKTSMwHHQX4m42juzEZzvbUCJX7RiPVlhASKM0f/cJ4vvI/+txMkZ7F5To6dCdPYhg== + version "5.5.0" + resolved "https://registry.yarnpkg.com/env-ci/-/env-ci-5.5.0.tgz#43364e3554d261a586dec707bc32be81112b545f" + integrity sha512-o0JdWIbOLP+WJKIUt36hz1ImQQFuN92nhsfTkHHap+J8CiI8WgGpH/a9jEGHh4/TU5BUUGjlnKXNoDb57+ne+A== dependencies: execa "^5.0.0" fromentries "^1.3.2" @@ -2892,31 +3292,59 @@ error-ex@^1.3.1: dependencies: is-arrayish "^0.2.1" -es-abstract@^1.19.1: - version "1.19.1" - resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.19.1.tgz#d4885796876916959de78edaa0df456627115ec3" - integrity sha512-2vJ6tjA/UfqLm2MPs7jxVybLoB8i1t1Jd9R3kISld20sIxPcTbLuggQOUxeWeAvIUkduv/CfMjuh4WmiXr2v9w== +es-abstract@^1.19.0, es-abstract@^1.20.4, es-abstract@^1.21.2: + version "1.21.2" + resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.21.2.tgz#a56b9695322c8a185dc25975aa3b8ec31d0e7eff" + integrity sha512-y/B5POM2iBnIxCiernH1G7rC9qQoM77lLIMQLuob0zhp8C56Po81+2Nj0WFKnd0pNReDTnkYryc+zhOzpEIROg== dependencies: + array-buffer-byte-length "^1.0.0" + available-typed-arrays "^1.0.5" call-bind "^1.0.2" + es-set-tostringtag "^2.0.1" es-to-primitive "^1.2.1" - function-bind "^1.1.1" - get-intrinsic "^1.1.1" + function.prototype.name "^1.1.5" + get-intrinsic "^1.2.0" get-symbol-description "^1.0.0" + globalthis "^1.0.3" + gopd "^1.0.1" has "^1.0.3" - has-symbols "^1.0.2" - internal-slot "^1.0.3" - is-callable "^1.2.4" - is-negative-zero "^2.0.1" + has-property-descriptors "^1.0.0" + has-proto "^1.0.1" + has-symbols "^1.0.3" + internal-slot "^1.0.5" + is-array-buffer "^3.0.2" + is-callable "^1.2.7" + is-negative-zero "^2.0.2" is-regex "^1.1.4" - is-shared-array-buffer "^1.0.1" + is-shared-array-buffer "^1.0.2" is-string "^1.0.7" - is-weakref "^1.0.1" - object-inspect "^1.11.0" + is-typed-array "^1.1.10" + is-weakref "^1.0.2" + object-inspect "^1.12.3" object-keys "^1.1.1" - object.assign "^4.1.2" - string.prototype.trimend "^1.0.4" - string.prototype.trimstart "^1.0.4" - unbox-primitive "^1.0.1" + object.assign "^4.1.4" + regexp.prototype.flags "^1.4.3" + safe-regex-test "^1.0.0" + string.prototype.trim "^1.2.7" + string.prototype.trimend "^1.0.6" + string.prototype.trimstart "^1.0.6" + typed-array-length "^1.0.4" + unbox-primitive "^1.0.2" + which-typed-array "^1.1.9" + +es-array-method-boxes-properly@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/es-array-method-boxes-properly/-/es-array-method-boxes-properly-1.0.0.tgz#873f3e84418de4ee19c5be752990b2e44718d09e" + integrity sha512-wd6JXUmyHmt8T5a2xreUwKcGPq6f1f+WwIJkijUqiGcJz1qqnZgP6XIK+QyIWU5lT7imeNxUll48bziG+TSYcA== + +es-set-tostringtag@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/es-set-tostringtag/-/es-set-tostringtag-2.0.1.tgz#338d502f6f674301d710b80c8592de8a15f09cd8" + integrity sha512-g3OMbtlwY3QewlqAiMLI47KywjWZoEytKr8pf6iTC8uJq5bIAH52Z9pnQ8pVL6whrCto53JZDuUIsifGeLorTg== + dependencies: + get-intrinsic "^1.1.3" + has "^1.0.3" + has-tostringtag "^1.0.0" es-to-primitive@^1.2.1: version "1.2.1" @@ -2932,18 +3360,6 @@ es6-error@^4.0.1: resolved "https://registry.yarnpkg.com/es6-error/-/es6-error-4.1.1.tgz#9e3af407459deed47e9a91f9b885a84eb05c561d" integrity sha512-Um/+FxMr9CISWh0bi5Zv0iOD+4cFh5qLeks1qhAopKVAJw3drgKbKySikp7wGhDL0HPeaja0P5ULZrxLkniUVg== -es6-promise@^4.0.3: - version "4.2.8" - resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-4.2.8.tgz#4eb21594c972bc40553d276e510539143db53e0a" - integrity sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w== - -es6-promisify@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/es6-promisify/-/es6-promisify-5.0.0.tgz#5109d62f3e56ea967c4b63505aef08291c8a5203" - integrity sha1-UQnWLz5W6pZ8S2NQWu8IKRyKUgM= - dependencies: - es6-promise "^4.0.3" - esbuild-android-arm64@0.14.3: version "0.14.3" resolved "https://registry.yarnpkg.com/esbuild-android-arm64/-/esbuild-android-arm64-0.14.3.tgz#f0fc0a892dd6f2f42baf68f9ac24c9bfcfdaba20" @@ -3057,22 +3473,22 @@ escalade@^3.1.1: resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40" integrity sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw== -escape-html@1.0.3: +escape-html@1.0.3, escape-html@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988" - integrity sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg= + integrity sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow== escape-string-regexp@1.0.5, escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" - integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= + integrity sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg== escape-string-regexp@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34" integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA== -escodegen@^1.6.1: +escodegen@^1.6.1, escodegen@^1.8.1: version "1.14.3" resolved "https://registry.yarnpkg.com/escodegen/-/escodegen-1.14.3.tgz#4e7b81fba61581dc97582ed78cab7f0e8d63f503" integrity sha512-qFcX0XJkdg+PB3xjZZG/wKSuT1PnQWx57+TVSjIMmILd2yC/6ByYElPwJnslDsuWuSAp4AwJGumarAAmJch5Kw== @@ -3087,7 +3503,7 @@ escodegen@^1.6.1: esdoc-accessor-plugin@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/esdoc-accessor-plugin/-/esdoc-accessor-plugin-1.0.0.tgz#791ba4872e6c403515ce749b1348d6f0293ad9eb" - integrity sha1-eRukhy5sQDUVznSbE0jW8Ck62es= + integrity sha512-s9mNmdHGOyQOaOUXNHPz38Y8clm6dR8/fa9DPGzuRYmIN+Lv0NVnpPAcHb5XrfC23/Mz3IUwD8h798f5Ai4rbA== esdoc-brand-plugin@^1.0.0: version "1.0.1" @@ -3099,24 +3515,24 @@ esdoc-brand-plugin@^1.0.0: esdoc-coverage-plugin@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/esdoc-coverage-plugin/-/esdoc-coverage-plugin-1.1.0.tgz#3869869cd7f87891f972625787695a299aece45c" - integrity sha1-OGmGnNf4eJH5cmJXh2laKZrs5Fw= + integrity sha512-M+94/Y+eoM08V3teiJIYpJ5HF13jH4cC9LQZrjmA91mlAqCHtNzelHF9ZdWofoOFYFRNpllFsXTFsJgwVa000A== esdoc-ecmascript-proposal-plugin@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/esdoc-ecmascript-proposal-plugin/-/esdoc-ecmascript-proposal-plugin-1.0.0.tgz#390dc5656ba8a2830e39dba3570d79138df2ffd9" - integrity sha1-OQ3FZWuoooMOOdujVw15E43y/9k= + integrity sha512-PuaU/O8d+Sb0J6qQdyhmy74h/2cp/2kqsvPuoCiK+50Rw54nlGqXxvWNaaNikS5qntE0FfssnwZtUPa6q4RiXg== esdoc-external-ecmascript-plugin@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/esdoc-external-ecmascript-plugin/-/esdoc-external-ecmascript-plugin-1.0.0.tgz#78f565d4a0c5185ac63152614dce1fe1a86688db" - integrity sha1-ePVl1KDFGFrGMVJhTc4f4ahmiNs= + integrity sha512-ASj7lhfZpzI01xd4XqB4HN+zNKwnhdaN/OIp/CTnUiLIErMOeUqzV9z/dcnUUeDY3NSwPCH1pUNATVwznspmHw== dependencies: fs-extra "1.0.0" esdoc-inject-style-plugin@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/esdoc-inject-style-plugin/-/esdoc-inject-style-plugin-1.0.0.tgz#a13597368bb9fb89c365e066495caf97a4decbb1" - integrity sha1-oTWXNou5+4nDZeBmSVyvl6Tey7E= + integrity sha512-LqSGr3YKe+vY2u6TCp9K+EEt97S78KjdJUz5PXyitHkp4nGXRSZq2ftEQJioF/WtTeGYWeQLzNAM9LihIlisqg== dependencies: cheerio "0.22.0" fs-extra "1.0.0" @@ -3124,12 +3540,12 @@ esdoc-inject-style-plugin@^1.0.0: esdoc-integrate-manual-plugin@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/esdoc-integrate-manual-plugin/-/esdoc-integrate-manual-plugin-1.0.0.tgz#1854a6aa1c081035d7c8c51e3bdd4fb65aa4711c" - integrity sha1-GFSmqhwIEDXXyMUeO91PtlqkcRw= + integrity sha512-+XcW8xRtuFVFadoVLIOj6kzX4uqtAEB5UoR7AA5g46StxLghZZ6RLrRQSERUTIc3VX9v47lOMKEaQvQfanv3+A== esdoc-integrate-test-plugin@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/esdoc-integrate-test-plugin/-/esdoc-integrate-test-plugin-1.0.0.tgz#e2d0d00090f7f0c35e5d2f2c033327a79e53e409" - integrity sha1-4tDQAJD38MNeXS8sAzMnp55T5Ak= + integrity sha512-WRbkbnbWnzF4RdmcoJLYZvhod7jLVUYWU2ZAojYjK+GiqSgy2yjGi7PxckeGF0LtpCuqqKat3PRdUNEMo6Nf3A== esdoc-lint-plugin@^1.0.0: version "1.0.2" @@ -3152,7 +3568,7 @@ esdoc-publish-html-plugin@^1.0.0: esdoc-standard-plugin@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/esdoc-standard-plugin/-/esdoc-standard-plugin-1.0.0.tgz#661201cac7ef868924902446fdac1527253c5d4d" - integrity sha1-ZhIBysfvhokkkCRG/awVJyU8XU0= + integrity sha512-IDEG9NV/MF5Bi2TdKPqQ3GHfDkgqYhk2iyvBNX+XcNKYmXm9zxtXVS459WAmiTZuYpDLtDGbulQdJ1t4ud57mw== dependencies: esdoc-accessor-plugin "^1.0.0" esdoc-brand-plugin "^1.0.0" @@ -3174,12 +3590,12 @@ esdoc-type-inference-plugin@^1.0.0: esdoc-undocumented-identifier-plugin@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/esdoc-undocumented-identifier-plugin/-/esdoc-undocumented-identifier-plugin-1.0.0.tgz#82e05d371c32d12871140f1d5c81ec99fd9cc2c8" - integrity sha1-guBdNxwy0ShxFA8dXIHsmf2cwsg= + integrity sha512-T0hQc0ec1+pUJPDBoJ2SxEv7uX9VD7Q9+7UAGnDZ5R2l2JYa3WY7cawyqfbMHVtLgvqH0eMBpxdfRsQvAWzj4Q== esdoc-unexported-identifier-plugin@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/esdoc-unexported-identifier-plugin/-/esdoc-unexported-identifier-plugin-1.0.0.tgz#1f9874c6a7c2bebf9ad397c3ceb75c9c69dabab1" - integrity sha1-H5h0xqfCvr+a05fDzrdcnGnaurE= + integrity sha512-PRdMLWHWdy9PwxzYDG2clhta9H7yHDpGCBIHxSw9R7TFK6ZYuPK1fUbURIzIxcdQhzt1PX9Cn6Cak2824K0+Ng== esdoc@^1.1.0: version "1.1.0" @@ -3199,16 +3615,15 @@ esdoc@^1.1.0: taffydb "2.7.3" eslint-plugin-jsdoc@^37.4.0: - version "37.4.0" - resolved "https://registry.yarnpkg.com/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-37.4.0.tgz#6e6eade5494150a392365f63bbd2fb88caeb8d0c" - integrity sha512-XWKMMHFq7eUdC8XMzuQSskevJvlHTDSAJm/2qtEZ7+qhZTZ0YjeqWaUn7KGdrmxLNqtWwtJ67LdIPgrYUZ5EoA== + version "37.9.7" + resolved "https://registry.yarnpkg.com/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-37.9.7.tgz#ef46141aa2e5fcbb89adfa658eef8126435e9eac" + integrity sha512-8alON8yYcStY94o0HycU2zkLKQdcS+qhhOUNQpfONHHwvI99afbmfpYuPqf6PbLz5pLZldG3Te5I0RbAiTN42g== dependencies: - "@es-joy/jsdoccomment" "0.13.0" + "@es-joy/jsdoccomment" "~0.20.1" comment-parser "1.3.0" debug "^4.3.3" escape-string-regexp "^4.0.0" esquery "^1.4.0" - jsdoc-type-pratt-parser "^2.0.0" regextras "^0.8.0" semver "^7.3.5" spdx-expression-parse "^3.0.1" @@ -3229,10 +3644,10 @@ eslint-scope@^5.1.1: esrecurse "^4.3.0" estraverse "^4.1.1" -eslint-scope@^7.1.0: - version "7.1.0" - resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-7.1.0.tgz#c1f6ea30ac583031f203d65c73e723b01298f153" - integrity sha512-aWwkhnS0qAXqNOgKOK0dJ2nvzEbhEvpy8OlJ9kZ0FeZnA6zpjv1/Vei+puGFFX7zkPCkHHXb7IDX3A+7yPrRWg== +eslint-scope@^7.2.0: + version "7.2.0" + resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-7.2.0.tgz#f21ebdafda02352f103634b96dd47d9f81ca117b" + integrity sha512-DYj5deGlHBfMt15J7rdtyKNq/Nqlv5KfU4iodrQ019XESsRnwXH9KAE0y3cwtUHDo2ob7CypAnCqefh6vioWRw== dependencies: esrecurse "^4.3.0" estraverse "^5.2.0" @@ -3249,73 +3664,74 @@ eslint-visitor-keys@^2.0.0: resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz#f65328259305927392c938ed44eb0a5c9b2bd303" integrity sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw== -eslint-visitor-keys@^3.0.0, eslint-visitor-keys@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.1.0.tgz#eee4acea891814cda67a7d8812d9647dd0179af2" - integrity sha512-yWJFpu4DtjsWKkt5GeNBBuZMlNcYVs6vRCLoCVEJrTjaSB6LC98gFipNK/erM2Heg/E8mIK+hXG/pJMLK+eRZA== +eslint-visitor-keys@^3.3.0, eslint-visitor-keys@^3.4.1: + version "3.4.1" + resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.4.1.tgz#c22c48f48942d08ca824cc526211ae400478a994" + integrity sha512-pZnmmLwYzf+kWaM/Qgrvpen51upAktaaiI01nsJD/Yr3lMOdNtq0cxkrrg16w64VtisN6okbs7Q8AfGqj4c9fA== eslint@^8.5.0: - version "8.5.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.5.0.tgz#ddd2c1afd8f412036f87ae2a063d2aa296d3175f" - integrity sha512-tVGSkgNbOfiHyVte8bCM8OmX+xG9PzVG/B4UCF60zx7j61WIVY/AqJECDgpLD4DbbESD0e174gOg3ZlrX15GDg== - dependencies: - "@eslint/eslintrc" "^1.0.5" - "@humanwhocodes/config-array" "^0.9.2" + version "8.42.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.42.0.tgz#7bebdc3a55f9ed7167251fe7259f75219cade291" + integrity sha512-ulg9Ms6E1WPf67PHaEY4/6E2tEn5/f7FXGzr3t9cBMugOmf1INYvuUwwh1aXQN4MfJ6a5K2iNwP3w4AColvI9A== + dependencies: + "@eslint-community/eslint-utils" "^4.2.0" + "@eslint-community/regexpp" "^4.4.0" + "@eslint/eslintrc" "^2.0.3" + "@eslint/js" "8.42.0" + "@humanwhocodes/config-array" "^0.11.10" + "@humanwhocodes/module-importer" "^1.0.1" + "@nodelib/fs.walk" "^1.2.8" ajv "^6.10.0" chalk "^4.0.0" cross-spawn "^7.0.2" debug "^4.3.2" doctrine "^3.0.0" - enquirer "^2.3.5" escape-string-regexp "^4.0.0" - eslint-scope "^7.1.0" - eslint-utils "^3.0.0" - eslint-visitor-keys "^3.1.0" - espree "^9.2.0" - esquery "^1.4.0" + eslint-scope "^7.2.0" + eslint-visitor-keys "^3.4.1" + espree "^9.5.2" + esquery "^1.4.2" esutils "^2.0.2" fast-deep-equal "^3.1.3" file-entry-cache "^6.0.1" - functional-red-black-tree "^1.0.1" - glob-parent "^6.0.1" - globals "^13.6.0" - ignore "^4.0.6" + find-up "^5.0.0" + glob-parent "^6.0.2" + globals "^13.19.0" + graphemer "^1.4.0" + ignore "^5.2.0" import-fresh "^3.0.0" imurmurhash "^0.1.4" is-glob "^4.0.0" + is-path-inside "^3.0.3" js-yaml "^4.1.0" json-stable-stringify-without-jsonify "^1.0.1" levn "^0.4.1" lodash.merge "^4.6.2" - minimatch "^3.0.4" + minimatch "^3.1.2" natural-compare "^1.4.0" optionator "^0.9.1" - progress "^2.0.0" - regexpp "^3.2.0" - semver "^7.2.1" strip-ansi "^6.0.1" strip-json-comments "^3.1.0" text-table "^0.2.0" - v8-compile-cache "^2.0.3" -espree@^9.2.0: - version "9.2.0" - resolved "https://registry.yarnpkg.com/espree/-/espree-9.2.0.tgz#c50814e01611c2d0f8bd4daa83c369eabba80dbc" - integrity sha512-oP3utRkynpZWF/F2x/HZJ+AGtnIclaR7z1pYPxy7NYM2fSO6LgK/Rkny8anRSPK/VwEA1eqm2squui0T7ZMOBg== +espree@^9.5.2: + version "9.5.2" + resolved "https://registry.yarnpkg.com/espree/-/espree-9.5.2.tgz#e994e7dc33a082a7a82dceaf12883a829353215b" + integrity sha512-7OASN1Wma5fum5SrNhFMAMJxOUAbhyfQ8dQ//PJaJbNw0URTPWqIghHWt1MmAANKhHZIYOHruW4Kw4ruUWOdGw== dependencies: - acorn "^8.6.0" - acorn-jsx "^5.3.1" - eslint-visitor-keys "^3.1.0" + acorn "^8.8.0" + acorn-jsx "^5.3.2" + eslint-visitor-keys "^3.4.1" esprima@^4.0.0, esprima@^4.0.1, esprima@~4.0.0: version "4.0.1" resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== -esquery@^1.4.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.4.0.tgz#2148ffc38b82e8c7057dfed48425b3e61f0f24a5" - integrity sha512-cCDispWt5vHHtwMY2YrAQ4ibFkAL8RbH5YGBnZBc90MolvvfkkQcJro/aZiAQUlQ3qgrYS6D6v8Gc5G5CQsc9w== +esquery@^1.4.0, esquery@^1.4.2: + version "1.5.0" + resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.5.0.tgz#6ce17738de8577694edd7361c57182ac8cb0db0b" + integrity sha512-YQLXUplAwJgCydQ78IMJywZCceoqk1oH01OERdSAJc/7U2AylwjhSCLDEtqwg811idIS/9fIU5GjG73IgjKMVg== dependencies: estraverse "^5.1.0" @@ -3341,10 +3757,15 @@ esutils@^2.0.2: resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64" integrity sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g== +event-target-shim@^5.0.0: + version "5.0.1" + resolved "https://registry.yarnpkg.com/event-target-shim/-/event-target-shim-5.0.1.tgz#5d4d3ebdf9583d63a5333ce2deb7480ab2b05789" + integrity sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ== + events@1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/events/-/events-1.1.1.tgz#9ebdb7635ad099c70dcc4c2a1f5004288e8bd924" - integrity sha1-nr23Y1rQmccNzEwqH1AEKI6L2SQ= + integrity sha512-kEcvvCBByWXGnZy6JUlgAp2gBIUjfCAV6P6TgT1/aaQKcmuAEC4OZTV1I4EWQLz2gxZw76atuVyvHhTxvi0Flw== events@^3.0.0: version "3.3.0" @@ -3369,7 +3790,7 @@ execa@^5.0.0, execa@^5.1.1: expand-tilde@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/expand-tilde/-/expand-tilde-2.0.2.tgz#97e801aa052df02454de46b02bf621642cdc8502" - integrity sha1-l+gBqgUt8CRU3kawK/YhZCzchQI= + integrity sha512-A5EmesHW6rfnZ9ysHQjPdJRni0SRar0tjtG5MNtm9n5TUvsYU8oozprtRD4AqHxcZWWlVuAmQo2nWKfN9oyjTw== dependencies: homedir-polyfill "^1.0.1" @@ -3378,6 +3799,13 @@ expect-type@^0.12.0: resolved "https://registry.yarnpkg.com/expect-type/-/expect-type-0.12.0.tgz#133534b5e2561158c371e74af63fd8f18a9f3d42" integrity sha512-IHwziEOjpjXqxQhtOAD5zMiQpGztaEKM4Q8wnwoRN9NIFlnyNHNjRxKWv+18UqRfsqi6vVnZIYFU16ePf+HaqA== +extend-shallow@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/extend-shallow/-/extend-shallow-2.0.1.tgz#51af7d614ad9a9f610ea1bafbb989d6b1c56890f" + integrity sha512-zCnTtlxNoAiDc3gqY2aYAWFx7XWWiasuF2K8Me5WbN8otHKTUKBwjPtNpRs/rbUZm7KxWAaNj7P1a/p52GbVug== + dependencies: + is-extendable "^0.1.0" + extend@^3.0.0, extend@^3.0.2, extend@~3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.2.tgz#f8b1136b4071fbd8eb140aff858b1019ec2915fa" @@ -3386,7 +3814,7 @@ extend@^3.0.0, extend@^3.0.2, extend@~3.0.2: extsprintf@1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.3.0.tgz#96918440e3041a7a414f8c52e3c574eb3c3e1e05" - integrity sha1-lpGEQOMEGnpBT4xS48V06zw+HgU= + integrity sha512-11Ndz7Nv+mvAC1j0ktTa7fAb0vLyGGX+rMHNBYQviQDGU0Hw7lhctJANqbPhu9nV9/izT/IntTgZ7Im/9LJs9g== extsprintf@^1.2.0: version "1.4.1" @@ -3398,10 +3826,10 @@ fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3: resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== -fast-glob@^3.1.1, fast-glob@^3.2.7: - version "3.2.7" - resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.7.tgz#fd6cb7a2d7e9aa7a7846111e85a196d6b2f766a1" - integrity sha512-rYGMRwip6lUMvYD3BTScMwT1HtAs2d71SMv66Vrxs0IekGZEjhM0pcMfjQPnknBt2zeCwQMEupiN02ZP4DiT1Q== +fast-glob@^3.2.7, fast-glob@^3.2.9: + version "3.2.12" + resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.12.tgz#7f39ec99c2e6ab030337142da9e0c18f37afae80" + integrity sha512-DVj4CQIYYow0BlaelwK1pHl5n5cRSJfM60UA0zK891sVInoPri2Ekj7+e1CT3/3qxXenpI+nBBmQAcJPJgaj4w== dependencies: "@nodelib/fs.stat" "^2.0.2" "@nodelib/fs.walk" "^1.2.3" @@ -3417,29 +3845,41 @@ fast-json-stable-stringify@^2.0.0: fast-levenshtein@^2.0.6, fast-levenshtein@~2.0.6: version "2.0.6" resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917" - integrity sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc= + integrity sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw== + +fast-text-encoding@^1.0.0: + version "1.0.6" + resolved "https://registry.yarnpkg.com/fast-text-encoding/-/fast-text-encoding-1.0.6.tgz#0aa25f7f638222e3396d72bf936afcf1d42d6867" + integrity sha512-VhXlQgj9ioXCqGstD37E/HBeqEGV/qOD/kmbVG8h5xKBYvM1L3lR1Zn4555cQ8GkYbJa8aJSipLPndE1k6zK2w== + +fast-xml-parser@^4.1.3: + version "4.2.4" + resolved "https://registry.yarnpkg.com/fast-xml-parser/-/fast-xml-parser-4.2.4.tgz#6e846ede1e56ad9e5ef07d8720809edf0ed07e9b" + integrity sha512-fbfMDvgBNIdDJLdLOwacjFAPYt67tr31H9ZhWSm45CDAxvd0I6WTlSOUo7K2P/K5sA5JgMKG64PI3DMcaFdWpQ== + dependencies: + strnum "^1.0.5" fastest-levenshtein@^1.0.12: - version "1.0.12" - resolved "https://registry.yarnpkg.com/fastest-levenshtein/-/fastest-levenshtein-1.0.12.tgz#9990f7d3a88cc5a9ffd1f1745745251700d497e2" - integrity sha512-On2N+BpYJ15xIC974QNVuYGMOlEVt4s0EOI3wwMqOmK1fdDY+FN/zltPV8vosq4ad4c/gJ1KHScUn/6AWIgiow== + version "1.0.16" + resolved "https://registry.yarnpkg.com/fastest-levenshtein/-/fastest-levenshtein-1.0.16.tgz#210e61b6ff181de91ea9b3d1b84fdedd47e034e5" + integrity sha512-eRnCtTTtGZFpQCwhJiUOuxPQWRXVKYDn0b2PeHfXL6/Zi53SLAzAHfVhVWK2AryC/WH05kGfxhFIPvTF0SXQzg== fastq@^1.6.0: - version "1.13.0" - resolved "https://registry.yarnpkg.com/fastq/-/fastq-1.13.0.tgz#616760f88a7526bdfc596b7cab8c18938c36b98c" - integrity sha512-YpkpUnK8od0o1hmeSc7UUs/eB/vIPWJYjKck2QKIzAf71Vm1AAQ3EbuZB3g2JIy+pg+ERD0vqI79KyZiB2e2Nw== + version "1.15.0" + resolved "https://registry.yarnpkg.com/fastq/-/fastq-1.15.0.tgz#d04d07c6a2a68fe4599fea8d2e103a937fae6b3a" + integrity sha512-wBrocU2LCXXa+lWBt8RoIRD89Fi8OdABODa/kEnyeyjS5aZO5/GNvI5sEINADqP/h8M29UHTHUb53sUu5Ihqdw== dependencies: reusify "^1.0.4" fecha@^4.2.0: - version "4.2.1" - resolved "https://registry.yarnpkg.com/fecha/-/fecha-4.2.1.tgz#0a83ad8f86ef62a091e22bb5a039cd03d23eecce" - integrity sha512-MMMQ0ludy/nBs1/o0zVOiKTpG7qMbonKUzjJgQFEuvq6INZ1OraKPRAWkBq5vlKLOUMpmNYG1JoN3oDPUQ9m3Q== + version "4.2.3" + resolved "https://registry.yarnpkg.com/fecha/-/fecha-4.2.3.tgz#4d9ccdbc61e8629b259fdca67e65891448d569fd" + integrity sha512-OP2IUU6HeYKJi3i0z4A19kHMQoLVs4Hc+DPqqxI2h/DPZHTm/vjsfC6P0b4jCMy14XizLBqvndQ+UilD7707Jw== figures@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/figures/-/figures-2.0.0.tgz#3ab1a2d2a62c8bfb431a0c94cb797a2fce27c962" - integrity sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI= + integrity sha512-Oa2M9atig69ZkfwiApY8F2Yy+tzMbazyvqv21R0NsSC8floSOC09BbT1ITWAdoMGQvJ/aZnR1KMwdx9tvHnTNA== dependencies: escape-string-regexp "^1.0.5" @@ -3462,6 +3902,11 @@ file-uri-to-path@1.0.0: resolved "https://registry.yarnpkg.com/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz#553a7b8446ff6f684359c445f1e37a05dacc33dd" integrity sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw== +file-uri-to-path@2: + version "2.0.0" + resolved "https://registry.yarnpkg.com/file-uri-to-path/-/file-uri-to-path-2.0.0.tgz#7b415aeba227d575851e0a5b0c640d7656403fba" + integrity sha512-hjPFI8oE/2iQPVe4gbrJ73Pp+Xfub2+WI2LlXDbsaJBwT5wuMh35WNWVYYTpnz895shtwfyutMFLFywpQAFdLg== + fill-range@^7.0.1: version "7.0.1" resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40" @@ -3488,7 +3933,7 @@ find-up@3.0.0, find-up@^3.0.0: find-up@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/find-up/-/find-up-2.1.0.tgz#45d1b7e506c717ddd482775a2b77920a3c0c57a7" - integrity sha1-RdG35QbHF93UgndaK3eSCjwMV6c= + integrity sha512-NWzkk0jSJtTt08+FBFMvXoeZnOJD+jTtsRmBYbAIzJdX6l7dLgR7CTubCM5/eDdPUBvLCeVasP1brfVR/9/EZQ== dependencies: locate-path "^2.0.0" @@ -3531,9 +3976,9 @@ flat@^4.1.0: is-buffer "~2.0.3" flatted@^3.1.0: - version "3.2.4" - resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.2.4.tgz#28d9969ea90661b5134259f312ab6aa7929ac5e2" - integrity sha512-8/sOawo8tJ4QOBX8YlQBMxL8+RLZfxMQOif9o0KUKTNTjMYElWPE0r/m5VNFxTRd0NSw8qSy8dajrwX4RYI1Hw== + version "3.2.7" + resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.2.7.tgz#609f39207cb614b89d0765b477cb2d437fbf9787" + integrity sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ== flush-write-stream@^1.0.2: version "1.1.1" @@ -3548,10 +3993,17 @@ fn.name@1.x.x: resolved "https://registry.yarnpkg.com/fn.name/-/fn.name-1.1.0.tgz#26cad8017967aea8731bc42961d04a3d5988accc" integrity sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw== -follow-redirects@^1.14.0: - version "1.14.5" - resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.5.tgz#f09a5848981d3c772b5392309778523f8d85c381" - integrity sha512-wtphSXy7d4/OR+MvIFbCVBDzZ5520qV8XfPklSN5QtxuMUJZ+b0Wnst1e1lCDocfzuCkHqj8k0FpZqO+UIaKNA== +follow-redirects@^1.14.0, follow-redirects@^1.14.8, follow-redirects@^1.14.9: + version "1.15.2" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.2.tgz#b460864144ba63f2681096f274c4e57026da2c13" + integrity sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA== + +for-each@^0.3.3: + version "0.3.3" + resolved "https://registry.yarnpkg.com/for-each/-/for-each-0.3.3.tgz#69b447e88a0a5d32c3e7084f3f1710034b21376e" + integrity sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw== + dependencies: + is-callable "^1.1.3" foreground-child@^2.0.0: version "2.0.0" @@ -3564,7 +4016,7 @@ foreground-child@^2.0.0: forever-agent@~0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91" - integrity sha1-+8cfDEGt6zf5bFd60e1C2P2sypE= + integrity sha512-j0KLYPhm6zeac4lz3oJ3o65qvgQCcPubiyotZrXqEaG4hNagNYO8qdlUrX5vwqv9ohqeT/Z3j6+yW067yWWdUw== form-data@^2.3.2: version "2.5.1" @@ -3602,10 +4054,19 @@ form-data@~2.3.2: combined-stream "^1.0.6" mime-types "^2.1.12" +formstream@^1.1.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/formstream/-/formstream-1.2.0.tgz#6948dfa0d1c64bffe93029abf30326fe7504dc41" + integrity sha512-ef4F+FQLnQLly1/AZ5OGNgGzzlOmp+T7+L/TaXASJ1GrETrpZb78/Mz7z+1Ra5FX3nLZE0WIOInGOoa81LxWew== + dependencies: + destroy "^1.0.4" + mime "^2.5.2" + pause-stream "~0.0.11" + from2@^2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/from2/-/from2-2.3.0.tgz#8bfb5502bde4a4d36cfdeea007fcca21d7e382af" - integrity sha1-i/tVAr3kpNNs/e6gB/zKIdfjgq8= + integrity sha512-OMcX/4IC/uqEPVgGeyfN22LJk6AZrMkRZHxcHBMBvHScDGgwTm2GT2Wkgtocyd3JfZffjj2kYUDXXII0Fk9W0g== dependencies: inherits "^2.0.1" readable-stream "^2.0.0" @@ -3623,7 +4084,7 @@ fs-constants@^1.0.0: fs-extra@1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-1.0.0.tgz#cd3ce5f7e7cb6145883fcae3191e9877f8587950" - integrity sha1-zTzl9+fLYUWIP8rjGR6Yd/hYeVA= + integrity sha512-VerQV6vEKuhDWD2HGOybV6v5I73syoc/cXAbKlgTC7M/oFVEtklWlp9QH2Ijw3IaWDOQcMkldSPa7zXy79Z/UQ== dependencies: graceful-fs "^4.1.2" jsonfile "^2.1.0" @@ -3639,9 +4100,18 @@ fs-extra@5.0.0: universalify "^0.1.0" fs-extra@^10.0.0: - version "10.0.0" - resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-10.0.0.tgz#9ff61b655dde53fb34a82df84bb214ce802e17c1" - integrity sha512-C5owb14u9eJwizKGdchcDUQeFtlSHHthBk8pbX9Vc1PFZrLombudjDnNns88aYslCyF6IY5SUw3Roz6xShcEIQ== + version "10.1.0" + resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-10.1.0.tgz#02873cfbc4084dde127eaa5f9905eef2325d1abf" + integrity sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ== + dependencies: + graceful-fs "^4.2.0" + jsonfile "^6.0.1" + universalify "^2.0.0" + +fs-extra@^11.0.0: + version "11.1.1" + resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-11.1.1.tgz#da69f7c39f3b002378b0954bb6ae7efdc0876e2d" + integrity sha512-MGIE4HOvQCeUCzmlHs0vXpih4ysz4wg9qiSAu6cd42lVwPbTM1TjV7RusoyQqMmk/95gdQZX72u+YW+c3eEpFQ== dependencies: graceful-fs "^4.2.0" jsonfile "^6.0.1" @@ -3657,9 +4127,9 @@ fs-extra@^8.1.0: universalify "^0.1.0" fs-jetpack@^4.3.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/fs-jetpack/-/fs-jetpack-4.3.0.tgz#8202abd21c9160faadf3c258b4cf918a74f680de" - integrity sha512-Zx4OJ8HyKvZL9sgxegMGRCgAJSQET5Cqpj/SESwnzqHruHvhkilJBGLoZf6EiYr3UWJDqcPoWDX7aAfaj7D9Qw== + version "4.3.1" + resolved "https://registry.yarnpkg.com/fs-jetpack/-/fs-jetpack-4.3.1.tgz#cdfd4b64e6bfdec7c7dc55c76b39efaa7853bb20" + integrity sha512-dbeOK84F6BiQzk2yqqCVwCPWTxAvVGJ3fMQc6E2wuEohS28mR6yHngbrKuVCK1KHRx/ccByDylqu4H5PCP2urQ== dependencies: minimatch "^3.0.2" rimraf "^2.6.3" @@ -3674,7 +4144,7 @@ fs-minipass@^2.0.0, fs-minipass@^2.1.0: fs-mkdirp-stream@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/fs-mkdirp-stream/-/fs-mkdirp-stream-1.0.0.tgz#0b7815fc3201c6a69e14db98ce098c16935259eb" - integrity sha1-C3gV/DIBxqaeFNuYzgmMFpNSWes= + integrity sha512-+vSd9frUnapVC2RZYfL3FCB2p3g4TBhaUmrsWlSudsGdnxIuUvBB2QM1VZeBtc49QFwrp+wQLrDs3+xxDgI5gQ== dependencies: graceful-fs "^4.1.11" through2 "^2.0.3" @@ -3682,7 +4152,7 @@ fs-mkdirp-stream@^1.0.0: fs.realpath@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" - integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8= + integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw== fsevents@~2.1.1: version "2.1.3" @@ -3699,35 +4169,67 @@ fstream@^1.0.12: mkdirp ">=0.5 0" rimraf "2" +ftp@^0.3.10: + version "0.3.10" + resolved "https://registry.yarnpkg.com/ftp/-/ftp-0.3.10.tgz#9197d861ad8142f3e63d5a83bfe4c59f7330885d" + integrity sha512-faFVML1aBx2UoDStmLwv2Wptt4vw5x03xxX172nhA5Y5HBshW5JweqQ2W4xL4dezQTG8inJsuYcpPHHU3X5OTQ== + dependencies: + readable-stream "1.1.x" + xregexp "2.0.0" + function-bind@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A== -functional-red-black-tree@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz#1b0ab3bd553b2a0d6399d29c0e3ea0b252078327" - integrity sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc= +function.prototype.name@^1.1.5: + version "1.1.5" + resolved "https://registry.yarnpkg.com/function.prototype.name/-/function.prototype.name-1.1.5.tgz#cce0505fe1ffb80503e6f9e46cc64e46a12a9621" + integrity sha512-uN7m/BzVKQnCUF/iW8jYea67v++2u7m5UgENbHRtdDVclOUP+FMPlCNdmk0h/ysGyo2tavMJEDqJAkJdRa1vMA== + dependencies: + call-bind "^1.0.2" + define-properties "^1.1.3" + es-abstract "^1.19.0" + functions-have-names "^1.2.2" + +functions-have-names@^1.2.2, functions-have-names@^1.2.3: + version "1.2.3" + resolved "https://registry.yarnpkg.com/functions-have-names/-/functions-have-names-1.2.3.tgz#0404fe4ee2ba2f607f0e0ec3c80bae994133b834" + integrity sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ== gauge@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/gauge/-/gauge-3.0.1.tgz#4bea07bcde3782f06dced8950e51307aa0f4a346" - integrity sha512-6STz6KdQgxO4S/ko+AbjlFGGdGcknluoqU+79GOFCDqqyYj5OanQf9AjxwN0jCidtT+ziPMmPSt9E4hfQ0CwIQ== + version "3.0.2" + resolved "https://registry.yarnpkg.com/gauge/-/gauge-3.0.2.tgz#03bf4441c044383908bcfa0656ad91803259b395" + integrity sha512-+5J6MS/5XksCuXq++uFRsnUd7Ovu1XenbeuIuNRJxYWjgQbPuFhT14lAvsWfqfAmnwluf1OwMjz39HjfLPci0Q== + dependencies: + aproba "^1.0.3 || ^2.0.0" + color-support "^1.1.2" + console-control-strings "^1.0.0" + has-unicode "^2.0.1" + object-assign "^4.1.1" + signal-exit "^3.0.0" + string-width "^4.2.3" + strip-ansi "^6.0.1" + wide-align "^1.1.2" + +gauge@^4.0.3: + version "4.0.4" + resolved "https://registry.yarnpkg.com/gauge/-/gauge-4.0.4.tgz#52ff0652f2bbf607a989793d53b751bef2328dce" + integrity sha512-f9m+BEN5jkg6a0fZjleidjN51VE1X+mPFQ2DJ0uv1V39oCLCbsGe6yjbBnp7eK7z/+GAon99a3nHuqbuuthyPg== dependencies: aproba "^1.0.3 || ^2.0.0" - color-support "^1.1.2" - console-control-strings "^1.0.0" + color-support "^1.1.3" + console-control-strings "^1.1.0" has-unicode "^2.0.1" - object-assign "^4.1.1" - signal-exit "^3.0.0" - string-width "^1.0.1 || ^2.0.0" - strip-ansi "^3.0.1 || ^4.0.0" - wide-align "^1.1.2" + signal-exit "^3.0.7" + string-width "^4.2.3" + strip-ansi "^6.0.1" + wide-align "^1.1.5" gauge@~2.7.3: version "2.7.4" resolved "https://registry.yarnpkg.com/gauge/-/gauge-2.7.4.tgz#2c03405c7538c39d7eb37b317022e325fb018bf7" - integrity sha1-LANAXHU4w51+s3sxcCLjJfsBi/c= + integrity sha512-14x4kjc6lkD3ltw589k0NrPD6cCNTD6CWoVUNpB85+DrtONoZn+Rug6xZU5RvSC4+TZPxA5AnBibQYAvZn41Hg== dependencies: aproba "^1.0.3" console-control-strings "^1.0.0" @@ -3738,6 +4240,24 @@ gauge@~2.7.3: strip-ansi "^3.0.1" wide-align "^1.1.0" +gaxios@^5.0.0, gaxios@^5.0.1: + version "5.1.0" + resolved "https://registry.yarnpkg.com/gaxios/-/gaxios-5.1.0.tgz#133b77b45532be71eec72012b7e97c2320b6140a" + integrity sha512-aezGIjb+/VfsJtIcHGcBSerNEDdfdHeMros+RbYbGpmonKWQCOVOes0LVZhn1lDtIgq55qq0HaxymIoae3Fl/A== + dependencies: + extend "^3.0.2" + https-proxy-agent "^5.0.0" + is-stream "^2.0.0" + node-fetch "^2.6.7" + +gcp-metadata@^5.2.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/gcp-metadata/-/gcp-metadata-5.2.0.tgz#b4772e9c5976241f5d3e69c4f446c906d25506ec" + integrity sha512-aFhhvvNycky2QyhG+dcfEdHBF0FRbYcf39s6WNHUDysKSrbJ5vuFbjydxBcmewtXeV248GP8dWT3ByPNxsyHCw== + dependencies: + gaxios "^5.0.0" + json-bigint "^1.0.0" + generate-function@^2.3.1: version "2.3.1" resolved "https://registry.yarnpkg.com/generate-function/-/generate-function-2.3.1.tgz#f069617690c10c868e73b8465746764f97c3479f" @@ -3746,20 +4266,15 @@ generate-function@^2.3.1: is-property "^1.0.2" generic-pool@^3.8.2: - version "3.8.2" - resolved "https://registry.yarnpkg.com/generic-pool/-/generic-pool-3.8.2.tgz#aab4f280adb522fdfbdc5e5b64d718d3683f04e9" - integrity sha512-nGToKy6p3PAbYQ7p1UlWl6vSPwfwU6TMSWK7TTu+WUY4ZjyZQGniGGt2oNVvyNSpyZYSB43zMXVLcBm08MTMkg== + version "3.9.0" + resolved "https://registry.yarnpkg.com/generic-pool/-/generic-pool-3.9.0.tgz#36f4a678e963f4fdb8707eab050823abc4e8f5e4" + integrity sha512-hymDOu5B53XvN4QT9dBmZxPX4CWhBPPLguTZ9MMFeFa/Kg0xWVfylOVNlJji/E7yTZWFd/q9GO5TxDLq156D7g== gensync@^1.0.0-beta.2: version "1.0.0-beta.2" resolved "https://registry.yarnpkg.com/gensync/-/gensync-1.0.0-beta.2.tgz#32a6ee76c3d7f52d46b2b1ae5d93fea8580a25e0" integrity sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg== -get-caller-file@^1.0.2: - version "1.0.3" - resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-1.0.3.tgz#f978fa4c90d1dfe7ff2d6beda2a515e713bdcf4a" - integrity sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w== - get-caller-file@^2.0.1, get-caller-file@^2.0.5: version "2.0.5" resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e" @@ -3768,16 +4283,17 @@ get-caller-file@^2.0.1, get-caller-file@^2.0.5: get-func-name@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/get-func-name/-/get-func-name-2.0.0.tgz#ead774abee72e20409433a066366023dd6887a41" - integrity sha1-6td0q+5y4gQJQzoGY2YCPdaIekE= + integrity sha512-Hm0ixYtaSZ/V7C8FJrtZIuBBI+iSgL+1Aq82zSu8VQNB4S3Gk8e7Qs3VwBDJAhmRZcFqkl3tQu36g/Foh5I5ig== -get-intrinsic@^1.0.2, get-intrinsic@^1.1.0, get-intrinsic@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.1.1.tgz#15f59f376f855c446963948f0d24cd3637b4abc6" - integrity sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q== +get-intrinsic@^1.0.2, get-intrinsic@^1.1.1, get-intrinsic@^1.1.3, get-intrinsic@^1.2.0: + version "1.2.1" + resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.2.1.tgz#d295644fed4505fc9cde952c37ee12b477a83d82" + integrity sha512-2DcsyfABl+gVHEfCOaTrWgyt+tb6MSEGmKq+kI5HwLbIYgjgmMcV8KQ41uaKz1xxUcn9tJtgFbQUEVcEbd0FYw== dependencies: function-bind "^1.1.1" has "^1.0.3" - has-symbols "^1.0.1" + has-proto "^1.0.1" + has-symbols "^1.0.3" get-package-type@^0.1.0: version "0.1.0" @@ -3787,7 +4303,7 @@ get-package-type@^0.1.0: get-stdin@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-4.0.1.tgz#b968c6b0a04384324902e8bf1a5df32579a450fe" - integrity sha1-uWjGsKBDhDJJAui/Gl3zJXmkUP4= + integrity sha512-F5aQMywwJ2n85s4hJPTT9RPxGmubonuB10MNYo17/xph174n2MIR33HRguhzVag10O/npM7SPk73LMZNP+FaWw== get-stdin@~8.0.0: version "8.0.0" @@ -3807,17 +4323,29 @@ get-symbol-description@^1.0.0: call-bind "^1.0.2" get-intrinsic "^1.1.1" +get-uri@3: + version "3.0.2" + resolved "https://registry.yarnpkg.com/get-uri/-/get-uri-3.0.2.tgz#f0ef1356faabc70e1f9404fa3b66b2ba9bfc725c" + integrity sha512-+5s0SJbGoyiJTZZ2JTpFPLMPSch72KEqGOTvQsBqg0RBWvwhWUSYZFAtz3TPW0GXJuLBJPts1E241iHg+VRfhg== + dependencies: + "@tootallnate/once" "1" + data-uri-to-buffer "3" + debug "4" + file-uri-to-path "2" + fs-extra "^8.1.0" + ftp "^0.3.10" + getpass@^0.1.1: version "0.1.7" resolved "https://registry.yarnpkg.com/getpass/-/getpass-0.1.7.tgz#5eff8e3e684d569ae4cb2b1282604e8ba62149fa" - integrity sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo= + integrity sha512-0fzj9JxOLfJ+XGLhR8ze3unN0KZCgZwiSSDz168VERjK8Wl8kVSdcu2kspd4s4wtAa1y/qrVRiAA0WclVsu0ng== dependencies: assert-plus "^1.0.0" git-log-parser@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/git-log-parser/-/git-log-parser-1.2.0.tgz#2e6a4c1b13fc00028207ba795a7ac31667b9fd4a" - integrity sha1-LmpMGxP8AAKCB7p5WnrDFme5/Uo= + integrity sha512-rnCVNfkTL8tdNryFuaY0fYiBWEBcgF748O6ZI61rslBvr2o7U65c2/6npCRqH40vuAhtgtDiqLTJjBVdrejCzA== dependencies: argv-formatter "~1.0.0" spawn-error-forwarder "~1.0.0" @@ -3827,9 +4355,9 @@ git-log-parser@^1.2.0: traverse "~0.6.6" git-raw-commits@^2.0.0: - version "2.0.10" - resolved "https://registry.yarnpkg.com/git-raw-commits/-/git-raw-commits-2.0.10.tgz#e2255ed9563b1c9c3ea6bd05806410290297bbc1" - integrity sha512-sHhX5lsbG9SOO6yXdlwgEMQ/ljIn7qMpAbJZCGfXX2fq5T8M5SrDnpYk9/4HswTildcIqatsWa91vty6VhWSaQ== + version "2.0.11" + resolved "https://registry.yarnpkg.com/git-raw-commits/-/git-raw-commits-2.0.11.tgz#bc3576638071d18655e1cc60d7f524920008d723" + integrity sha512-VnctFhw+xfj8Va1xtfEqCUD2XDrbAPSJx+hSrE5K7fGdjZruW7XV+QOrN7LF/RJyvspRiD2I0asWsxFp0ya26A== dependencies: dargs "^7.0.0" lodash "^4.17.15" @@ -3840,7 +4368,7 @@ git-raw-commits@^2.0.0: glob-parent@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-3.1.0.tgz#9e6af6299d8d3bd2bd40430832bd113df906c5ae" - integrity sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4= + integrity sha512-E8Ak/2+dZY6fnzlR7+ueWvhsH1SjHr4jjss4YS/h4py44jY9MhK/VFdaZJAWDz6BbL21KeteKxFSFpq8OS5gVA== dependencies: is-glob "^3.1.0" path-dirname "^1.0.0" @@ -3852,7 +4380,7 @@ glob-parent@^5.1.2, glob-parent@~5.1.0: dependencies: is-glob "^4.0.1" -glob-parent@^6.0.1: +glob-parent@^6.0.2: version "6.0.2" resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-6.0.2.tgz#6d237d99083950c79290f24c7642a3de9a28f9e3" integrity sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A== @@ -3862,7 +4390,7 @@ glob-parent@^6.0.1: glob-stream@^6.1.0: version "6.1.0" resolved "https://registry.yarnpkg.com/glob-stream/-/glob-stream-6.1.0.tgz#7045c99413b3eb94888d83ab46d0b404cc7bdde4" - integrity sha1-cEXJlBOz65SIjYOrRtC0BMx73eQ= + integrity sha512-uMbLGAP3S2aDOHUDfdoYcdIePUCfysbAd0IAoWVZbeGU/oNQ8asHVSshLDJUPWxfzj8zsCG7/XeHPHTtow0nsw== dependencies: extend "^3.0.0" glob "^7.1.1" @@ -3888,21 +4416,21 @@ glob@7.1.3: path-is-absolute "^1.0.0" glob@^7.0.5, glob@^7.1.1, glob@^7.1.3, glob@^7.1.4, glob@^7.1.6, glob@^7.2.0, glob@~7.2.0: - version "7.2.0" - resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.0.tgz#d15535af7732e02e948f4c41628bd910293f6023" - integrity sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q== + version "7.2.3" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.3.tgz#b8df0fb802bbfa8e89bd1d938b4e16578ed44f2b" + integrity sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q== dependencies: fs.realpath "^1.0.0" inflight "^1.0.4" inherits "2" - minimatch "^3.0.4" + minimatch "^3.1.1" once "^1.3.0" path-is-absolute "^1.0.0" global-dirs@^0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/global-dirs/-/global-dirs-0.1.1.tgz#b319c0dd4607f353f3be9cca4c72fc148c49f445" - integrity sha1-sxnA3UYH81PzvpzKTHL8FIxJ9EU= + integrity sha512-NknMLn7F2J7aflwFOlGdNIuCDpN3VGoSoB+aap3KABFWbHVn1TCgFC+np23J8W2BiZbjfEw3BFBycSMv1AFblg== dependencies: ini "^1.3.4" @@ -3911,10 +4439,10 @@ globals@^11.1.0: resolved "https://registry.yarnpkg.com/globals/-/globals-11.12.0.tgz#ab8795338868a0babd8525758018c2a7eb95c42e" integrity sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA== -globals@^13.6.0, globals@^13.9.0: - version "13.12.0" - resolved "https://registry.yarnpkg.com/globals/-/globals-13.12.0.tgz#4d733760304230a0082ed96e21e5c565f898089e" - integrity sha512-uS8X6lSKN2JumVoXrbUz+uG4BYG+eiawqm3qFcT7ammfbUHeCBoJMlHcec/S3krSk73/AE/f0szYFmgAA3kYZg== +globals@^13.19.0: + version "13.20.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-13.20.0.tgz#ea276a1e508ffd4f1612888f9d1bad1e2717bf82" + integrity sha512-Qg5QtVkCy/kv3FUSlu4ukeZDVf9ee0iXLAUYX13gbR17bnejFTzr4iS9bY7kwCf1NztRNm1t91fjOiyx4CSwPQ== dependencies: type-fest "^0.20.2" @@ -3923,29 +4451,84 @@ globals@^9.18.0: resolved "https://registry.yarnpkg.com/globals/-/globals-9.18.0.tgz#aa3896b3e69b487f17e31ed2143d69a8e30c2d8a" integrity sha512-S0nG3CLEQiY/ILxqtztTWH/3iRRdyBLw6KMDxnKMchrtbj2OFmehVh0WUCfW3DUrIgx/qFrJPICrq4Z4sTR9UQ== -globby@^11.0.0, globby@^11.0.1, globby@^11.0.4: - version "11.0.4" - resolved "https://registry.yarnpkg.com/globby/-/globby-11.0.4.tgz#2cbaff77c2f2a62e71e9b2813a67b97a3a3001a5" - integrity sha512-9O4MVG9ioZJ08ffbcyVYyLOJLk5JQ688pJ4eMGLpdWLHq/Wr1D9BlriLQyL0E+jbkuePVZXYFj47QM/v093wHg== +globalthis@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/globalthis/-/globalthis-1.0.3.tgz#5852882a52b80dc301b0660273e1ed082f0b6ccf" + integrity sha512-sFdI5LyBiNTHjRd7cGPWapiHWMOXKyuBNX/cWJ3NfzrZQVa8GI/8cofCl74AOVqq9W5kNmguTIzJ/1s2gyI9wA== + dependencies: + define-properties "^1.1.3" + +globby@^11.0.0, globby@^11.0.1, globby@^11.1.0: + version "11.1.0" + resolved "https://registry.yarnpkg.com/globby/-/globby-11.1.0.tgz#bd4be98bb042f83d796f7e3811991fbe82a0d34b" + integrity sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g== dependencies: array-union "^2.1.0" dir-glob "^3.0.1" - fast-glob "^3.1.1" - ignore "^5.1.4" - merge2 "^1.3.0" + fast-glob "^3.2.9" + ignore "^5.2.0" + merge2 "^1.4.1" slash "^3.0.0" -graceful-fs@^4.0.0, graceful-fs@^4.1.11, graceful-fs@^4.1.15, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.1.9, graceful-fs@^4.2.0, graceful-fs@^4.2.2, graceful-fs@^4.2.3, graceful-fs@^4.2.4, graceful-fs@^4.2.8: - version "4.2.8" - resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.8.tgz#e412b8d33f5e006593cbd3cee6df9f2cebbe802a" - integrity sha512-qkIilPUYcNhJpd33n0GBXTB1MMPp14TxEsEs0pTrsSVucApsYzW5V+Q8Qxhik6KU3evy+qkAAowTByymK0avdg== +google-auth-library@^8.0.1: + version "8.8.0" + resolved "https://registry.yarnpkg.com/google-auth-library/-/google-auth-library-8.8.0.tgz#2e17494431cef56b571420d483a4debff6c481cd" + integrity sha512-0iJn7IDqObDG5Tu9Tn2WemmJ31ksEa96IyK0J0OZCpTh6CrC6FrattwKX87h3qKVuprCJpdOGKc1Xi8V0kMh8Q== + dependencies: + arrify "^2.0.0" + base64-js "^1.3.0" + ecdsa-sig-formatter "^1.0.11" + fast-text-encoding "^1.0.0" + gaxios "^5.0.0" + gcp-metadata "^5.2.0" + gtoken "^6.1.0" + jws "^4.0.0" + lru-cache "^6.0.0" + +google-p12-pem@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/google-p12-pem/-/google-p12-pem-4.0.1.tgz#82841798253c65b7dc2a4e5fe9df141db670172a" + integrity sha512-WPkN4yGtz05WZ5EhtlxNDWPhC4JIic6G8ePitwUWy4l+XPVYec+a0j0Ts47PDtW59y3RwAhUd9/h9ZZ63px6RQ== + dependencies: + node-forge "^1.3.1" + +gopd@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/gopd/-/gopd-1.0.1.tgz#29ff76de69dac7489b7c0918a5788e56477c332c" + integrity sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA== + dependencies: + get-intrinsic "^1.1.3" + +graceful-fs@^4.0.0, graceful-fs@^4.1.11, graceful-fs@^4.1.15, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.1.9, graceful-fs@^4.2.0, graceful-fs@^4.2.2, graceful-fs@^4.2.3, graceful-fs@^4.2.4, graceful-fs@^4.2.6, graceful-fs@^4.2.8: + version "4.2.11" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.11.tgz#4183e4e8bf08bb6e05bbb2f7d2e0c8f712ca40e3" + integrity sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ== + +grapheme-splitter@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/grapheme-splitter/-/grapheme-splitter-1.0.4.tgz#9cf3a665c6247479896834af35cf1dbb4400767e" + integrity sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ== + +graphemer@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/graphemer/-/graphemer-1.4.0.tgz#fb2f1d55e0e3a1849aeffc90c4fa0dd53a0e66c6" + integrity sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag== growl@1.10.5: version "1.10.5" resolved "https://registry.yarnpkg.com/growl/-/growl-1.10.5.tgz#f2735dc2283674fa67478b10181059355c369e5e" integrity sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA== -handlebars@^4.7.6: +gtoken@^6.1.0: + version "6.1.2" + resolved "https://registry.yarnpkg.com/gtoken/-/gtoken-6.1.2.tgz#aeb7bdb019ff4c3ba3ac100bbe7b6e74dce0e8bc" + integrity sha512-4ccGpzz7YAr7lxrT2neugmXQ3hP9ho2gcaityLVkiUecAiwiy60Ii8gRbZeOsXV19fYaRjgBSshs8kXw+NKCPQ== + dependencies: + gaxios "^5.0.1" + google-p12-pem "^4.0.0" + jws "^4.0.0" + +handlebars@^4.7.7: version "4.7.7" resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.7.7.tgz#9ce33416aad02dbd6c8fafa8240d5d98004945a1" integrity sha512-aAcXm5OAfE/8IXkcZvCepKU3VzW1/39Fb5ZuqMtgI/hT8X2YgoMvBY5dLhq/cpOvw7Lk1nK/UF71aLG/ZnVYRA== @@ -3960,7 +4543,7 @@ handlebars@^4.7.6: har-schema@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/har-schema/-/har-schema-2.0.0.tgz#a94c2224ebcac04782a0d9035521f24735b7ec92" - integrity sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI= + integrity sha512-Oqluz6zhGX8cyRaTQlFMPw80bSJVG2x/cFb8ZPhUILGgHka9SsokCCOQgpveePerqidZOrT14ipqfJb7ILcW5Q== har-validator@~5.1.3: version "5.1.5" @@ -3978,29 +4561,41 @@ hard-rejection@^2.1.0: has-ansi@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/has-ansi/-/has-ansi-2.0.0.tgz#34f5049ce1ecdf2b0649af3ef24e45ed35416d91" - integrity sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE= + integrity sha512-C8vBJ8DwUCx19vhm7urhTuUsr4/IyP6l4VzNQDv+ryHQObW3TTTp9yB68WpYgRe2bbaGuZ/se74IqFeVnMnLZg== dependencies: ansi-regex "^2.0.0" -has-bigints@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/has-bigints/-/has-bigints-1.0.1.tgz#64fe6acb020673e3b78db035a5af69aa9d07b113" - integrity sha512-LSBS2LjbNBTf6287JEbEzvJgftkF5qFkmCo9hDRpAzKhUOlJ+hx8dd4USs00SgsUNwc4617J9ki5YtEClM2ffA== +has-bigints@^1.0.1, has-bigints@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/has-bigints/-/has-bigints-1.0.2.tgz#0871bd3e3d51626f6ca0966668ba35d5602d6eaa" + integrity sha512-tSvCKtBr9lkF0Ex0aQiP9N+OpV4zi2r/Nee5VkRDbaqv35RLYMzbwQfFSZZH0kR+Rd6302UJZ2p/bJCEoR3VoQ== has-flag@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" - integrity sha1-tdRU3CGZriJWmfNGfloH87lVuv0= + integrity sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw== has-flag@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b" integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== -has-symbols@^1.0.0, has-symbols@^1.0.1, has-symbols@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.2.tgz#165d3070c00309752a1236a479331e3ac56f1423" - integrity sha512-chXa79rL/UC2KlX17jo3vRGz0azaWEx5tGqZg5pO3NUyEJVB17dMruQlzCCOfUvElghKcm5194+BCRvi2Rv/Gw== +has-property-descriptors@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/has-property-descriptors/-/has-property-descriptors-1.0.0.tgz#610708600606d36961ed04c196193b6a607fa861" + integrity sha512-62DVLZGoiEBDHQyqG4w9xCuZ7eJEwNmJRWw2VY84Oedb7WFcA27fiEVe8oUQx9hAUJ4ekurquucTGwsyO1XGdQ== + dependencies: + get-intrinsic "^1.1.1" + +has-proto@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/has-proto/-/has-proto-1.0.1.tgz#1885c1305538958aff469fef37937c22795408e0" + integrity sha512-7qE+iP+O+bgF9clE5+UoBFzE65mlBiVj3tKCrlNQ0Ogwm0BjpT/gK4SlLYDMybDh5I3TCTKnPPa0oMG7JDYrhg== + +has-symbols@^1.0.0, has-symbols@^1.0.2, has-symbols@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.3.tgz#bb7b2c4349251dce87b125f7bdf874aa7c8b39f8" + integrity sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A== has-tostringtag@^1.0.0: version "1.0.0" @@ -4012,7 +4607,7 @@ has-tostringtag@^1.0.0: has-unicode@^2.0.0, has-unicode@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/has-unicode/-/has-unicode-2.0.1.tgz#e0e6fe6a28cf51138855e086d1691e771de2a8b9" - integrity sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk= + integrity sha512-8Rf9Y83NBReMnx0gFzA8JImQACstCYWUplepDa9xprwwtmgEZUF0h/i5xSA625zB/I37EtrswSST6OXxwaaIJQ== has@^1.0.3: version "1.0.3" @@ -4052,9 +4647,9 @@ hosted-git-info@^2.1.4: integrity sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw== hosted-git-info@^4.0.0, hosted-git-info@^4.0.1, hosted-git-info@^4.0.2: - version "4.0.2" - resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-4.0.2.tgz#5e425507eede4fea846b7262f0838456c4209961" - integrity sha512-c9OGXbZ3guC/xOlCg1Ci/VgWlwsqDv1yMQL1CWqXDL0hDjXuNcq0zuR4xqPSuasI3kqFDhqSyTjREz5gzq0fXg== + version "4.1.0" + resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-4.1.0.tgz#827b82867e9ff1c8d0c4d9d53880397d2c86d224" + integrity sha512-kyCuEOWjJqZuDbRHzL8V93NzQhwIB71oFWSyzVo+KPZI+pnQPPxucdkrOZvkLRnrf5URsQM+IJ09Dw29cRALIA== dependencies: lru-cache "^6.0.0" @@ -4075,20 +4670,20 @@ htmlparser2@^3.9.1: inherits "^2.0.1" readable-stream "^3.1.1" -htmlparser2@^6.1.0: - version "6.1.0" - resolved "https://registry.yarnpkg.com/htmlparser2/-/htmlparser2-6.1.0.tgz#c4d762b6c3371a05dbe65e94ae43a9f845fb8fb7" - integrity sha512-gyyPk6rgonLFEDGoeRgQNaEUvdJ4ktTmmUh/h2t7s+M8oPpIPxgNACWa+6ESR57kXstwqPiCut0V8NRpcwgU7A== +htmlparser2@^8.0.1: + version "8.0.2" + resolved "https://registry.yarnpkg.com/htmlparser2/-/htmlparser2-8.0.2.tgz#f002151705b383e62433b5cf466f5b716edaec21" + integrity sha512-GYdjWKDkbRLkZ5geuHs5NY1puJ+PXwP7+fHPRz06Eirsb9ugf6d8kkXav6ADhcODhFFPMIXyxkxSuMf3D6NCFA== dependencies: - domelementtype "^2.0.1" - domhandler "^4.0.0" - domutils "^2.5.2" - entities "^2.0.0" + domelementtype "^2.3.0" + domhandler "^5.0.3" + domutils "^3.0.1" + entities "^4.4.0" htmlparser2@~3.8.1: version "3.8.3" resolved "https://registry.yarnpkg.com/htmlparser2/-/htmlparser2-3.8.3.tgz#996c28b191516a8be86501a7d79757e5c70c1068" - integrity sha1-mWwosZFRaovoZQGn15dX5ccMEGg= + integrity sha512-hBxEg3CYXe+rPIua8ETe7tmG3XDn9B0edOE/e9wH2nLczxzgdu0m0aNHY+5wFZiviLWLdANPJTssa92dMcXQ5Q== dependencies: domelementtype "1" domhandler "2.3" @@ -4097,11 +4692,22 @@ htmlparser2@~3.8.1: readable-stream "1.1" http-cache-semantics@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/http-cache-semantics/-/http-cache-semantics-4.1.0.tgz#49e91c5cbf36c9b94bcfcd71c23d5249ec74e390" - integrity sha512-carPklcUh7ROWRK7Cv27RPtdhYhUsela/ue5/jKzjegVvXDqM2ILE9Q2BGn9JZJh1g87cp56su/FgQSzcWS8cQ== + version "4.1.1" + resolved "https://registry.yarnpkg.com/http-cache-semantics/-/http-cache-semantics-4.1.1.tgz#abe02fcb2985460bf0323be664436ec3476a6d5a" + integrity sha512-er295DKPVsV82j5kw1Gjt+ADA/XYHsajl82cGNQG2eyoPkvgUhX+nDIyelzhIWbbsXP39EHcI6l5tYs2FYqYXQ== + +http-errors@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-2.0.0.tgz#b7774a1486ef73cf7667ac9ae0858c012c57b9d3" + integrity sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ== + dependencies: + depd "2.0.0" + inherits "2.0.4" + setprototypeof "1.2.0" + statuses "2.0.1" + toidentifier "1.0.1" -http-proxy-agent@^4.0.1: +http-proxy-agent@^4.0.0, http-proxy-agent@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/http-proxy-agent/-/http-proxy-agent-4.0.1.tgz#8a8c8ef7f5932ccf953c296ca8291b95aa74aa3a" integrity sha512-k0zdNgqWTGA6aeIRVpvfVob4fL52dTfaehylg0Y4UvSySvOq/Y+BOyPrgpUrA7HylqvU8vIZGsRuXmspskV0Tg== @@ -4119,38 +4725,37 @@ http-proxy-agent@^5.0.0: agent-base "6" debug "4" -http-signature@^1.3.6: - version "1.3.6" - resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-1.3.6.tgz#cb6fbfdf86d1c974f343be94e87f7fc128662cf9" - integrity sha512-3adrsD6zqo4GsTqtO7FyrejHNv+NgiIfAfv68+jVlFmSr9OGy7zrxONceFRLKvnnZA5jbxQBX1u9PpB6Wi32Gw== +http-proxy-agent@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/http-proxy-agent/-/http-proxy-agent-7.0.0.tgz#e9096c5afd071a3fce56e6252bb321583c124673" + integrity sha512-+ZT+iBxVUQ1asugqnD6oWoRiS25AkjNfG085dKJGtGxkdwLQrMKU5wJr2bOOFAXzKcTuqq+7fZlTMgG3SRfIYQ== dependencies: - assert-plus "^1.0.0" - jsprim "^2.0.2" - sshpk "^1.14.1" + agent-base "^7.1.0" + debug "^4.3.4" http-signature@~1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-1.2.0.tgz#9aecd925114772f3d95b65a60abb8f7c18fbace1" - integrity sha1-muzZJRFHcvPZW2WmCruPfBj7rOE= + integrity sha512-CAbnr6Rz4CYQkLYUtSNXxQPUH2gK8f3iWexVlsnMeD+GjlsQ0Xsy1cOX+mN3dtxYomRy21CiOzU8Uhw6OwncEQ== dependencies: assert-plus "^1.0.0" jsprim "^1.2.2" sshpk "^1.7.0" -https-proxy-agent@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-3.0.1.tgz#b8c286433e87602311b01c8ea34413d856a4af81" - integrity sha512-+ML2Rbh6DAuee7d07tYGEKOEi2voWPUGan+ExdPbPW6Z3svq+JCqr0v8WmKPOkz1vOVykPCBSuobe7G8GJUtVg== +https-proxy-agent@5, https-proxy-agent@^5.0.0, https-proxy-agent@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz#c59ef224a04fe8b754f3db0063a25ea30d0005d6" + integrity sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA== dependencies: - agent-base "^4.3.0" - debug "^3.1.0" + agent-base "6" + debug "4" -https-proxy-agent@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-5.0.0.tgz#e2a90542abb68a762e0a0850f6c9edadfd8506b2" - integrity sha512-EkYm5BcKUGiduxzSt3Eppko+PiNWNEpa4ySk9vTC6wDsQJW9rHSa+UhGNJoRYp7bz6Ht1eaRIa6QaJqO5rCFbA== +https-proxy-agent@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-7.0.0.tgz#75cb70d04811685667183b31ab158d006750418a" + integrity sha512-0euwPCRyAPSgGdzD1IVN9nJYHtBhJwb6XPfbpQcYbPCwrBidX6GzxmchnaF4sfF/jPb74Ojx5g4yTg3sixlyPw== dependencies: - agent-base "6" + agent-base "^7.0.2" debug "4" human-signals@^2.1.0: @@ -4158,10 +4763,10 @@ human-signals@^2.1.0: resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-2.1.0.tgz#dc91fcba42e4d06e4abaed33b3e7a3c02f514ea0" integrity sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw== -humanize-ms@^1.2.1: +humanize-ms@^1.2.0, humanize-ms@^1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/humanize-ms/-/humanize-ms-1.2.1.tgz#c46e3159a293f6b896da29316d8b6fe8bb79bbed" - integrity sha1-xG4xWaKT9riW2ikxbYtv6Lt5u+0= + integrity sha512-Fl70vYtsAFb/C06PTS9dZBo7ihau+Tu/DNCk/OyHhea07S+aeMWpFFkUaXRa8fI+ScZbEI8dfSxwY7gxZ9SAVQ== dependencies: ms "^2.0.0" @@ -4171,11 +4776,11 @@ husky@^7.0.4: integrity sha512-vbaCKN2QLtP/vD4yvs6iz6hBEo6wkSzs8HpRah1Z6aGmF2KW5PdYuAd7uX5a+OyBZHBhd+TFLqgjUgytQr4RvQ== ibm_db@^2.8.1: - version "2.8.1" - resolved "https://registry.yarnpkg.com/ibm_db/-/ibm_db-2.8.1.tgz#1b018d1fc9c6b5bd205b603e43a09584e1dbecc0" - integrity sha512-w4q5UN5FNRf4PW2yDG3uQVnA81vy2GS4vkGwigKgBuUMRa+pNgbAtTkhv3w/9Vz12X6YiYK9hFcwlVomKdj0qw== + version "2.8.2" + resolved "https://registry.yarnpkg.com/ibm_db/-/ibm_db-2.8.2.tgz#bc5a22c2859a95de577088f4f2bf72fb6da6107b" + integrity sha512-cvvvz/VGeniQRHpSpiJmw2wJxkLG5ewcS1DLOW9rvHYBMBvyCM54O7ZhCSlsX1+XV5QKyKdvhjQxld+uoiZJlA== dependencies: - axios "^0.21.1" + axios "^0.26.1" big-integer "^1.6.51" bindings "^1.5.0" fs-extra "^8.1.0" @@ -4189,11 +4794,18 @@ ibm_db@^2.8.1: ice-cap@0.0.4: version "0.0.4" resolved "https://registry.yarnpkg.com/ice-cap/-/ice-cap-0.0.4.tgz#8a6d31ab4cac8d4b56de4fa946df3352561b6e18" - integrity sha1-im0xq0ysjUtW3k+pRt8zUlYbbhg= + integrity sha512-39ZblYEKlqj7LHgLkUcVk7zcJp772lOVQAUhN6QyY88w8/4bn5SgDeU2020yzHosf+uKPuCFK1UQ36gyBNiraw== dependencies: cheerio "0.20.0" color-logger "0.0.3" +iconv-lite@0.4.24, iconv-lite@^0.4.15: + version "0.4.24" + resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" + integrity sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA== + dependencies: + safer-buffer ">= 2.1.2 < 3" + iconv-lite@^0.5.0: version "0.5.2" resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.5.2.tgz#af6d628dccfb463b7364d97f715e4b74b8c8c2b8" @@ -4225,12 +4837,12 @@ ignore-walk@^3.0.3: dependencies: minimatch "^3.0.4" -ignore@^4.0.6: - version "4.0.6" - resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc" - integrity sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg== +ignore@^5.2.0: + version "5.2.4" + resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.4.tgz#a291c0c6178ff1b960befe47fcdec301674a6324" + integrity sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ== -ignore@^5.1.4, ignore@^5.1.8, ignore@~5.1.9: +ignore@~5.1.9: version "5.1.9" resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.1.9.tgz#9ec1a5cbe8e1446ec60d4420060d43aa6e7382fb" integrity sha512-2zeMQpbKz5dhZ9IwL0gbxSW5w0NK/MSAMtNuhgIHEPmaU3vPdKPL0UdvUCXs5SS4JAwsBxysK5sFMW8ocFiVjQ== @@ -4251,7 +4863,7 @@ import-from@^4.0.0: imurmurhash@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea" - integrity sha1-khi5srkoojixPcT7a21XbyMUU+o= + integrity sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA== indent-string@^4.0.0: version "4.0.0" @@ -4263,20 +4875,20 @@ infer-owner@^1.0.4: resolved "https://registry.yarnpkg.com/infer-owner/-/infer-owner-1.0.4.tgz#c4cefcaa8e51051c2a40ba2ce8a3d27295af9467" integrity sha512-IClj+Xz94+d7irH5qRyfJonOdfTzuDaifE6ZPWfx0N0+/ATZCbuTPq2prFl526urkQd90WyUKIh1DfBQ2hMz9A== -inflection@^1.13.1: - version "1.13.1" - resolved "https://registry.yarnpkg.com/inflection/-/inflection-1.13.1.tgz#c5cadd80888a90cf84c2e96e340d7edc85d5f0cb" - integrity sha512-dldYtl2WlN0QDkIDtg8+xFwOS2Tbmp12t1cHa5/YClU6ZQjTFm7B66UcVbh9NQB+HvT5BAd2t5+yKsBkw5pcqA== +inflection@^1.13.4: + version "1.13.4" + resolved "https://registry.yarnpkg.com/inflection/-/inflection-1.13.4.tgz#65aa696c4e2da6225b148d7a154c449366633a32" + integrity sha512-6I/HUDeYFfuNCVS3td055BaXBwKYuzw7K3ExVMStBowKo9oOAMJIXIHvdyR3iboTCp1b+1i5DSkIZTcwIktuDw== inflight@^1.0.4: version "1.0.6" resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" - integrity sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk= + integrity sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA== dependencies: once "^1.3.0" wrappy "1" -inherits@2, inherits@^2.0.1, inherits@^2.0.3, inherits@~2.0.0, inherits@~2.0.1, inherits@~2.0.3: +inherits@2, inherits@2.0.4, inherits@^2.0.1, inherits@^2.0.3, inherits@~2.0.0, inherits@~2.0.1, inherits@~2.0.3: version "2.0.4" resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== @@ -4286,11 +4898,16 @@ ini@^1.3.4, ini@~1.3.0: resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.8.tgz#a29da425b48806f34767a4efce397269af28432c" integrity sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew== -ini@^2.0.0, ini@~2.0.0: +ini@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/ini/-/ini-2.0.0.tgz#e5fd556ecdd5726be978fa1001862eacb0a94bc5" integrity sha512-7PnF4oN3CvZF23ADhA5wRaYEQpJ8qygSkbtTXWBeXWXmEVRXK+1ITciHWwHhsjv1TmW0MgacIv6hEi5pX5NQdA== +ini@~3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/ini/-/ini-3.0.1.tgz#c76ec81007875bc44d544ff7a11a55d12294102d" + integrity sha512-it4HyVAUTKBc6m8e1iXWvXSTdndF7HbdN713+kvLrymxTaU4AUBWrJ4vEooP+V7fexnVD3LKcBshjGGPefSMUQ== + init-package-json@^2.0.5: version "2.0.5" resolved "https://registry.yarnpkg.com/init-package-json/-/init-package-json-2.0.5.tgz#78b85f3c36014db42d8f32117252504f68022646" @@ -4304,12 +4921,12 @@ init-package-json@^2.0.5: validate-npm-package-license "^3.0.4" validate-npm-package-name "^3.0.0" -internal-slot@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/internal-slot/-/internal-slot-1.0.3.tgz#7347e307deeea2faac2ac6205d4bc7d34967f59c" - integrity sha512-O0DB1JC/sPyZl7cIo78n5dR7eUSwwpYPiXRhTzNxZVAMUuB8vlnRFyLxdrVToks6XPLVnFfbzaVd5WLjhgg+vA== +internal-slot@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/internal-slot/-/internal-slot-1.0.5.tgz#f2a2ee21f668f8627a4667f309dc0f4fb6674986" + integrity sha512-Y+R5hJrzs52QCG2laLn4udYVnxsfny9CpOhNhUvk/SSSVyF6T27FzRbF0sroPidSu3X8oEAkOn2K804mjpt6UQ== dependencies: - get-intrinsic "^1.1.0" + get-intrinsic "^1.2.0" has "^1.0.3" side-channel "^1.0.4" @@ -4334,9 +4951,14 @@ ip-regex@^4.1.0: integrity sha512-B9ZWJxHHOHUhUjCPrMpLD4xEq35bUTClHM1S6CBU5ixQnkZmwipwgc96vAd7AAGM9TGHvJR+Uss+/Ak6UphK+Q== ip@^1.1.5: - version "1.1.5" - resolved "https://registry.yarnpkg.com/ip/-/ip-1.1.5.tgz#bdded70114290828c0a039e72ef25f5aaec4354a" - integrity sha1-vd7XARQpCCjAoDnnLvJfWq7ENUo= + version "1.1.8" + resolved "https://registry.yarnpkg.com/ip/-/ip-1.1.8.tgz#ae05948f6b075435ed3307acce04629da8cdbf48" + integrity sha512-PuExPYUiu6qMBQb4l06ecm6T6ujzhmh+MeJcW9wa89PoAz5pvd4zPgN5WJV104mb6S2T1AwNIAaB70JNrLQWhg== + +ip@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/ip/-/ip-2.0.0.tgz#4cf4ab182fee2314c75ede1276f8c80b479936da" + integrity sha512-WKa+XuLG1A1R0UWhl2+1XQSi+fZWMsYKffMZTTYsiZaUD8k2yDAj5atimTUD2TZkyCkNEeYE5NhFZmupOGtjYQ== is-absolute@^1.0.0: version "1.0.0" @@ -4346,10 +4968,27 @@ is-absolute@^1.0.0: is-relative "^1.0.0" is-windows "^1.0.1" +is-arguments@^1.0.4: + version "1.1.1" + resolved "https://registry.yarnpkg.com/is-arguments/-/is-arguments-1.1.1.tgz#15b3f88fda01f2a97fec84ca761a560f123efa9b" + integrity sha512-8Q7EARjzEnKpt/PCD7e1cgUS0a6X8u5tdSiMqXhojOdoV9TsMsiO+9VLC5vAmO8N7/GmXn7yjR8qnA6bVAEzfA== + dependencies: + call-bind "^1.0.2" + has-tostringtag "^1.0.0" + +is-array-buffer@^3.0.1, is-array-buffer@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/is-array-buffer/-/is-array-buffer-3.0.2.tgz#f2653ced8412081638ecb0ebbd0c41c6e0aecbbe" + integrity sha512-y+FyyR/w8vfIRq4eQcM1EYgSTnmHXPqaF+IgzgraytCFq5Xh8lllDVmAZolPJiZttZLeFSINPYMaEJ7/vWUa1w== + dependencies: + call-bind "^1.0.2" + get-intrinsic "^1.2.0" + is-typed-array "^1.1.10" + is-arrayish@^0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d" - integrity sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0= + integrity sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg== is-arrayish@^0.3.1: version "0.3.2" @@ -4388,10 +5027,10 @@ is-buffer@~2.0.3: resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-2.0.5.tgz#ebc252e400d22ff8d77fa09888821a24a658c191" integrity sha512-i2R6zNFDwgEHJyQUtJEk0XFi1i0dPFn/oqjK3/vPCcDeJvW5NQ83V8QbicfF1SupOaB0h8ntgBC2YiE7dfyctQ== -is-callable@^1.1.4, is-callable@^1.2.4: - version "1.2.4" - resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.2.4.tgz#47301d58dd0259407865547853df6d61fe471945" - integrity sha512-nsuwtxZfMX67Oryl9LCQ+upnC0Z0BgpwntpS89m1H/TLF0zNfzfLMV/9Wa/6MZsj0acpEjAO0KF1xT6ZdLl95w== +is-callable@^1.1.3, is-callable@^1.1.4, is-callable@^1.2.7: + version "1.2.7" + resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.2.7.tgz#3bc2a85ea742d9e36205dcacdd72ca1fdc51b055" + integrity sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA== is-cidr@^4.0.2: version "4.0.2" @@ -4400,10 +5039,10 @@ is-cidr@^4.0.2: dependencies: cidr-regex "^3.1.1" -is-core-module@^2.2.0, is-core-module@^2.5.0: - version "2.8.0" - resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.8.0.tgz#0321336c3d0925e497fd97f5d95cb114a5ccd548" - integrity sha512-vd15qHsaqrRL7dtH6QNuy0ndJmRDrS9HAM1CAiSifNUFv4x1a0CCVsj18hJ1mShxIG6T2i1sO78MkP56r0nYRw== +is-core-module@^2.11.0, is-core-module@^2.5.0: + version "2.12.1" + resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.12.1.tgz#0c0b6885b6f80011c71541ce15c8d66cf5a4f9fd" + integrity sha512-Q4ZuBAe2FUsKtyQJoQHlvP8OvBERxO3jEmy1I7hcRXcJBGGHFh/aJBswbXuS9sgrDH2QUO8ilkwNPHvHMd8clg== dependencies: has "^1.0.3" @@ -4419,10 +5058,15 @@ is-docker@^2.0.0: resolved "https://registry.yarnpkg.com/is-docker/-/is-docker-2.2.1.tgz#33eeabe23cfe86f14bde4408a02c0cfb853acdaa" integrity sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ== +is-extendable@^0.1.0: + version "0.1.1" + resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-0.1.1.tgz#62b110e289a471418e3ec36a617d472e301dfc89" + integrity sha512-5BMULNob1vgFX6EjQw5izWDxrecWK9AM72rugNr0TFldMOi0fj6Jk+zeKIt0xGj4cEfQIJth4w3OKWOJ4f+AFw== + is-extglob@^2.1.0, is-extglob@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" - integrity sha1-qIwCU1eR8C7TfHahueqXc8gz+MI= + integrity sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ== is-finite@^1.0.0: version "1.1.0" @@ -4432,14 +5076,14 @@ is-finite@^1.0.0: is-fullwidth-code-point@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz#ef9e31386f031a7f0d643af82fde50c457ef00cb" - integrity sha1-754xOG8DGn8NZDr4L95QxFfvAMs= + integrity sha512-1pqUqRjkhPJ9miNq9SwMfdvi6lBJcd6eFxvfaivQhaH3SgisfiuudvFntdKOmxuee/77l+FPjKrQjWvmPjWrRw== dependencies: number-is-nan "^1.0.0" is-fullwidth-code-point@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz#a3b30a5c4f199183167aaab93beefae3ddfb654f" - integrity sha1-o7MKXE8ZkYMWeqq5O+764937ZU8= + integrity sha512-VHskAKYM8RfSFXwee5t5cbN5PZeq1Wrh6qd5bkyiXIf6UQcN6w/A0eXM9r6t8d+GYOh+o6ZhiEnb88LN/Y8m2w== is-fullwidth-code-point@^3.0.0: version "3.0.0" @@ -4451,10 +5095,17 @@ is-fullwidth-code-point@^4.0.0: resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-4.0.0.tgz#fae3167c729e7463f8461ce512b080a49268aa88" integrity sha512-O4L094N2/dZ7xqVdrXhh9r1KODPJpFms8B5sGdJLPy664AgvXsreZUyCQQNItZRDlYug4xStLjNp/sz3HvBowQ== +is-generator-function@^1.0.7: + version "1.0.10" + resolved "https://registry.yarnpkg.com/is-generator-function/-/is-generator-function-1.0.10.tgz#f1558baf1ac17e0deea7c0415c438351ff2b3c72" + integrity sha512-jsEjy9l3yiXEQ+PsXdmBwEPcOxaXWLspKdplFUVI9vq1iZgIekeC0L167qeu86czQaxed3q/Uzuw0swL0irL8A== + dependencies: + has-tostringtag "^1.0.0" + is-glob@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-3.1.0.tgz#7ba5ae24217804ac70707b96922567486cc3e84a" - integrity sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo= + integrity sha512-UFpDDrPgM6qpnFNI+rh/p3bUaq9hKLZN8bMUWzxmcnZVS3omf4IPK+BrewlnWjO1WmUsMYuSjKh4UJuV4+Lqmw== dependencies: is-extglob "^2.1.0" @@ -4468,22 +5119,22 @@ is-glob@^4.0.0, is-glob@^4.0.1, is-glob@^4.0.3, is-glob@~4.0.1: is-lambda@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/is-lambda/-/is-lambda-1.0.1.tgz#3d9877899e6a53efc0160504cde15f82e6f061d5" - integrity sha1-PZh3iZ5qU+/AFgUEzeFfgubwYdU= + integrity sha512-z7CMFGNrENq5iFB9Bqo64Xk6Y9sg+epq1myIcdHaGnbMTYOxvzsEtdYqQUylB7LxfkvgrrjP32T6Ywciio9UIQ== is-negated-glob@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-negated-glob/-/is-negated-glob-1.0.0.tgz#6910bca5da8c95e784b5751b976cf5a10fee36d2" - integrity sha1-aRC8pdqMleeEtXUbl2z1oQ/uNtI= + integrity sha512-czXVVn/QEmgvej1f50BZ648vUI+em0xqMq2Sn+QncCLN4zj1UAxlT+kw/6ggQTOaZPd1HqKQGEqbpQVtJucWug== -is-negative-zero@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/is-negative-zero/-/is-negative-zero-2.0.1.tgz#3de746c18dda2319241a53675908d8f766f11c24" - integrity sha512-2z6JzQvZRa9A2Y7xC6dQQm4FSTSTNWjKIYYTt4246eMTJmIo0Q+ZyOsU66X8lxK1AbB92dFeglPLrhwpeRKO6w== +is-negative-zero@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/is-negative-zero/-/is-negative-zero-2.0.2.tgz#7bf6f03a28003b8b3965de3ac26f664d765f3150" + integrity sha512-dqJvarLawXsFbNDeJW7zAz8ItJ9cd28YufuuFzh0G8pNHjJMnY08Dv7sYX2uF5UpQOwieAeOExEYAWWfu7ZZUA== is-number-object@^1.0.4: - version "1.0.6" - resolved "https://registry.yarnpkg.com/is-number-object/-/is-number-object-1.0.6.tgz#6a7aaf838c7f0686a50b4553f7e54a96494e89f0" - integrity sha512-bEVOqiRcvo3zO1+G2lVMy+gkkEm9Yh7cDMRusKKu5ZJKPUYSJwICTKZrNKHA2EbSP0Tu0+6B/emsYNHZyn6K8g== + version "1.0.7" + resolved "https://registry.yarnpkg.com/is-number-object/-/is-number-object-1.0.7.tgz#59d50ada4c45251784e9904f5246c742f07a42fc" + integrity sha512-k1U0IRzLMo7ZlYIfzRu23Oh6MiIFasgpb9X76eqfFZAqwH44UI4KTBvBYIZ1dSL9ZzChTB9ShHfLkR4pdW5krQ== dependencies: has-tostringtag "^1.0.0" @@ -4502,7 +5153,7 @@ is-path-cwd@^2.2.0: resolved "https://registry.yarnpkg.com/is-path-cwd/-/is-path-cwd-2.2.0.tgz#67d43b82664a7b5191fd9119127eb300048a9fdb" integrity sha512-w942bTcih8fdJPJmQHFzkS76NEP8Kzzvmw92cXsazb8intwLqPibPPdXf4ANdKV3rYMuuQYGIWtvz9JilB3NFQ== -is-path-inside@^3.0.2: +is-path-inside@^3.0.2, is-path-inside@^3.0.3: version "3.0.3" resolved "https://registry.yarnpkg.com/is-path-inside/-/is-path-inside-3.0.3.tgz#d231362e53a07ff2b0e0ea7fed049161ffd16283" integrity sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ== @@ -4510,7 +5161,7 @@ is-path-inside@^3.0.2: is-plain-obj@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-1.1.0.tgz#71a50c8429dfca773c92a390a4a03b39fcd51d3e" - integrity sha1-caUMhCnfync8kqOQpKA7OfzVHT4= + integrity sha512-yvkRyxmFKEOQ4pNXCmJG5AEQNlXJS5LaONXo5/cLdTZdWvsZ1ioJEonLGAosKlMWE8lwUy/bJzMjcw8az73+Fg== is-plain-object@^5.0.0: version "5.0.0" @@ -4520,7 +5171,7 @@ is-plain-object@^5.0.0: is-property@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/is-property/-/is-property-1.0.2.tgz#57fe1c4e48474edd65b09911f26b1cd4095dda84" - integrity sha1-V/4cTkhHTt1lsJkR8msc1Ald2oQ= + integrity sha512-Ks/IoX00TtClbGQr4TWXemAnktAQvYB7HzcCxDGqEZU6oCmb2INHuOoKxbtR+HFkmYWBKv/dOZtGRiAjDhj92g== is-regex@^1.1.4: version "1.1.4" @@ -4537,10 +5188,12 @@ is-relative@^1.0.0: dependencies: is-unc-path "^1.0.0" -is-shared-array-buffer@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/is-shared-array-buffer/-/is-shared-array-buffer-1.0.1.tgz#97b0c85fbdacb59c9c446fe653b82cf2b5b7cfe6" - integrity sha512-IU0NmyknYZN0rChcKhRO1X8LYz5Isj/Fsqh8NJOSf+N/hCOTwy29F32Ik7a+QszE63IdvmwdTPDd6cZ5pg4cwA== +is-shared-array-buffer@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-shared-array-buffer/-/is-shared-array-buffer-1.0.2.tgz#8f259c573b60b6a32d4058a1a07430c0a7344c79" + integrity sha512-sqN2UDu1/0y6uvXyStCOzyhAjCSlHceFoMKJW8W9EU9cvic/QdsZ0kEU93HEy3IUEFZIiH/3w+AH/UQbPHNdhA== + dependencies: + call-bind "^1.0.2" is-stream@^2.0.0: version "2.0.1" @@ -4564,14 +5217,25 @@ is-symbol@^1.0.2, is-symbol@^1.0.3: is-text-path@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/is-text-path/-/is-text-path-1.0.1.tgz#4e1aa0fb51bfbcb3e92688001397202c1775b66e" - integrity sha1-Thqg+1G/vLPpJogAE5cgLBd1tm4= + integrity sha512-xFuJpne9oFz5qDaodwmmG08e3CawH/2ZV8Qqza1Ko7Sk8POWbkRdwIoAWVhqvq0XeUzANEhKo2n0IXUGBm7A/w== dependencies: text-extensions "^1.0.0" +is-typed-array@^1.1.10, is-typed-array@^1.1.3, is-typed-array@^1.1.9: + version "1.1.10" + resolved "https://registry.yarnpkg.com/is-typed-array/-/is-typed-array-1.1.10.tgz#36a5b5cb4189b575d1a3e4b08536bfb485801e3f" + integrity sha512-PJqgEHiWZvMpaFZ3uTc8kHPM4+4ADTlDniuQL7cU/UDA0Ql7F70yGfHph3cLNe+c9toaigv+DFzTJKhc2CtO6A== + dependencies: + available-typed-arrays "^1.0.5" + call-bind "^1.0.2" + for-each "^0.3.3" + gopd "^1.0.1" + has-tostringtag "^1.0.0" + is-typedarray@^1.0.0, is-typedarray@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a" - integrity sha1-5HnICFjfDBsR3dppQPlgEfzaSpo= + integrity sha512-cyA56iCMHAh5CdzjJIa4aohJyeO1YbwLi3Jc35MmRU6poroFjIGZzUzupGiRPOjgHg9TLu43xbpwXk523fMxKA== is-unc-path@^1.0.0: version "1.0.0" @@ -4583,19 +5247,19 @@ is-unc-path@^1.0.0: is-utf8@^0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/is-utf8/-/is-utf8-0.2.1.tgz#4b0da1442104d1b336340e80797e865cf39f7d72" - integrity sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI= + integrity sha512-rMYPYvCzsXywIsldgLaSoPlw5PfoB/ssr7hY4pLfcodrA5M/eArza1a9VmTiNIBNMjOGr1Ow9mTyU2o69U6U9Q== is-valid-glob@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-valid-glob/-/is-valid-glob-1.0.0.tgz#29bf3eff701be2d4d315dbacc39bc39fe8f601aa" - integrity sha1-Kb8+/3Ab4tTTFdusw5vDn+j2Aao= + integrity sha512-AhiROmoEFDSsjx8hW+5sGwgKVIORcXnrlAx/R0ZSeaPw70Vw0CqkGBBhHGL58Uox2eXnU1AnvXJl1XlyedO5bA== -is-weakref@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/is-weakref/-/is-weakref-1.0.1.tgz#842dba4ec17fa9ac9850df2d6efbc1737274f2a2" - integrity sha512-b2jKc2pQZjaeFYWEf7ScFj+Be1I+PXmlu572Q8coTXZ+LD/QQZ7ShPMst8h16riVgyXTQwUsFEl74mDvc/3MHQ== +is-weakref@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-weakref/-/is-weakref-1.0.2.tgz#9529f383a9338205e89765e0392efc2f100f06f2" + integrity sha512-qctsuLZmIQ0+vSSMfoVvyFe2+GSEvnmZ2ezTup1SBse9+twCCeial6EEi3Nc2KFcf6+qz2FBPnjXsk8xhKSaPQ== dependencies: - call-bind "^1.0.0" + call-bind "^1.0.2" is-windows@^1.0.1, is-windows@^1.0.2: version "1.0.2" @@ -4612,22 +5276,27 @@ is-wsl@^2.1.1: isarray@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf" - integrity sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8= + integrity sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ== isarray@^1.0.0, isarray@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" - integrity sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE= + integrity sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ== + +isarray@^2.0.5: + version "2.0.5" + resolved "https://registry.yarnpkg.com/isarray/-/isarray-2.0.5.tgz#8af1e4c1221244cc62459faf38940d4e644a5723" + integrity sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw== isexe@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" - integrity sha1-6PvzdNxVb/iUehDcsFctYz8s+hA= + integrity sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw== isstream@~0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" - integrity sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo= + integrity sha512-Yljz7ffyPbrLpLngrMtZ7NduUgVvi6wG9RJ9IUcyCd59YQ911PBJphODUcbOVbqYfxe1wuYf/LJ8PauMRwsM/g== issue-parser@^6.0.0: version "6.0.0" @@ -4640,7 +5309,7 @@ issue-parser@^6.0.0: lodash.isstring "^4.0.1" lodash.uniqby "^4.7.0" -istanbul-lib-coverage@^3.0.0, istanbul-lib-coverage@^3.0.0-alpha.1: +istanbul-lib-coverage@^3.0.0, istanbul-lib-coverage@^3.2.0: version "3.2.0" resolved "https://registry.yarnpkg.com/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.0.tgz#189e7909d0a39fa5a3dfad5b03f71947770191d3" integrity sha512-eOeJ5BHCmHYvQK7xt9GkdHuzuCGS1Y6g9Gvnx3Ym33fz/HpLRYxiS0wHNr+m/MBC8B647Xt608vCDEvhl9c6Mw== @@ -4663,17 +5332,16 @@ istanbul-lib-instrument@^4.0.0: semver "^6.3.0" istanbul-lib-processinfo@^2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/istanbul-lib-processinfo/-/istanbul-lib-processinfo-2.0.2.tgz#e1426514662244b2f25df728e8fd1ba35fe53b9c" - integrity sha512-kOwpa7z9hme+IBPZMzQ5vdQj8srYgAtaRqeI48NGmAQ+/5yKiHLV0QbYqQpxsdEF0+w14SoB8YbnHKcXE2KnYw== + version "2.0.3" + resolved "https://registry.yarnpkg.com/istanbul-lib-processinfo/-/istanbul-lib-processinfo-2.0.3.tgz#366d454cd0dcb7eb6e0e419378e60072c8626169" + integrity sha512-NkwHbo3E00oybX6NGJi6ar0B29vxyvNwoC7eJ4G4Yq28UfY758Hgn/heV8VRFhevPED4LXfFz0DQ8z/0kw9zMg== dependencies: archy "^1.0.0" - cross-spawn "^7.0.0" - istanbul-lib-coverage "^3.0.0-alpha.1" - make-dir "^3.0.0" + cross-spawn "^7.0.3" + istanbul-lib-coverage "^3.2.0" p-map "^3.0.0" rimraf "^3.0.0" - uuid "^3.3.3" + uuid "^8.3.2" istanbul-lib-report@^3.0.0: version "3.0.0" @@ -4694,9 +5362,9 @@ istanbul-lib-source-maps@^4.0.0: source-map "^0.6.1" istanbul-reports@^3.0.2: - version "3.0.5" - resolved "https://registry.yarnpkg.com/istanbul-reports/-/istanbul-reports-3.0.5.tgz#a2580107e71279ea6d661ddede929ffc6d693384" - integrity sha512-5+19PlhnGabNWB7kOFnuxT8H3T/iIyQzIbQMxXsURmmvKg86P2sbkrGOT77VnHw0Qr0gc2XzRaRfMZYYbSQCJQ== + version "3.1.5" + resolved "https://registry.yarnpkg.com/istanbul-reports/-/istanbul-reports-3.1.5.tgz#cc9a6ab25cb25659810e4785ed9d9fb742578bae" + integrity sha512-nUsEMa9pBt/NOHqbcbeJEgqIlY/K7rVWUX6Lql2orY5e9roQOthbR3vtY4zzf2orPELg80fnxxk9zUyPlgwD1w== dependencies: html-escaper "^2.0.0" istanbul-lib-report "^3.0.0" @@ -4706,10 +5374,10 @@ java-properties@^1.0.0: resolved "https://registry.yarnpkg.com/java-properties/-/java-properties-1.0.2.tgz#ccd1fa73907438a5b5c38982269d0e771fe78211" integrity sha512-qjdpeo2yKlYTH7nFdK0vbZWuTCesk4o63v5iVOlhMQPfuIZQfW/HI35SjfhA+4qpg36rnFSvUK5b1m+ckIblQQ== -jmespath@0.15.0: - version "0.15.0" - resolved "https://registry.yarnpkg.com/jmespath/-/jmespath-0.15.0.tgz#a3f222a9aae9f966f5d27c796510e28091764217" - integrity sha1-o/Iiqarp+Wb10nx5ZRDigJF2Qhc= +jmespath@0.16.0: + version "0.16.0" + resolved "https://registry.yarnpkg.com/jmespath/-/jmespath-0.16.0.tgz#b15b0a85dfd4d930d43e69ed605943c802785076" + integrity sha512-9FzQjJ7MATs1tSpnco1K6ayiYE3figslrXA72G2HQ/n76RzvYlofyi5QM+iX4YRs/pu3yzxlVQSST23+dMDknw== js-combinatorics@^0.6.1: version "0.6.1" @@ -4724,7 +5392,7 @@ js-combinatorics@^0.6.1: js-tokens@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b" - integrity sha1-mGbfOVECEw449/mWvOtlRDIJwls= + integrity sha512-RjTcuD4xjtthQkaWH7dFlH85L+QaVtSoOyGdZ3g6HFhS9dFNDfLyqgm2NFe2X6cQpeFmt0452FJjFG5UameExg== js-yaml@3.13.1: version "3.13.1" @@ -4757,17 +5425,17 @@ jsbi@^3.1.1: jsbn@~0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513" - integrity sha1-peZUwuWi3rXyAdls77yoDA7y9RM= + integrity sha512-UVU9dibq2JcFWxQPA6KCqj5O42VOmAY3zQUfEKxU0KpTGXwNoCjkX1e13eHNvw/xPynt6pU0rZ1htjWTNTSXsg== -jsdoc-type-pratt-parser@2.0.0, jsdoc-type-pratt-parser@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/jsdoc-type-pratt-parser/-/jsdoc-type-pratt-parser-2.0.0.tgz#ec739a0868922515fcb179852e990e89b52b9044" - integrity sha512-sUuj2j48wxrEpbFjDp1sAesAxPiLT+z0SWVmMafyIINs6Lj5gIPKh3VrkBZu4E/Dv+wHpOot0m6H8zlHQjwqeQ== +jsdoc-type-pratt-parser@~2.2.3: + version "2.2.5" + resolved "https://registry.yarnpkg.com/jsdoc-type-pratt-parser/-/jsdoc-type-pratt-parser-2.2.5.tgz#c9f93afac7ee4b5ed4432fe3f09f7d36b05ed0ff" + integrity sha512-2a6eRxSxp1BW040hFvaJxhsCMI9lT8QB8t14t+NY5tC5rckIR0U9cr2tjOeaFirmEOy6MHvmJnY7zTBHq431Lw== jsdom@^7.0.2: version "7.2.2" resolved "https://registry.yarnpkg.com/jsdom/-/jsdom-7.2.2.tgz#40b402770c2bda23469096bee91ab675e3b1fc6e" - integrity sha1-QLQCdwwr2iNGkJa+6Rq2deOx/G4= + integrity sha512-kYeYuos/pYp0V/V8VAoGnUc0va0UZjTjwCsldBFZNBrOi9Q5kUXrvsw6W5/lQllB7hKXBARC4HRk1Sfk4dPFtA== dependencies: abab "^1.0.0" acorn "^2.4.0" @@ -4788,13 +5456,20 @@ jsdom@^7.0.2: jsesc@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-1.3.0.tgz#46c3fec8c1892b12b0833db9bc7622176dbab34b" - integrity sha1-RsP+yMGJKxKwgz25vHYiF226s0s= + integrity sha512-Mke0DA0QjUWuJlhsE0ZPPhYiJkRap642SmI/4ztCFaUs6V2AiH1sfecc+57NgaryfAA2VR3v6O+CSjC1jZJKOA== jsesc@^2.5.1: version "2.5.2" resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-2.5.2.tgz#80564d2e483dacf6e8ef209650a67df3f0c283a4" integrity sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA== +json-bigint@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/json-bigint/-/json-bigint-1.0.0.tgz#ae547823ac0cad8398667f8cd9ef4730f5b01ff1" + integrity sha512-SiPv/8VpZuWbvLSMtTDU8hEfrZWg/mH/nV/b4o0CYbSxu1UIQPLdwKOCIyLQX+VIPO5vrLX3i8qtqFyhdPSUSQ== + dependencies: + bignumber.js "^9.0.0" + json-parse-better-errors@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz#bb867cfb3450e69107c131d1c514bab3dc8bcaa9" @@ -4810,7 +5485,7 @@ json-schema-traverse@^0.4.1: resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660" integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg== -json-schema@0.4.0, json-schema@^0.4.0: +json-schema@0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/json-schema/-/json-schema-0.4.0.tgz#f7de4cf6efab838ebaeb3236474cbba5a1930ab5" integrity sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA== @@ -4818,7 +5493,7 @@ json-schema@0.4.0, json-schema@^0.4.0: json-stable-stringify-without-jsonify@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651" - integrity sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE= + integrity sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw== json-stringify-nice@^1.1.4: version "1.1.4" @@ -4828,14 +5503,12 @@ json-stringify-nice@^1.1.4: json-stringify-safe@^5.0.1, json-stringify-safe@~5.0.1: version "5.0.1" resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" - integrity sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus= + integrity sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA== -json5@^2.1.2: - version "2.2.0" - resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.0.tgz#2dfefe720c6ba525d9ebd909950f0515316c89a3" - integrity sha512-f+8cldu7X/y7RAJurMEJmdoKXGB/X550w2Nr3tTbezL6RwEE/iMcm+tZnXeoZtKuOq6ft8+CqzEkrIgx1fPoQA== - dependencies: - minimist "^1.2.5" +json5@^2.2.2: + version "2.2.3" + resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.3.tgz#78cd6f1a19bdc12b73db5ad0c61efd66c1e29283" + integrity sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg== jsonc-parser@~3.0.0: version "3.0.0" @@ -4845,14 +5518,14 @@ jsonc-parser@~3.0.0: jsonfile@^2.1.0: version "2.4.0" resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-2.4.0.tgz#3736a2b428b87bbda0cc83b53fa3d633a35c2ae8" - integrity sha1-NzaitCi4e72gzIO1P6PWM6NcKug= + integrity sha512-PKllAqbgLgxHaj8TElYymKCAgrASebJrWpTnEkOaTowt23VKXXN0sUeriJ+eh7y6ufb/CC5ap11pz71/cM0hUw== optionalDependencies: graceful-fs "^4.1.6" jsonfile@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb" - integrity sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss= + integrity sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg== optionalDependencies: graceful-fs "^4.1.6" @@ -4868,23 +5541,17 @@ jsonfile@^6.0.1: jsonparse@^1.2.0, jsonparse@^1.3.1: version "1.3.1" resolved "https://registry.yarnpkg.com/jsonparse/-/jsonparse-1.3.1.tgz#3f4dae4a91fac315f71062f8521cc239f1366280" - integrity sha1-P02uSpH6wxX3EGL4UhzCOfE2YoA= + integrity sha512-POQXvpdL69+CluYsillJ7SUhKvytYjW9vG/GKpnf+xP8UWgYEM/RaMzHHofbALDiKbbP1W8UEYmgGl39WkPZsg== -jsonwebtoken@^8.5.1: - version "8.5.1" - resolved "https://registry.yarnpkg.com/jsonwebtoken/-/jsonwebtoken-8.5.1.tgz#00e71e0b8df54c2121a1f26137df2280673bcc0d" - integrity sha512-XjwVfRS6jTMsqYs0EsuJ4LGxXV14zQybNd4L2r0UvbVnSF9Af8x7p5MzbJ90Ioz/9TI41/hTCvznF/loiSzn8w== +jsonwebtoken@^9.0.0: + version "9.0.0" + resolved "https://registry.yarnpkg.com/jsonwebtoken/-/jsonwebtoken-9.0.0.tgz#d0faf9ba1cc3a56255fe49c0961a67e520c1926d" + integrity sha512-tuGfYXxkQGDPnLJ7SibiQgVgeDgfbPq2k2ICcbgqW8WxWLBAxKQM/ZCu/IT8SOSwmaYl4dpTFCW5xZv7YbbWUw== dependencies: jws "^3.2.2" - lodash.includes "^4.3.0" - lodash.isboolean "^3.0.3" - lodash.isinteger "^4.0.4" - lodash.isnumber "^3.0.3" - lodash.isplainobject "^4.0.6" - lodash.isstring "^4.0.1" - lodash.once "^4.0.0" + lodash "^4.17.21" ms "^2.1.1" - semver "^5.6.0" + semver "^7.3.8" jsprim@^1.2.2: version "1.4.2" @@ -4896,16 +5563,6 @@ jsprim@^1.2.2: json-schema "0.4.0" verror "1.10.0" -jsprim@^2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-2.0.2.tgz#77ca23dbcd4135cd364800d22ff82c2185803d4d" - integrity sha512-gqXddjPqQ6G40VdnI6T6yObEC+pDNvyP95wdQhkWkg7crHH3km5qP1FsOXEkzEQwnz6gz5qGTn1c2Y52wP3OyQ== - dependencies: - assert-plus "1.0.0" - extsprintf "1.3.0" - json-schema "0.4.0" - verror "1.10.0" - just-diff-apply@^3.0.0: version "3.1.2" resolved "https://registry.yarnpkg.com/just-diff-apply/-/just-diff-apply-3.1.2.tgz#710d8cda00c65dc4e692df50dbe9bac5581c2193" @@ -4930,6 +5587,15 @@ jwa@^1.4.1: ecdsa-sig-formatter "1.0.11" safe-buffer "^5.0.1" +jwa@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/jwa/-/jwa-2.0.0.tgz#a7e9c3f29dae94027ebcaf49975c9345593410fc" + integrity sha512-jrZ2Qx916EA+fq9cEAeCROWPTfCwi1IVHqT2tapuqLEVVDKFDENFw1oL+MwrTvH6msKxsd1YTDVw6uKEcsrLEA== + dependencies: + buffer-equal-constant-time "1.0.1" + ecdsa-sig-formatter "1.0.11" + safe-buffer "^5.0.1" + jws@3.x.x, jws@^3.2.2: version "3.2.2" resolved "https://registry.yarnpkg.com/jws/-/jws-3.2.2.tgz#001099f3639468c9414000e99995fa52fb478304" @@ -4938,6 +5604,14 @@ jws@3.x.x, jws@^3.2.2: jwa "^1.4.1" safe-buffer "^5.0.1" +jws@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/jws/-/jws-4.0.0.tgz#2d4e8cf6a318ffaa12615e9dec7e86e6c97310f4" + integrity sha512-KDncfTmOZoOMTFG4mBlG0qUIOlc03fmzH+ru6RgYVZhPkyiy/92Owlt/8UEN+a4TXR1FQetfIpJE8ApdvdVxTg== + dependencies: + jwa "^2.0.0" + safe-buffer "^5.0.1" + kind-of@^6.0.3: version "6.0.3" resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd" @@ -4946,7 +5620,7 @@ kind-of@^6.0.3: klaw@^1.0.0: version "1.3.1" resolved "https://registry.yarnpkg.com/klaw/-/klaw-1.3.1.tgz#4088433b46b3b1ba259d78785d8e96f73ba02439" - integrity sha1-QIhDO0azsbolnXh4XY6W9zugJDk= + integrity sha512-TED5xi9gGQjGpNnvRWknrwAB1eL5GciPfVFOt3Vk1OJCVDQbzuSfrF3hkUQKlsgKrG1F+0t5W0m+Fje1jIt8rw== optionalDependencies: graceful-fs "^4.1.9" @@ -4963,18 +5637,19 @@ lazystream@^1.0.0: readable-stream "^2.0.5" lcov-result-merger@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/lcov-result-merger/-/lcov-result-merger-3.1.0.tgz#ae6d1be663dbf7d586d8004642359d39de72039e" - integrity sha512-vGXaMNGZRr4cYvW+xMVg+rg7qd5DX9SbGXl+0S3k85+gRZVK4K7UvxPWzKb/qiMwe+4bx3EOrW2o4mbdb1WnsA== + version "3.3.0" + resolved "https://registry.yarnpkg.com/lcov-result-merger/-/lcov-result-merger-3.3.0.tgz#66d4b12ced4830855404db82622ac9e450304205" + integrity sha512-Krg9p24jGaIT93RBMA8b5qLHDEiAXTavaTiEdMAZaJS93PsBKIcg/89cw/8rgeSfRuQX+I9x7h73SHFjCZ6cHg== dependencies: through2 "^2.0.3" vinyl "^2.1.0" vinyl-fs "^3.0.2" + yargs "^16.2.0" lead@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/lead/-/lead-1.0.0.tgz#6f14f99a37be3a9dd784f5495690e5903466ee42" - integrity sha1-bxT5mje+Op3XhPVJVpDlkDRm7kI= + integrity sha512-IpSVCk9AYvLHo5ctcIXxOBpMWUe+4TKN3VPWAKUbJikkmsGp0VrSM8IttVc32D6J4WUsiPE6aEFRNmIoF/gdow== dependencies: flush-write-stream "^1.0.2" @@ -4989,7 +5664,7 @@ levn@^0.4.1: levn@~0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/levn/-/levn-0.3.0.tgz#3b09924edf9f083c0490fdd4c0bc4421e04764ee" - integrity sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4= + integrity sha512-0OO4y2iOHix2W6ujICbKIaEQXvFQHue65vUG3pb5EUomzPI90z9hsA1VsO/dbIIpC53J8gxM9Q4Oho0jrCM/yA== dependencies: prelude-ls "~1.1.2" type-check "~0.3.2" @@ -5104,10 +5779,10 @@ libnpmversion@^1.2.1: semver "^7.3.5" stringify-package "^1.0.1" -lilconfig@2.0.4: - version "2.0.4" - resolved "https://registry.yarnpkg.com/lilconfig/-/lilconfig-2.0.4.tgz#f4507d043d7058b380b6a8f5cb7bcd4b34cee082" - integrity sha512-bfTIN7lEsiooCocSISTWXkiWJkRqtL9wYtYy+8EK3Y41qh3mpwPU0ycTOgjdY9ErwXCc8QyrQp82bdL0Xkm9yA== +lilconfig@2.0.5: + version "2.0.5" + resolved "https://registry.yarnpkg.com/lilconfig/-/lilconfig-2.0.5.tgz#19e57fd06ccc3848fd1891655b5a447092225b25" + integrity sha512-xaYmXZtTHPAw5m+xLN8ab9C+3a8YmV3asNSPOATITbtwrfbwaLJj8h66H1WMIpALCkqsIzK3h7oQ+PdX+LQ9Eg== lines-and-columns@^1.1.6: version "1.2.4" @@ -5122,47 +5797,48 @@ linkify-it@^3.0.1: uc.micro "^1.0.1" lint-staged@^12.1.4: - version "12.1.4" - resolved "https://registry.yarnpkg.com/lint-staged/-/lint-staged-12.1.4.tgz#a92ec8509f13018caaafade61d515c2d5873316e" - integrity sha512-RgDz9nsFsE0/5eL9Vat0AvCuk0+j5mEuzBIVfrRH5FRtt5wibYe8zTjZs2nuqLFrLAGQGYnj8+HJxolcj08i/A== + version "12.5.0" + resolved "https://registry.yarnpkg.com/lint-staged/-/lint-staged-12.5.0.tgz#d6925747480ae0e380d13988522f9dd8ef9126e3" + integrity sha512-BKLUjWDsKquV/JuIcoQW4MSAI3ggwEImF1+sB4zaKvyVx1wBk3FsG7UK9bpnmBTN1pm7EH2BBcMwINJzCRv12g== dependencies: cli-truncate "^3.1.0" colorette "^2.0.16" - commander "^8.3.0" - debug "^4.3.3" + commander "^9.3.0" + debug "^4.3.4" execa "^5.1.1" - lilconfig "2.0.4" - listr2 "^3.13.5" - micromatch "^4.0.4" + lilconfig "2.0.5" + listr2 "^4.0.5" + micromatch "^4.0.5" normalize-path "^3.0.0" - object-inspect "^1.11.1" + object-inspect "^1.12.2" + pidtree "^0.5.0" string-argv "^0.3.1" - supports-color "^9.2.1" + supports-color "^9.2.2" yaml "^1.10.2" listenercount@~1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/listenercount/-/listenercount-1.0.1.tgz#84c8a72ab59c4725321480c975e6508342e70937" - integrity sha1-hMinKrWcRyUyFIDJdeZQg0LnCTc= + integrity sha512-3mk/Zag0+IJxeDrxSgaDPy4zZ3w05PRZeJNnlWhzFz5OkX49J4krc+A8X2d2M69vGMBEX0uyl8M+W+8gH+kBqQ== -listr2@^3.13.5: - version "3.13.5" - resolved "https://registry.yarnpkg.com/listr2/-/listr2-3.13.5.tgz#105a813f2eb2329c4aae27373a281d610ee4985f" - integrity sha512-3n8heFQDSk+NcwBn3CgxEibZGaRzx+pC64n3YjpMD1qguV4nWus3Al+Oo3KooqFKTQEJ1v7MmnbnyyNspgx3NA== +listr2@^4.0.5: + version "4.0.5" + resolved "https://registry.yarnpkg.com/listr2/-/listr2-4.0.5.tgz#9dcc50221583e8b4c71c43f9c7dfd0ef546b75d5" + integrity sha512-juGHV1doQdpNT3GSTs9IUN43QJb7KHdF9uqg7Vufs/tG9VTzpFphqF4pm/ICdAABGQxsyNn9CiYA3StkI6jpwA== dependencies: cli-truncate "^2.1.0" colorette "^2.0.16" log-update "^4.0.0" p-map "^4.0.0" rfdc "^1.3.0" - rxjs "^7.4.0" + rxjs "^7.5.5" through "^2.3.8" wrap-ansi "^7.0.0" load-json-file@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-4.0.0.tgz#2f5f45ab91e33216234fd53adab668eb4ec0993b" - integrity sha1-L19Fq5HjMhYjT9U62rZo607AmTs= + integrity sha512-Kx8hMakjX03tiGTLAIdJ+lL0htKnXjEZN6hk/tozf/WOuYGdZBJrZ+rCJRbVCugsjB3jMLn9746NsQIf5VjBMw== dependencies: graceful-fs "^4.1.2" parse-json "^4.0.0" @@ -5172,7 +5848,7 @@ load-json-file@^4.0.0: locate-path@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-2.0.0.tgz#2b568b265eec944c6d9c0de9c3dbbbca0354cd8e" - integrity sha1-K1aLJl7slExtnA3pw9u7ygNUzY4= + integrity sha512-NCI2kiDkyR7VeEKm27Kda/iQHyKJe1Bu0FlTbYp3CqJu+9IFe9bLyAjMxf5ZDDbEg+iMPzB5zYyUTSm8wVTKmA== dependencies: p-locate "^2.0.0" path-exists "^3.0.0" @@ -5202,132 +5878,107 @@ locate-path@^6.0.0: lodash.assignin@^4.0.9: version "4.2.0" resolved "https://registry.yarnpkg.com/lodash.assignin/-/lodash.assignin-4.2.0.tgz#ba8df5fb841eb0a3e8044232b0e263a8dc6a28a2" - integrity sha1-uo31+4QesKPoBEIysOJjqNxqKKI= + integrity sha512-yX/rx6d/UTVh7sSVWVSIMjfnz95evAgDFdb1ZozC35I9mSFCkmzptOzevxjgbQUsc78NR44LVHWjsoMQXy9FDg== lodash.bind@^4.1.4: version "4.2.1" resolved "https://registry.yarnpkg.com/lodash.bind/-/lodash.bind-4.2.1.tgz#7ae3017e939622ac31b7d7d7dcb1b34db1690d35" - integrity sha1-euMBfpOWIqwxt9fX3LGzTbFpDTU= + integrity sha512-lxdsn7xxlCymgLYo1gGvVrfHmkjDiyqVv62FAeF2i5ta72BipE1SLxw8hPEPLhD4/247Ijw07UQH7Hq/chT5LA== lodash.capitalize@^4.2.1: version "4.2.1" resolved "https://registry.yarnpkg.com/lodash.capitalize/-/lodash.capitalize-4.2.1.tgz#f826c9b4e2a8511d84e3aca29db05e1a4f3b72a9" - integrity sha1-+CbJtOKoUR2E46yinbBeGk87cqk= + integrity sha512-kZzYOKspf8XVX5AvmQF94gQW0lejFVgb80G85bU4ZWzoJ6C03PQg3coYAUpSTpQWelrZELd3XWgHzw4Ck5kaIw== lodash.defaults@^4.0.1: version "4.2.0" resolved "https://registry.yarnpkg.com/lodash.defaults/-/lodash.defaults-4.2.0.tgz#d09178716ffea4dde9e5fb7b37f6f0802274580c" - integrity sha1-0JF4cW/+pN3p5ft7N/bwgCJ0WAw= + integrity sha512-qjxPLHd3r5DnsdGacqOMU6pb/avJzdh9tFX2ymgoZE27BmjXrNy/y4LoaiTeAb+O3gL8AfpJGtqfX/ae2leYYQ== lodash.differencewith@~4.5.0: version "4.5.0" resolved "https://registry.yarnpkg.com/lodash.differencewith/-/lodash.differencewith-4.5.0.tgz#bafafbc918b55154e179176a00bb0aefaac854b7" - integrity sha1-uvr7yRi1UVTheRdqALsK76rIVLc= + integrity sha512-/8JFjydAS+4bQuo3CpLMBv7WxGFyk7/etOAsrQUCu0a9QVDemxv0YQ0rFyeZvqlUD314SERfNlgnlqqHmaQ0Cg== lodash.escaperegexp@^4.1.2: version "4.1.2" resolved "https://registry.yarnpkg.com/lodash.escaperegexp/-/lodash.escaperegexp-4.1.2.tgz#64762c48618082518ac3df4ccf5d5886dae20347" - integrity sha1-ZHYsSGGAglGKw99Mz11YhtriA0c= + integrity sha512-TM9YBvyC84ZxE3rgfefxUWiQKLilstD6k7PTGt6wfbtXF8ixIJLOL3VYyV/z+ZiPLsVxAsKAFVwWlWeb2Y8Yyw== lodash.filter@^4.4.0: version "4.6.0" resolved "https://registry.yarnpkg.com/lodash.filter/-/lodash.filter-4.6.0.tgz#668b1d4981603ae1cc5a6fa760143e480b4c4ace" - integrity sha1-ZosdSYFgOuHMWm+nYBQ+SAtMSs4= + integrity sha512-pXYUy7PR8BCLwX5mgJ/aNtyOvuJTdZAo9EQFUvMIYugqmJxnrYaANvTbgndOzHSCSR0wnlBBfRXJL5SbWxo3FQ== lodash.flatten@^4.2.0, lodash.flatten@~4.4.0: version "4.4.0" resolved "https://registry.yarnpkg.com/lodash.flatten/-/lodash.flatten-4.4.0.tgz#f31c22225a9632d2bbf8e4addbef240aa765a61f" - integrity sha1-8xwiIlqWMtK7+OSt2+8kCqdlph8= + integrity sha512-C5N2Z3DgnnKr0LOpv/hKCgKdb7ZZwafIrsesve6lmzvZIRZRGaZ/l6Q8+2W7NaT+ZwO3fFlSCzCzrDCFdJfZ4g== lodash.flattendeep@^4.4.0: version "4.4.0" resolved "https://registry.yarnpkg.com/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz#fb030917f86a3134e5bc9bec0d69e0013ddfedb2" - integrity sha1-+wMJF/hqMTTlvJvsDWngAT3f7bI= + integrity sha512-uHaJFihxmJcEX3kT4I23ABqKKalJ/zDrDg0lsFtc1h+3uw49SIJ5beyhx5ExVRti3AvKoOJngIj7xz3oylPdWQ== lodash.foreach@^4.3.0: version "4.5.0" resolved "https://registry.yarnpkg.com/lodash.foreach/-/lodash.foreach-4.5.0.tgz#1a6a35eace401280c7f06dddec35165ab27e3e53" - integrity sha1-Gmo16s5AEoDH8G3d7DUWWrJ+PlM= + integrity sha512-aEXTF4d+m05rVOAUG3z4vZZ4xVexLKZGF0lIxuHZ1Hplpk/3B6Z1+/ICICYRLm7c41Z2xiejbkCkJoTlypoXhQ== lodash.get@^4, lodash.get@^4.4.2: version "4.4.2" resolved "https://registry.yarnpkg.com/lodash.get/-/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99" - integrity sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk= - -lodash.includes@^4.3.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/lodash.includes/-/lodash.includes-4.3.0.tgz#60bb98a87cb923c68ca1e51325483314849f553f" - integrity sha1-YLuYqHy5I8aMoeUTJUgzFISfVT8= - -lodash.isboolean@^3.0.3: - version "3.0.3" - resolved "https://registry.yarnpkg.com/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz#6c2e171db2a257cd96802fd43b01b20d5f5870f6" - integrity sha1-bC4XHbKiV82WgC/UOwGyDV9YcPY= - -lodash.isinteger@^4.0.4: - version "4.0.4" - resolved "https://registry.yarnpkg.com/lodash.isinteger/-/lodash.isinteger-4.0.4.tgz#619c0af3d03f8b04c31f5882840b77b11cd68343" - integrity sha1-YZwK89A/iwTDH1iChAt3sRzWg0M= + integrity sha512-z+Uw/vLuy6gQe8cfaFWD7p0wVv8fJl3mbzXh33RS+0oW2wvUqiRXiQ69gLWSLpgB5/6sU+r6BlQR0MBILadqTQ== lodash.ismatch@^4.4.0: version "4.4.0" resolved "https://registry.yarnpkg.com/lodash.ismatch/-/lodash.ismatch-4.4.0.tgz#756cb5150ca3ba6f11085a78849645f188f85f37" - integrity sha1-dWy1FQyjum8RCFp4hJZF8Yj4Xzc= - -lodash.isnumber@^3.0.3: - version "3.0.3" - resolved "https://registry.yarnpkg.com/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz#3ce76810c5928d03352301ac287317f11c0b1ffc" - integrity sha1-POdoEMWSjQM1IwGsKHMX8RwLH/w= + integrity sha512-fPMfXjGQEV9Xsq/8MTSgUf255gawYRbjwMyDbcvDhXgV7enSZA0hynz6vMPnpAb5iONEzBHBPsT+0zes5Z301g== lodash.isplainobject@^4.0.6: version "4.0.6" resolved "https://registry.yarnpkg.com/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz#7c526a52d89b45c45cc690b88163be0497f550cb" - integrity sha1-fFJqUtibRcRcxpC4gWO+BJf1UMs= + integrity sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA== lodash.isstring@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/lodash.isstring/-/lodash.isstring-4.0.1.tgz#d527dfb5456eca7cc9bb95d5daeaf88ba54a5451" - integrity sha1-1SfftUVuynzJu5XV2ur4i6VKVFE= + integrity sha512-0wJxfxH1wgO3GrbuP+dTTk7op+6L41QCXbGINEmD+ny/G/eCqGzxyCsh7159S+mgDDcoarnBw6PC1PS5+wUGgw== lodash.map@^4.4.0: version "4.6.0" resolved "https://registry.yarnpkg.com/lodash.map/-/lodash.map-4.6.0.tgz#771ec7839e3473d9c4cde28b19394c3562f4f6d3" - integrity sha1-dx7Hg540c9nEzeKLGTlMNWL09tM= + integrity sha512-worNHGKLDetmcEYDvh2stPCrrQRkP20E4l0iIS7F8EvzMqBBi7ltvFN5m1HvTf1P7Jk1txKhvFcmYsCr8O2F1Q== lodash.merge@^4.4.0, lodash.merge@^4.6.2: version "4.6.2" resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a" integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ== -lodash.once@^4.0.0: - version "4.1.1" - resolved "https://registry.yarnpkg.com/lodash.once/-/lodash.once-4.1.1.tgz#0dd3971213c7c56df880977d504c88fb471a97ac" - integrity sha1-DdOXEhPHxW34gJd9UEyI+0cal6w= - lodash.pick@^4.2.1: version "4.4.0" resolved "https://registry.yarnpkg.com/lodash.pick/-/lodash.pick-4.4.0.tgz#52f05610fff9ded422611441ed1fc123a03001b3" - integrity sha1-UvBWEP/53tQiYRRB7R/BI6AwAbM= + integrity sha512-hXt6Ul/5yWjfklSGvLQl8vM//l3FtyHZeuelpzK6mm99pNvN9yTDruNZPEJZD1oWrqo+izBmB7oUfWgcCX7s4Q== lodash.reduce@^4.4.0: version "4.6.0" resolved "https://registry.yarnpkg.com/lodash.reduce/-/lodash.reduce-4.6.0.tgz#f1ab6b839299ad48f784abbf476596f03b914d3b" - integrity sha1-8atrg5KZrUj3hKu/R2WW8DuRTTs= + integrity sha512-6raRe2vxCYBhpBu+B+TtNGUzah+hQjVdu3E17wfusjyrXBka2nBS8OH/gjVZ5PvHOhWmIZTYri09Z6n/QfnNMw== lodash.reject@^4.4.0: version "4.6.0" resolved "https://registry.yarnpkg.com/lodash.reject/-/lodash.reject-4.6.0.tgz#80d6492dc1470864bbf583533b651f42a9f52415" - integrity sha1-gNZJLcFHCGS79YNTO2UfQqn1JBU= + integrity sha512-qkTuvgEzYdyhiJBx42YPzPo71R1aEr0z79kAv7Ixg8wPFEjgRgJdUsGMG3Hf3OYSF/kHI79XhNlt+5Ar6OzwxQ== lodash.some@^4.4.0: version "4.6.0" resolved "https://registry.yarnpkg.com/lodash.some/-/lodash.some-4.6.0.tgz#1bb9f314ef6b8baded13b549169b2a945eb68e4d" - integrity sha1-G7nzFO9ri63tE7VJFpsqlF62jk0= + integrity sha512-j7MJE+TuT51q9ggt4fSgVqro163BEFjAt3u97IqU+JA2DkWl80nFTrowzLpZ/BnpN7rrl0JA/593NAdd8p/scQ== lodash.uniqby@^4.7.0: version "4.7.0" resolved "https://registry.yarnpkg.com/lodash.uniqby/-/lodash.uniqby-4.7.0.tgz#d99c07a669e9e6d24e1362dfe266c67616af1302" - integrity sha1-2ZwHpmnp5tJOE2Lf4mbGdhavEwI= + integrity sha512-e/zcLx6CSbmaEgFHCA7BnoQKyCtKMxnuWrJygbwPs/AIn+IMKl66L8/s+wBUn5LRw2pZx3bUHibiV1b6aTWIww== lodash@^4.1.0, lodash@^4.15.0, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.21, lodash@^4.17.4, lodash@^4.2.0: version "4.17.21" @@ -5351,15 +6002,16 @@ log-update@^4.0.0: slice-ansi "^4.0.0" wrap-ansi "^6.2.0" -logform@^2.2.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/logform/-/logform-2.3.0.tgz#a3997a05985de2ebd325ae0d166dffc9c6fe6b57" - integrity sha512-graeoWUH2knKbGthMtuG1EfaSPMZFZBIrhuJHhkS5ZseFBrc7DupCzihOQAzsK/qIKPQaPJ/lFQFctILUY5ARQ== +logform@^2.3.2, logform@^2.4.0: + version "2.5.1" + resolved "https://registry.yarnpkg.com/logform/-/logform-2.5.1.tgz#44c77c34becd71b3a42a3970c77929e52c6ed48b" + integrity sha512-9FyqAm9o9NKKfiAKfZoYo9bGXXuwMkxQiQttkT4YjjVtQVIQtK6LmVtlxmCaFswo6N4AfEkHqZTV0taDtPotNg== dependencies: - colors "^1.2.1" + "@colors/colors" "1.5.0" + "@types/triple-beam" "^1.3.2" fecha "^4.2.0" ms "^2.1.1" - safe-stable-stringify "^1.1.0" + safe-stable-stringify "^2.3.1" triple-beam "^1.3.0" long@^4.0.0: @@ -5367,6 +6019,11 @@ long@^4.0.0: resolved "https://registry.yarnpkg.com/long/-/long-4.0.0.tgz#9a7b71cfb7d361a194ea555241c92f7468d5bf28" integrity sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA== +long@^5.2.0: + version "5.2.3" + resolved "https://registry.yarnpkg.com/long/-/long-5.2.3.tgz#a3ba97f3877cf1d778eccbcb048525ebb77499e1" + integrity sha512-lcHwpNoggQTObv5apGNCTdJrO69eHOZMi4BNC+rTLER8iHAqGrUVeLh/irVIM7zTw2bOXA8T6uNPeujwOLg/2Q== + loose-envify@^1.0.0: version "1.4.0" resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf" @@ -5374,13 +6031,19 @@ loose-envify@^1.0.0: dependencies: js-tokens "^3.0.0 || ^4.0.0" -lru-cache@^4.1.3: - version "4.1.5" - resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.5.tgz#8bbe50ea85bed59bc9e33dcab8235ee9bcf443cd" - integrity sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g== +loupe@^2.3.1: + version "2.3.6" + resolved "https://registry.yarnpkg.com/loupe/-/loupe-2.3.6.tgz#76e4af498103c532d1ecc9be102036a21f787b53" + integrity sha512-RaPMZKiMy8/JruncMU5Bt6na1eftNoo++R4Y+N2FrxkDVTrGvcyzFTsaGif4QTeKESheMGegbhw6iUAq+5A8zA== + dependencies: + get-func-name "^2.0.0" + +lru-cache@^5.1.1: + version "5.1.1" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-5.1.1.tgz#1da27e6710271947695daf6848e847f01d84b920" + integrity sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w== dependencies: - pseudomap "^1.0.2" - yallist "^2.1.2" + yallist "^3.0.2" lru-cache@^6.0.0: version "6.0.0" @@ -5389,7 +6052,12 @@ lru-cache@^6.0.0: dependencies: yallist "^4.0.0" -make-dir@^3.0.0, make-dir@^3.0.2: +lru-cache@^7.14.1: + version "7.18.3" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-7.18.3.tgz#f793896e0fd0e954a59dfdd82f0773808df6aa89" + integrity sha512-jumlc0BIUrS3qJGgIkWZsyfAM7NCWiBcCDhnd+3NNM5KbBmLTgHVfWBcg6W+rLUsIpzpERPsvwUP7CckAQSOoA== + +make-dir@^3.0.0, make-dir@^3.0.2, make-dir@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-3.1.0.tgz#415e967046b3a7f1d185277d84aa58203726a13f" integrity sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw== @@ -5426,7 +6094,7 @@ make-fetch-happen@^9.0.1, make-fetch-happen@^9.1.0: map-obj@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-1.0.1.tgz#d933ceb9205d82bdcf4886f6742bdc2b4dea146d" - integrity sha1-2TPOuSBdgr3PSIb2dCvcK03qFG0= + integrity sha512-7N/q3lyZ+LVCp7PzuxrJr4KMbBE2hW7BT7YNia330OFxIf4d3r5zVpicP2650l7CPN6RM9zOJRl3NGpqSiw3Eg== map-obj@^4.0.0: version "4.3.0" @@ -5434,16 +6102,16 @@ map-obj@^4.0.0: integrity sha512-hdN1wVrZbb29eBGiGjJbeP8JbKjq1urkHJ/LIP/NY48MZ1QVXUsQBV1G1zvYFHn1XE06cwjBsOI2K3Ulnj1YXQ== mariadb@^2.5.5: - version "2.5.5" - resolved "https://registry.yarnpkg.com/mariadb/-/mariadb-2.5.5.tgz#a9aff9f1e57231a415a21254489439beb501c803" - integrity sha512-6dklvcKWuuaV1JjAwnE2ezR+jTt7JrZHftgeHHBmjB0wgfaUpdxol1DPWclwMcCrsO9yoM0FuCOiCcCgXc//9Q== + version "2.5.6" + resolved "https://registry.yarnpkg.com/mariadb/-/mariadb-2.5.6.tgz#7314e9287cdba212831ebf16ef3b34dc6a1f0f06" + integrity sha512-zBx7loYY5GzLl8Y6AKxGXfY9DUYIIdGrmEORPOK9FEu0pg5ZLBKCGJuucHwKADxTBxKY7eM4rxndqxRcnMZKIw== dependencies: - "@types/geojson" "^7946.0.7" - "@types/node" "^14.14.28" - denque "^1.5.0" + "@types/geojson" "^7946.0.8" + "@types/node" "^17.0.10" + denque "^2.0.1" iconv-lite "^0.6.3" - long "^4.0.0" - moment-timezone "^0.5.33" + long "^5.2.0" + moment-timezone "^0.5.34" please-upgrade-node "^3.2.0" markdown-it@12.2.0: @@ -5514,7 +6182,7 @@ marked@^2.0.0: mdurl@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/mdurl/-/mdurl-1.0.1.tgz#fe85b2ec75a59037f2adfec100fd6c601761152e" - integrity sha1-/oWy7HWlkDfyrf7BAP1sYBdhFS4= + integrity sha512-/sKlQJCBYVY9Ers9hqzKou4H6V5UWc/M59TH2dvkt+84itfnq7uFOMLpOiOS4ujvHP4etln18fmIxA5R5fll0g== meow@^8.0.0: version "8.1.2" @@ -5538,30 +6206,35 @@ merge-stream@^2.0.0: resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60" integrity sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w== -merge2@^1.3.0: +merge2@^1.3.0, merge2@^1.4.1: version "1.4.1" resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae" integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg== -micromatch@^4.0.2, micromatch@^4.0.4: - version "4.0.4" - resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.4.tgz#896d519dfe9db25fce94ceb7a500919bf881ebf9" - integrity sha512-pRmzw/XUcwXGpD9aI9q/0XOwLNygjETJ8y0ao0wdqprrzDa4YnxLcz7fQRZr8voh8V10kGhABbNcHVk5wHgWwg== +micromatch@^4.0.2, micromatch@^4.0.4, micromatch@^4.0.5: + version "4.0.5" + resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.5.tgz#bc8999a7cbbf77cdc89f132f6e467051b49090c6" + integrity sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA== dependencies: - braces "^3.0.1" - picomatch "^2.2.3" + braces "^3.0.2" + picomatch "^2.3.1" -mime-db@1.51.0: - version "1.51.0" - resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.51.0.tgz#d9ff62451859b18342d960850dc3cfb77e63fb0c" - integrity sha512-5y8A56jg7XVQx2mbv1lu49NR4dokRnhZYTtL+KGfaa27uq4pSTXkwQkFJl4pkRMyNFz/EtYDSkiiEHx3F7UN6g== +mime-db@1.52.0, "mime-db@>= 1.43.0 < 2": + version "1.52.0" + resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70" + integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg== -mime-types@^2.1.12, mime-types@^2.1.29, mime-types@~2.1.19: - version "2.1.34" - resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.34.tgz#5a712f9ec1503511a945803640fafe09d3793c24" - integrity sha512-6cP692WwGIs9XXdOO4++N+7qjqv0rqxxVvJ3VHPh/Sc9mVZcQP+ZGhkKiTvWMQRr2tbHkJP/Yn7Y0npb3ZBs4A== +mime-types@^2.0.8, mime-types@^2.1.12, mime-types@^2.1.29, mime-types@~2.1.19: + version "2.1.35" + resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.35.tgz#381a871b62a734450660ae3deee44813f70d959a" + integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw== dependencies: - mime-db "1.51.0" + mime-db "1.52.0" + +mime@^2.5.2: + version "2.6.0" + resolved "https://registry.yarnpkg.com/mime/-/mime-2.6.0.tgz#a2a682a95cd4d0cb1d6257e28f83da7e35800367" + integrity sha512-USPkMeET31rOMiarsBNIHZKLGgvKc/LrjofAnBlOttf5ajRvqiRA8QsenbcooctK6d6Ts6aqZXBA+XbkKthiQg== mime@^3.0.0: version "3.0.0" @@ -5583,13 +6256,27 @@ minimalistic-assert@^1.0.0: resolved "https://registry.yarnpkg.com/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz#2e194de044626d4a10e7f7fbc00ce73e83e4d5c7" integrity sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A== -minimatch@3.0.4, minimatch@^3.0.2, minimatch@^3.0.3, minimatch@^3.0.4, minimatch@~3.0.4: +minimatch@3.0.4: version "3.0.4" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA== dependencies: brace-expansion "^1.1.7" +minimatch@^3.0.2, minimatch@^3.0.3, minimatch@^3.0.4, minimatch@^3.0.5, minimatch@^3.1.1, minimatch@^3.1.2: + version "3.1.2" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" + integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw== + dependencies: + brace-expansion "^1.1.7" + +minimatch@~3.0.4: + version "3.0.8" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.8.tgz#5e6a59bd11e2ab0de1cfb843eb2d82e546c321c1" + integrity sha512-6FsRAQsxQ61mw+qP1ZzbL9Bc78x2p5OqNgNpnoAFLTrX8n5Kxph0CsnhmKKNXTWjXqU5L0pGPR7hYk+XWZr60Q== + dependencies: + brace-expansion "^1.1.7" + minimist-options@4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/minimist-options/-/minimist-options-4.1.0.tgz#c0655713c53a8a2ebd77ffa247d342c40f010619" @@ -5602,12 +6289,12 @@ minimist-options@4.1.0: minimist@1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" - integrity sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ= + integrity sha512-7Wl+Jz+IGWuSdgsQEJ4JunV0si/iMhg42MnQQG6h1R6TNeVenp4U9x5CC5v/gYqz/fENLQITAWXidNtVL0NNbw== -minimist@^1.1.0, minimist@^1.2.0, minimist@^1.2.5, minimist@~1.2.5: - version "1.2.5" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602" - integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw== +minimist@^1.1.0, minimist@^1.2.0, minimist@^1.2.5, minimist@^1.2.6, minimist@~1.2.5: + version "1.2.8" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.8.tgz#c1a464e7693302e082a075cee0c057741ac4772c" + integrity sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA== minipass-collect@^1.0.2: version "1.0.2" @@ -5657,12 +6344,17 @@ minipass-sized@^1.0.3: minipass "^3.0.0" minipass@^3.0.0, minipass@^3.1.0, minipass@^3.1.1, minipass@^3.1.3: - version "3.1.5" - resolved "https://registry.yarnpkg.com/minipass/-/minipass-3.1.5.tgz#71f6251b0a33a49c01b3cf97ff77eda030dff732" - integrity sha512-+8NzxD82XQoNKNrl1d/FSi+X8wAEWR+sbYAfIvub4Nz0d22plFG72CEVVaufV8PNf4qSslFTD8VMOxNVhHCjTw== + version "3.3.6" + resolved "https://registry.yarnpkg.com/minipass/-/minipass-3.3.6.tgz#7bba384db3a1520d18c9c0e5251c3444e95dd94a" + integrity sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw== dependencies: yallist "^4.0.0" +minipass@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/minipass/-/minipass-5.0.0.tgz#3e9788ffb90b694a5d0ec94479a45b5d8738133d" + integrity sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ== + minizlib@^2.0.0, minizlib@^2.1.1: version "2.1.2" resolved "https://registry.yarnpkg.com/minizlib/-/minizlib-2.1.2.tgz#e90d3466ba209b932451508a11ce3d3632145931" @@ -5680,13 +6372,20 @@ mkdirp-infer-owner@^2.0.0: infer-owner "^1.0.4" mkdirp "^1.0.3" -mkdirp@0.5.5, "mkdirp@>=0.5 0", mkdirp@^0.5.1: +mkdirp@0.5.5: version "0.5.5" resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.5.tgz#d91cefd62d1436ca0f41620e251288d420099def" integrity sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ== dependencies: minimist "^1.2.5" +"mkdirp@>=0.5 0", mkdirp@^0.5.1: + version "0.5.6" + resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.6.tgz#7def03d2432dcae4ba1d611445c48396062255f6" + integrity sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw== + dependencies: + minimist "^1.2.6" + mkdirp@^1.0.3, mkdirp@^1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e" @@ -5722,40 +6421,32 @@ mocha@^7.2.0: yargs-parser "13.1.2" yargs-unparser "1.6.0" -mock-require@^3.0.3: - version "3.0.3" - resolved "https://registry.yarnpkg.com/mock-require/-/mock-require-3.0.3.tgz#ccd544d9eae81dd576b3f219f69ec867318a1946" - integrity sha512-lLzfLHcyc10MKQnNUCv7dMcoY/2Qxd6wJfbqCcVk3LDb8An4hF6ohk5AztrvgKhJCqj36uyzi/p5se+tvyD+Wg== - dependencies: - get-caller-file "^1.0.2" - normalize-path "^2.1.1" - modify-values@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/modify-values/-/modify-values-1.0.1.tgz#b3939fa605546474e3e3e3c63d64bd43b4ee6022" integrity sha512-xV2bxeN6F7oYjZWTe/YPAy6MN2M+sL4u/Rlm2AHCIVGfo2p1yGmBHQ6vHehl4bRTZBdHu3TSkWdYgkwpYzAGSw== module-alias@^2.2.2: - version "2.2.2" - resolved "https://registry.yarnpkg.com/module-alias/-/module-alias-2.2.2.tgz#151cdcecc24e25739ff0aa6e51e1c5716974c0e0" - integrity sha512-A/78XjoX2EmNvppVWEhM2oGk3x4lLxnkEA4jTbaK97QKSDjkIoOsKQlfylt/d3kKKi596Qy3NP5XrXJ6fZIC9Q== + version "2.2.3" + resolved "https://registry.yarnpkg.com/module-alias/-/module-alias-2.2.3.tgz#ec2e85c68973bda6ab71ce7c93b763ec96053221" + integrity sha512-23g5BFj4zdQL/b6tor7Ji+QY4pEfNH784BMslY9Qb0UnJWRAt+lQGLYmRaM0KDBwIG23ffEBELhZDP2rhi9f/Q== -moment-timezone@^0.5.15, moment-timezone@^0.5.33, moment-timezone@^0.5.34: - version "0.5.34" - resolved "https://registry.yarnpkg.com/moment-timezone/-/moment-timezone-0.5.34.tgz#a75938f7476b88f155d3504a9343f7519d9a405c" - integrity sha512-3zAEHh2hKUs3EXLESx/wsgw6IQdusOT8Bxm3D9UrHPQR7zlMmzwybC8zHEM1tQ4LJwP7fcxrWr8tuBg05fFCbg== +moment-timezone@^0.5.15, moment-timezone@^0.5.34, moment-timezone@^0.5.43: + version "0.5.43" + resolved "https://registry.yarnpkg.com/moment-timezone/-/moment-timezone-0.5.43.tgz#3dd7f3d0c67f78c23cd1906b9b2137a09b3c4790" + integrity sha512-72j3aNyuIsDxdF1i7CEgV2FfxM1r6aaqJyLB2vwb33mXYyoyLly+F1zbWqhA3/bVIoJ4szlUoMbUnVdid32NUQ== dependencies: - moment ">= 2.9.0" + moment "^2.29.4" -"moment@>= 2.9.0", moment@^2.23.0, moment@^2.29.1: - version "2.29.1" - resolved "https://registry.yarnpkg.com/moment/-/moment-2.29.1.tgz#b2be769fa31940be9eeea6469c075e35006fa3d3" - integrity sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ== +moment@^2.29.4: + version "2.29.4" + resolved "https://registry.yarnpkg.com/moment/-/moment-2.29.4.tgz#3dbe052889fe7c1b2ed966fcb3a77328964ef108" + integrity sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w== ms@2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" - integrity sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g= + integrity sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A== ms@2.1.1: version "2.1.1" @@ -5791,32 +6482,46 @@ mysql2@^2.3.3: seq-queue "^0.0.5" sqlstring "^2.3.2" +mz@^2.7.0: + version "2.7.0" + resolved "https://registry.yarnpkg.com/mz/-/mz-2.7.0.tgz#95008057a56cafadc2bc63dde7f9ff6955948e32" + integrity sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q== + dependencies: + any-promise "^1.0.0" + object-assign "^4.0.1" + thenify-all "^1.0.0" + named-placeholders@^1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/named-placeholders/-/named-placeholders-1.1.2.tgz#ceb1fbff50b6b33492b5cf214ccf5e39cef3d0e8" - integrity sha512-wiFWqxoLL3PGVReSZpjLVxyJ1bRqe+KKJVbr4hGs1KWfTZTQyezHFBbuKj9hsizHyGV2ne7EMjHdxEGAybD5SA== + version "1.1.3" + resolved "https://registry.yarnpkg.com/named-placeholders/-/named-placeholders-1.1.3.tgz#df595799a36654da55dda6152ba7a137ad1d9351" + integrity sha512-eLoBxg6wE/rZkJPhU/xRX1WTpkFEwDJEN96oxFrTsqBdbT5ec295Q+CoHrL9IT0DipqKhmGcaZmwOt8OON5x1w== dependencies: - lru-cache "^4.1.3" + lru-cache "^7.14.1" nan@^2.15.0: - version "2.15.0" - resolved "https://registry.yarnpkg.com/nan/-/nan-2.15.0.tgz#3f34a473ff18e15c1b5626b62903b5ad6e665fee" - integrity sha512-8ZtvEnA2c5aYCZYd1cvgdnU6cqwixRoYg70xPLWUws5ORTa/lnw+u4amixRS/Ac5U5mQVgp9pnlSUnbNWFaWZQ== + version "2.17.0" + resolved "https://registry.yarnpkg.com/nan/-/nan-2.17.0.tgz#c0150a2368a182f033e9aa5195ec76ea41a199cb" + integrity sha512-2ZTgtl0nJsO0KQCjEpxcIr5D+Yv90plTitZt9JBfQvVJDS5seMl3FOvsh3+9CoYWXf/1l5OaZzzF6nDm4cagaQ== native-duplexpair@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/native-duplexpair/-/native-duplexpair-1.0.0.tgz#7899078e64bf3c8a3d732601b3d40ff05db58fa0" - integrity sha1-eJkHjmS/PIo9cyYBs9QP8F21j6A= + integrity sha512-E7QQoM+3jvNtlmyfqRZ0/U75VFgCls+fSkbml2MpgWkWyz3ox8Y58gNhfuziuQYGNNQAbFZJQck55LHCnCK6CA== + +natural-compare-lite@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/natural-compare-lite/-/natural-compare-lite-1.4.0.tgz#17b09581988979fddafe0201e931ba933c96cbb4" + integrity sha512-Tj+HTDSJJKaZnfiuw+iaF9skdPpTo2GtEly5JHnWV/hfv2Qj/9RKsGISQtLh2ox3l5EAGw487hnBee0sIJ6v2g== natural-compare@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" - integrity sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc= + integrity sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw== negotiator@^0.6.2: - version "0.6.2" - resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.2.tgz#feacf7ccf525a77ae9634436a64883ffeca346fb" - integrity sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw== + version "0.6.3" + resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.3.tgz#58e323a72fedc0d6f9cd4d31fe49f51479590ccd" + integrity sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg== neo-async@^2.6.0: version "2.6.2" @@ -5826,23 +6531,28 @@ neo-async@^2.6.0: nerf-dart@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/nerf-dart/-/nerf-dart-1.0.0.tgz#e6dab7febf5ad816ea81cf5c629c5a0ebde72c1a" - integrity sha1-5tq3/r9a2Bbqgc9cYpxaDr3nLBo= + integrity sha512-EZSPZB70jiVsivaBLYDCyntd5eH8NTSMOn3rB+HxwdmKThGELLdYv8qVIMWvZEFy9w8ZZpW9h9OB32l1rGtj7g== + +netmask@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/netmask/-/netmask-2.0.2.tgz#8b01a07644065d536383835823bc52004ebac5e7" + integrity sha512-dBpDMdxv9Irdq66304OLfEmQ9tbNRFnFTuZiLo+bD+r332bBmMJ8GBLXklIXXgxd3+v9+KUnZaUR5PJMa75Gsg== nise@^5.1.0: - version "5.1.0" - resolved "https://registry.yarnpkg.com/nise/-/nise-5.1.0.tgz#713ef3ed138252daef20ec035ab62b7a28be645c" - integrity sha512-W5WlHu+wvo3PaKLsJJkgPup2LrsXCcm7AWwyNZkUnn5rwPkuPBi3Iwk5SQtN0mv+K65k7nKKjwNQ30wg3wLAQQ== + version "5.1.4" + resolved "https://registry.yarnpkg.com/nise/-/nise-5.1.4.tgz#491ce7e7307d4ec546f5a659b2efe94a18b4bbc0" + integrity sha512-8+Ib8rRJ4L0o3kfmyVCL7gzrohyDe0cMFTBa2d364yIrEGMEoetznKJx899YxjybU6bL9SQkYPSBBs1gyYs8Xg== dependencies: - "@sinonjs/commons" "^1.7.0" - "@sinonjs/fake-timers" "^7.0.4" + "@sinonjs/commons" "^2.0.0" + "@sinonjs/fake-timers" "^10.0.2" "@sinonjs/text-encoding" "^0.7.1" just-extend "^4.0.2" path-to-regexp "^1.7.0" node-addon-api@^4.2.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-4.2.0.tgz#117cbb5a959dff0992e1c586ae0393573e4d2a87" - integrity sha512-eazsqzwG2lskuzBqCGPi7Ac2UgOoMz8JVOXVhTvvPDYhthvNpefx8jWD8Np7Gv+2Sz0FlPWZk0nJV0z598Wn8Q== + version "4.3.0" + resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-4.3.0.tgz#52a1a0b475193e0928e98e0426a0d1254782b77f" + integrity sha512-73sE9+3UaLYYFmDsFZnqCInzPyh3MqIwZO9cw58yIqAZhONrrabrYyYe3TuIqtIiOuTXVhsGau8hcrhhwSsDIQ== node-emoji@^1.10.0: version "1.11.0" @@ -5859,13 +6569,34 @@ node-environment-flags@1.0.6: object.getownpropertydescriptors "^2.0.3" semver "^5.7.0" -node-fetch@^2.6.0, node-fetch@^2.6.1: - version "2.6.6" - resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.6.tgz#1751a7c01834e8e1697758732e9efb6eeadfaf89" - integrity sha512-Z8/6vRlTUChSdIgMa51jxQ4lrw/Jy5SOW10ObaA47/RElsAN2c5Pn8bTgFGWn/ibwzXTE8qwr1Yzx28vsecXEA== +node-fetch@^2.6.1, node-fetch@^2.6.7: + version "2.6.11" + resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.11.tgz#cde7fc71deef3131ef80a738919f999e6edfff25" + integrity sha512-4I6pdBY1EthSqDmJkiNk3JIT8cswwR9nfeW/cPdUagJYEQG7R95WRH74wpz7ma8Gh/9dI9FP+OU+0E4FvtA55w== dependencies: whatwg-url "^5.0.0" +node-forge@^1.3.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-1.3.1.tgz#be8da2af243b2417d5f646a770663a92b7e9ded3" + integrity sha512-dPEtOeMvF9VMcYV/1Wb8CPoVAXtp6MKMlcbAt4ddqmGqUJ6fQZFXkNZNkNlfevtNkGtaSoXf/vNNNSvgrdXwtA== + +node-gyp@8.x: + version "8.4.1" + resolved "https://registry.yarnpkg.com/node-gyp/-/node-gyp-8.4.1.tgz#3d49308fc31f768180957d6b5746845fbd429937" + integrity sha512-olTJRgUtAb/hOXG0E93wZDs5YiJlgbXxTwQAFHyNlRsXQnYzUaF2aGgujZbw+hR8aF4ZG/rST57bWMWD16jr9w== + dependencies: + env-paths "^2.2.0" + glob "^7.1.4" + graceful-fs "^4.2.6" + make-fetch-happen "^9.1.0" + nopt "^5.0.0" + npmlog "^6.0.0" + rimraf "^3.0.2" + semver "^7.3.5" + tar "^6.1.2" + which "^2.0.2" + node-gyp@^7.1.0, node-gyp@^7.1.2: version "7.1.2" resolved "https://registry.yarnpkg.com/node-gyp/-/node-gyp-7.1.2.tgz#21a810aebb187120251c3bcec979af1587b188ae" @@ -5885,7 +6616,7 @@ node-gyp@^7.1.0, node-gyp@^7.1.2: node-hook@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/node-hook/-/node-hook-1.0.0.tgz#82ca39af991d726d5c7952e59c992378bb296f7e" - integrity sha1-gso5r5kdcm1ceVLlnJkjeLspb34= + integrity sha512-tBTIHwkzXvbesP0fY495VsqSWCOS5Ttt5+mAmeqUC1yglCiSYarNewfi2Q+HOL+M6pZYYqwGU6jIi5+gIHQbpg== node-preload@^0.2.1: version "0.2.1" @@ -5894,15 +6625,15 @@ node-preload@^0.2.1: dependencies: process-on-spawn "^1.0.0" -node-releases@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.1.tgz#3d1d395f204f1f2f29a54358b9fb678765ad2fc5" - integrity sha512-CqyzN6z7Q6aMeF/ktcMVTzhAHCEpf8SOarwpzpf8pNBY2k5/oM34UHldUwp8VKI7uxct2HxSRdJjBaZeESzcxA== +node-releases@^2.0.12: + version "2.0.12" + resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.12.tgz#35627cc224a23bfb06fb3380f2b3afaaa7eb1039" + integrity sha512-QzsYKWhXTWx8h1kIvqfnC++o0pEmpRQA/aenALsL2F4pqNVr7YzcdMlDij5WBnwftRbJCNJL/O7zdKaxKPHqgQ== noms@0.0.0: version "0.0.0" resolved "https://registry.yarnpkg.com/noms/-/noms-0.0.0.tgz#da8ebd9f3af9d6760919b27d9cdc8092a7332859" - integrity sha1-2o69nzr51nYJGbJ9nNyAkqczKFk= + integrity sha512-lNDU9VJaOPxUmXcLb+HQFeUgQQPtMI24Gt6hgfuMHRJgMRHMF/qZ4HJD3GDru4sSw9IQl2jPjAYnQrdIeLbwow== dependencies: inherits "^2.0.1" readable-stream "~1.0.31" @@ -5937,7 +6668,7 @@ normalize-package-data@^3.0.0, normalize-package-data@^3.0.2: normalize-path@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-2.1.1.tgz#1ab28b556e198363a8c1a6f7e6fa20137fe6aed9" - integrity sha1-GrKLVW4Zg2Oowab35vogE3/mrtk= + integrity sha512-3pKJwH184Xo/lnH6oyP1q2pMd7HcypqqmRs91/6/i2CGtWwIKGCkOOMTm/zXbgTEWHw1uNpNi/igc3ePOYHb6w== dependencies: remove-trailing-separator "^1.0.1" @@ -6140,10 +6871,20 @@ npmlog@^5.0.1: gauge "^3.0.0" set-blocking "^2.0.0" -nth-check@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/nth-check/-/nth-check-2.0.1.tgz#2efe162f5c3da06a28959fbd3db75dbeea9f0fc2" - integrity sha512-it1vE95zF6dTT9lBsYbxvqh0Soy4SPowchj0UBGj/V6cTPnXXtQOPUbhZ6CmGzAD/rW22LQK6E96pcdJXk4A4w== +npmlog@^6.0.0: + version "6.0.2" + resolved "https://registry.yarnpkg.com/npmlog/-/npmlog-6.0.2.tgz#c8166017a42f2dea92d6453168dd865186a70830" + integrity sha512-/vBvz5Jfr9dT/aFWd0FIRf+T/Q2WBsLENygUaFUqstqsycmZAP/t5BvFJTK0viFmSUxiUKTUplWy5vt+rvKIxg== + dependencies: + are-we-there-yet "^3.0.0" + console-control-strings "^1.1.0" + gauge "^4.0.3" + set-blocking "^2.0.0" + +nth-check@^2.0.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/nth-check/-/nth-check-2.1.1.tgz#c9eab428effce36cd6b92c924bdb000ef1f1ed1d" + integrity sha512-lqjrjmaOoAnWfMmBPL+XNnynZh2+swxiX3WUE0s4yEHI6m+AwrK2UZOimIRl3X/4QctVqS8AiZjFqyOGrMXb/w== dependencies: boolbase "^1.0.0" @@ -6157,7 +6898,7 @@ nth-check@~1.0.1: number-is-nan@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d" - integrity sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0= + integrity sha512-4jbtZXNAsfZbAHiiqjLPBiCl16dES1zI4Hpzzxw61Tk+loF+sBDBKx1ICKKKwIqQ7M0mFn1TmkN7euSncWgHiQ== "nwmatcher@>= 1.3.7 < 2.0.0": version "1.4.4" @@ -6202,22 +6943,17 @@ oauth-sign@~0.9.0: resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.9.0.tgz#47a7b016baa68b5fa0ecf3dee08a85c679ac6455" integrity sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ== -object-assign@^4.1.0, object-assign@^4.1.1: +object-assign@^4.0.1, object-assign@^4.1.0, object-assign@^4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" - integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM= - -object-inspect@^1.11.0, object-inspect@^1.9.0: - version "1.11.0" - resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.11.0.tgz#9dceb146cedd4148a0d9e51ab88d34cf509922b1" - integrity sha512-jp7ikS6Sd3GxQfZJPyH3cjcbJF6GZPClgdV+EFygjFLQ5FmW/dRUnTd9PQ9k0JhoNDabWFbpF1yCdSWCC6gexg== + integrity sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg== -object-inspect@^1.11.1: - version "1.12.0" - resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.12.0.tgz#6e2c120e868fd1fd18cb4f18c31741d0d6e776f0" - integrity sha512-Ho2z80bVIvJloH+YzRmpZVQe87+qASmBUKZDWgx9cu+KDrX2ZDH/3tMy+gXbZETVGs2M8YdxObOh7XAtim9Y0g== +object-inspect@^1.12.2, object-inspect@^1.12.3, object-inspect@^1.9.0: + version "1.12.3" + resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.12.3.tgz#ba62dffd67ee256c8c086dfae69e016cd1f198b9" + integrity sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g== -object-keys@^1.0.11, object-keys@^1.0.12, object-keys@^1.1.1: +object-keys@^1.0.11, object-keys@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.1.1.tgz#1c47f272df277f3b1daf061677d9c82e2322c60e" integrity sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA== @@ -6232,40 +6968,31 @@ object.assign@4.1.0: has-symbols "^1.0.0" object-keys "^1.0.11" -object.assign@^4.0.4, object.assign@^4.1.2: - version "4.1.2" - resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.1.2.tgz#0ed54a342eceb37b38ff76eb831a0e788cb63940" - integrity sha512-ixT2L5THXsApyiUPYKmW+2EHpXXe5Ii3M+f4e+aJFAHao5amFRW6J0OO6c/LU8Be47utCx2GL89hxGB6XSmKuQ== +object.assign@^4.0.4, object.assign@^4.1.4: + version "4.1.4" + resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.1.4.tgz#9673c7c7c351ab8c4d0b516f4343ebf4dfb7799f" + integrity sha512-1mxKf0e58bvyjSCtKYY4sRe9itRk3PJpquJOjeIkz885CczcI4IvJJDLPS72oowuSh+pBxUFROpX+TU++hxhZQ== dependencies: - call-bind "^1.0.0" - define-properties "^1.1.3" - has-symbols "^1.0.1" + call-bind "^1.0.2" + define-properties "^1.1.4" + has-symbols "^1.0.3" object-keys "^1.1.1" object.getownpropertydescriptors@^2.0.3: - version "2.1.3" - resolved "https://registry.yarnpkg.com/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.1.3.tgz#b223cf38e17fefb97a63c10c91df72ccb386df9e" - integrity sha512-VdDoCwvJI4QdC6ndjpqFmoL3/+HxffFBbcJzKi5hwLLqqx3mdbedRpfZDdK0SrOSauj8X4GzBvnDZl4vTN7dOw== - dependencies: - call-bind "^1.0.2" - define-properties "^1.1.3" - es-abstract "^1.19.1" - -ocsp@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/ocsp/-/ocsp-1.2.0.tgz#469a1776b457dee67eb0201408c1946bac4076cc" - integrity sha1-RpoXdrRX3uZ+sCAUCMGUa6xAdsw= + version "2.1.6" + resolved "https://registry.yarnpkg.com/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.1.6.tgz#5e5c384dd209fa4efffead39e3a0512770ccc312" + integrity sha512-lq+61g26E/BgHv0ZTFgRvi7NMEPuAxLkFU7rukXjc/AlwH4Am5xXVnIXy3un1bg/JPbXHrixRkK1itUzzPiIjQ== dependencies: - asn1.js "^4.8.0" - asn1.js-rfc2560 "^4.0.0" - asn1.js-rfc5280 "^2.0.0" - async "^1.5.2" - simple-lru-cache "0.0.2" + array.prototype.reduce "^1.0.5" + call-bind "^1.0.2" + define-properties "^1.2.0" + es-abstract "^1.21.2" + safe-array-concat "^1.0.0" once@^1.3.0, once@^1.3.1, once@^1.3.2, once@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" - integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E= + integrity sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w== dependencies: wrappy "1" @@ -6320,13 +7047,33 @@ optionator@^0.9.1: type-check "^0.4.0" word-wrap "^1.2.3" +oracledb@^5.5.0: + version "5.5.0" + resolved "https://registry.yarnpkg.com/oracledb/-/oracledb-5.5.0.tgz#0cf9af5d0c0815f74849ae9ed56aee823514d71b" + integrity sha512-i5cPvMENpZP8nnqptB6l0pjiOyySj1IISkbM4Hr3yZEDdANo2eezarwZb9NQ8fTh5pRjmgpZdSyIbnn9N3AENw== + ordered-read-streams@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/ordered-read-streams/-/ordered-read-streams-1.0.1.tgz#77c0cb37c41525d64166d990ffad7ec6a0e1363e" - integrity sha1-d8DLN8QVJdZBZtmQ/61+xqDhNj4= + integrity sha512-Z87aSjx3r5c0ZB7bcJqIgIRX5bxR7A4aSzvIbaxd0oTkWBCOoKfuGHiKj60CHVUgg1Phm5yMZzBdt8XqRs73Mw== dependencies: readable-stream "^2.0.1" +os-name@~1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/os-name/-/os-name-1.0.3.tgz#1b379f64835af7c5a7f498b357cb95215c159edf" + integrity sha512-f5estLO2KN8vgtTRaILIgEGBoBrMnZ3JQ7W9TMZCnOIGwHe8TRGSpcagnWDo+Dfhd/z08k9Xe75hvciJJ8Qaew== + dependencies: + osx-release "^1.0.0" + win-release "^1.0.0" + +osx-release@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/osx-release/-/osx-release-1.1.0.tgz#f217911a28136949af1bf9308b241e2737d3cd6c" + integrity sha512-ixCMMwnVxyHFQLQnINhmIpWqXIfS2YOXchwQrk+OFzmo6nDjQ0E4KXAyyUh0T0MZgV4bUhkRrAbVqlE4yLVq4A== + dependencies: + minimist "^1.1.0" + p-each-series@^2.1.0: version "2.2.0" resolved "https://registry.yarnpkg.com/p-each-series/-/p-each-series-2.2.0.tgz#105ab0357ce72b202a8a8b94933672657b5e2a9a" @@ -6358,7 +7105,7 @@ p-limit@^2.0.0, p-limit@^2.2.0, p-limit@^2.2.2: dependencies: p-try "^2.0.0" -p-limit@^3.0.2: +p-limit@^3.0.1, p-limit@^3.0.2: version "3.1.0" resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-3.1.0.tgz#e1daccbe78d0d1388ca18c64fea38e3e57e3706b" integrity sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ== @@ -6368,7 +7115,7 @@ p-limit@^3.0.2: p-locate@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-2.0.0.tgz#20a0103b222a70c8fd39cc2e580680f3dde5ec43" - integrity sha1-IKAQOyIqcMj9OcwuWAaA893l7EM= + integrity sha512-nQja7m7gSKuewoVRen45CtVfODR3crN3goVQ0DDZ9N3yHxgpkuBhZqsaiotSQRrADUrne346peY7kT3TSACykg== dependencies: p-limit "^1.1.0" @@ -6429,14 +7176,6 @@ p-reflect@^2.1.0: resolved "https://registry.yarnpkg.com/p-reflect/-/p-reflect-2.1.0.tgz#5d67c7b3c577c4e780b9451fc9129675bd99fe67" integrity sha512-paHV8NUz8zDHu5lhr/ngGWQiW067DK/+IbJ+RfZ4k+s8y4EKyYCz8pGYWjxCg35eHztpJAt+NUgvN4L+GCbPlg== -p-retry@^4.0.0: - version "4.6.1" - resolved "https://registry.yarnpkg.com/p-retry/-/p-retry-4.6.1.tgz#8fcddd5cdf7a67a0911a9cf2ef0e5df7f602316c" - integrity sha512-e2xXGNhZOZ0lfgR9kL34iGlU8N/KO0xZnQxVEwdeOvpqNDQfdnxIYizvWtK8RglUa3bGqI8g0R/BdfzLMxRkiA== - dependencies: - "@types/retry" "^0.12.0" - retry "^0.13.1" - p-settle@^4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/p-settle/-/p-settle-4.1.1.tgz#37fbceb2b02c9efc28658fc8d36949922266035f" @@ -6453,13 +7192,37 @@ p-timeout@^4.0.0: p-try@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/p-try/-/p-try-1.0.0.tgz#cbc79cdbaf8fd4228e13f621f2b1a237c1b207b3" - integrity sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M= + integrity sha512-U1etNYuMJoIz3ZXSrrySFjsXQTWOx2/jdi86L+2pRvph/qMKL6sbcCYdH23fqsbm8TH2Gn0OybpT4eSFlCVHww== p-try@^2.0.0: version "2.2.0" resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6" integrity sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ== +pac-proxy-agent@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/pac-proxy-agent/-/pac-proxy-agent-5.0.0.tgz#b718f76475a6a5415c2efbe256c1c971c84f635e" + integrity sha512-CcFG3ZtnxO8McDigozwE3AqAw15zDvGH+OjXO4kzf7IkEKkQ4gxQ+3sdF50WmhQ4P/bVusXcqNE2S3XrNURwzQ== + dependencies: + "@tootallnate/once" "1" + agent-base "6" + debug "4" + get-uri "3" + http-proxy-agent "^4.0.1" + https-proxy-agent "5" + pac-resolver "^5.0.0" + raw-body "^2.2.0" + socks-proxy-agent "5" + +pac-resolver@^5.0.0: + version "5.0.1" + resolved "https://registry.yarnpkg.com/pac-resolver/-/pac-resolver-5.0.1.tgz#c91efa3a9af9f669104fa2f51102839d01cde8e7" + integrity sha512-cy7u00ko2KVgBAjuhevqpPeHIkCIqPe1v24cydhWjmeuzaBfmUWFCZJ1iAh5TuVzVZoUzXIW7K8sMYOZ84uZ9Q== + dependencies: + degenerator "^3.0.2" + ip "^1.1.5" + netmask "^2.0.2" + package-hash@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/package-hash/-/package-hash-4.0.0.tgz#3537f654665ec3cc38827387fc904c163c54f506" @@ -6519,7 +7282,7 @@ parse-conflict-json@^1.1.1: parse-json@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-4.0.0.tgz#be35f5425be1f7f6c747184f98a788cb99477ee0" - integrity sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA= + integrity sha512-aOIos8bujGN93/8Ox/jPLh7RwVnPEysynVFE+fQZyg6jKELEHwzgKdLRFHUgXJL6kylijVSBC4BvN9OmsB48Rw== dependencies: error-ex "^1.3.1" json-parse-better-errors "^1.0.1" @@ -6537,19 +7300,20 @@ parse-json@^5.0.0: parse-passwd@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/parse-passwd/-/parse-passwd-1.0.0.tgz#6d5b934a456993b23d37f40a382d6f1666a8e5c6" - integrity sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY= + integrity sha512-1Y1A//QUXEZK7YKz+rD9WydcE1+EuPr6ZBgKecAB8tmoW6UFv0NREVJe1p+jRxtThkcbbKkfwIbWJe/IeE6m2Q== -parse5-htmlparser2-tree-adapter@^6.0.1: - version "6.0.1" - resolved "https://registry.yarnpkg.com/parse5-htmlparser2-tree-adapter/-/parse5-htmlparser2-tree-adapter-6.0.1.tgz#2cdf9ad823321140370d4dbf5d3e92c7c8ddc6e6" - integrity sha512-qPuWvbLgvDGilKc5BoicRovlT4MtYT6JfJyBOMDsKoiT+GiuP5qyrPCnR9HcPECIJJmZh5jRndyNThnhhb/vlA== +parse5-htmlparser2-tree-adapter@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/parse5-htmlparser2-tree-adapter/-/parse5-htmlparser2-tree-adapter-7.0.0.tgz#23c2cc233bcf09bb7beba8b8a69d46b08c62c2f1" + integrity sha512-B77tOZrqqfUfnVcOrUvfdLbz4pu4RopLD/4vmu3HUPswwTA8OH0EMW9BlWR2B0RCoiZRAHEUu7IxeP1Pd1UU+g== dependencies: - parse5 "^6.0.1" + domhandler "^5.0.2" + parse5 "^7.0.0" parse5@^1.5.1: version "1.5.1" resolved "https://registry.yarnpkg.com/parse5/-/parse5-1.5.1.tgz#9b7f3b0de32be78dc2401b17573ccaf0f6f59d94" - integrity sha1-m387DeMr543CQBsXVzzK8Pb1nZQ= + integrity sha512-w2jx/0tJzvgKwZa58sj2vAYq/S/K1QJfIB3cWYea/Iu1scFPDQQ3IQiVZTHWtRBwAjv2Yd7S/xeZf3XqLDb3bA== parse5@^3.0.1: version "3.0.3" @@ -6558,20 +7322,22 @@ parse5@^3.0.1: dependencies: "@types/node" "*" -parse5@^6.0.1: - version "6.0.1" - resolved "https://registry.yarnpkg.com/parse5/-/parse5-6.0.1.tgz#e1a1c085c569b3dc08321184f19a39cc27f7c30b" - integrity sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw== +parse5@^7.0.0: + version "7.1.2" + resolved "https://registry.yarnpkg.com/parse5/-/parse5-7.1.2.tgz#0736bebbfd77793823240a23b7fc5e010b7f8e32" + integrity sha512-Czj1WaSVpaoj0wbhMzLmWD69anp2WH7FXMB9n1Sy8/ZFF9jolSQVMu1Ij5WIyGmcBmhk7EOndpO4mIpihVqAXw== + dependencies: + entities "^4.4.0" path-dirname@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/path-dirname/-/path-dirname-1.0.2.tgz#cc33d24d525e099a5388c0336c6e32b9160609e0" - integrity sha1-zDPSTVJeCZpTiMAzbG4yuRYGCeA= + integrity sha512-ALzNPpyNq9AqXMBjeymIjFDAkAFH06mHJH/cSBHAgU0s4vfpBn6b2nf8tiRLvagKD8RbTpq2FKTBg7cl9l3c7Q== path-exists@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-3.0.0.tgz#ce0ebeaa5f78cb18925ea7d810d7b59b010fd515" - integrity sha1-zg6+ql94yxiSXqfYENe1mwEP1RU= + integrity sha512-bpC7GYwiDYQ4wYLe+FA8lhRjhQCMcQGuSgGGqDkg/QerRWw9CmGRT0iSOVRSZJ29NMLZgIzqaljJ63oaL4NIJQ== path-exists@^4.0.0: version "4.0.0" @@ -6581,14 +7347,14 @@ path-exists@^4.0.0: path-is-absolute@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" - integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18= + integrity sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg== path-key@^3.0.0, path-key@^3.1.0: version "3.1.1" resolved "https://registry.yarnpkg.com/path-key/-/path-key-3.1.1.tgz#581f6ade658cbba65a0d3380de7753295054f375" integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q== -path-parse@^1.0.6: +path-parse@^1.0.7: version "1.0.7" resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735" integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw== @@ -6610,15 +7376,32 @@ pathval@^1.1.1: resolved "https://registry.yarnpkg.com/pathval/-/pathval-1.1.1.tgz#8534e77a77ce7ac5a2512ea21e0fdb8fcf6c3d8d" integrity sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ== +pause-stream@~0.0.11: + version "0.0.11" + resolved "https://registry.yarnpkg.com/pause-stream/-/pause-stream-0.0.11.tgz#fe5a34b0cbce12b5aa6a2b403ee2e73b602f1445" + integrity sha512-e3FBlXLmN/D1S+zHzanP4E/4Z60oFAa3O051qt1pxa7DEJWKAyil6upYVXCWadEnuoqa4Pkc9oUx9zsxYeRv8A== + dependencies: + through "~2.3" + performance-now@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b" - integrity sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns= + integrity sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow== -pg-connection-string@^2.5.0: - version "2.5.0" - resolved "https://registry.yarnpkg.com/pg-connection-string/-/pg-connection-string-2.5.0.tgz#538cadd0f7e603fc09a12590f3b8a452c2c0cf34" - integrity sha512-r5o/V/ORTA6TmUnyWZR9nCj1klXCO2CEKNRlVuJptZe85QuhFayC7WeMic7ndayT5IRIR0S0xFxFi2ousartlQ== +pg-cloudflare@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/pg-cloudflare/-/pg-cloudflare-1.1.0.tgz#833d70870d610d14bf9df7afb40e1cba310c17a0" + integrity sha512-tGM8/s6frwuAIyRcJ6nWcIvd3+3NmUKIs6OjviIm1HPPFEt5MzQDOTBQyhPWg/m0kCl95M6gA1JaIXtS8KovOA== + +pg-connection-string@^2.6.0: + version "2.6.0" + resolved "https://registry.yarnpkg.com/pg-connection-string/-/pg-connection-string-2.6.0.tgz#12a36cc4627df19c25cc1b9b736cc39ee1f73ae8" + integrity sha512-x14ibktcwlHKoHxx9X3uTVW9zIGR41ZB6QNhHb21OPNdCCO3NaRnpJuwKIQSR4u+Yqjx4HCvy7Hh7VSy1U4dGg== + +pg-connection-string@^2.6.1: + version "2.6.1" + resolved "https://registry.yarnpkg.com/pg-connection-string/-/pg-connection-string-2.6.1.tgz#78c23c21a35dd116f48e12e23c0965e8d9e2cbfb" + integrity sha512-w6ZzNu6oMmIzEAYVw+RLK0+nqHPt8K3ZnknKi+g48Ak2pr3dtljJW3o+D/n2zzCG07Zoe9VOX3aiKpj+BN0pjg== pg-hstore@^2.3.4: version "2.3.4" @@ -6632,15 +7415,15 @@ pg-int8@1.0.1: resolved "https://registry.yarnpkg.com/pg-int8/-/pg-int8-1.0.1.tgz#943bd463bf5b71b4170115f80f8efc9a0c0eb78c" integrity sha512-WCtabS6t3c8SkpDBUlb1kjOs7l66xsGdKpIPZsg4wR+B3+u9UAum2odSsF9tnvxg80h4ZxLWMy4pRjOsFIqQpw== -pg-pool@^3.4.1: - version "3.4.1" - resolved "https://registry.yarnpkg.com/pg-pool/-/pg-pool-3.4.1.tgz#0e71ce2c67b442a5e862a9c182172c37eda71e9c" - integrity sha512-TVHxR/gf3MeJRvchgNHxsYsTCHQ+4wm3VIHSS19z8NC0+gioEhq1okDY1sm/TYbfoP6JLFx01s0ShvZ3puP/iQ== +pg-pool@^3.6.0: + version "3.6.0" + resolved "https://registry.yarnpkg.com/pg-pool/-/pg-pool-3.6.0.tgz#3190df3e4747a0d23e5e9e8045bcd99bda0a712e" + integrity sha512-clFRf2ksqd+F497kWFyM21tMjeikn60oGDmqMT8UBrynEwVEX/5R5xd2sdvdo1cZCFlguORNpVuqxIj+aK4cfQ== -pg-protocol@^1.5.0: - version "1.5.0" - resolved "https://registry.yarnpkg.com/pg-protocol/-/pg-protocol-1.5.0.tgz#b5dd452257314565e2d54ab3c132adc46565a6a0" - integrity sha512-muRttij7H8TqRNu/DxrAJQITO4Ac7RmX3Klyr/9mJEOBeIpgnF8f9jAfRz5d3XwQZl5qBjF9gLsUtMPJE0vezQ== +pg-protocol@^1.6.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/pg-protocol/-/pg-protocol-1.6.0.tgz#4c91613c0315349363af2084608db843502f8833" + integrity sha512-M+PDm637OY5WM307051+bsDia5Xej6d9IR4GwJse1qA1DIhiKlksvrneZOYQq42OM+spubpcNYEo2FcKQrDk+Q== pg-types@^2.1.0: version "2.2.0" @@ -6654,44 +7437,51 @@ pg-types@^2.1.0: postgres-interval "^1.1.0" pg@^8.7.1: - version "8.7.1" - resolved "https://registry.yarnpkg.com/pg/-/pg-8.7.1.tgz#9ea9d1ec225980c36f94e181d009ab9f4ce4c471" - integrity sha512-7bdYcv7V6U3KAtWjpQJJBww0UEsWuh4yQ/EjNf2HeO/NnvKjpvhEIe/A/TleP6wtmSKnUnghs5A9jUoK6iDdkA== + version "8.11.0" + resolved "https://registry.yarnpkg.com/pg/-/pg-8.11.0.tgz#a37e534e94b57a7ed811e926f23a7c56385f55d9" + integrity sha512-meLUVPn2TWgJyLmy7el3fQQVwft4gU5NGyvV0XbD41iU9Jbg8lCH4zexhIkihDzVHJStlt6r088G6/fWeNjhXA== dependencies: buffer-writer "2.0.0" packet-reader "1.0.0" - pg-connection-string "^2.5.0" - pg-pool "^3.4.1" - pg-protocol "^1.5.0" + pg-connection-string "^2.6.0" + pg-pool "^3.6.0" + pg-protocol "^1.6.0" pg-types "^2.1.0" pgpass "1.x" + optionalDependencies: + pg-cloudflare "^1.1.0" pgpass@1.x: - version "1.0.4" - resolved "https://registry.yarnpkg.com/pgpass/-/pgpass-1.0.4.tgz#85eb93a83800b20f8057a2b029bf05abaf94ea9c" - integrity sha512-YmuA56alyBq7M59vxVBfPJrGSozru8QAdoNlWuW3cz8l+UX3cWge0vTvjKhsSHSJpo3Bom8/Mm6hf0TR5GY0+w== + version "1.0.5" + resolved "https://registry.yarnpkg.com/pgpass/-/pgpass-1.0.5.tgz#9b873e4a564bb10fa7a7dbd55312728d422a223d" + integrity sha512-FdW9r/jQZhSeohs1Z3sI1yxFQNFvMcnmfuj4WBMUTxOrAyLMaTcE1aAMBiTlbMNaXvBCQuVi0R7hd8udDSP7ug== dependencies: - split2 "^3.1.1" + split2 "^4.1.0" picocolors@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.0.0.tgz#cb5bdc74ff3f51892236eaf79d68bc44564ab81c" integrity sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ== -picomatch@^2.0.4, picomatch@^2.2.3: - version "2.3.0" - resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.0.tgz#f1f061de8f6a4bf022892e2d128234fb98302972" - integrity sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw== +picomatch@^2.0.4, picomatch@^2.3.1: + version "2.3.1" + resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" + integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== + +pidtree@^0.5.0: + version "0.5.0" + resolved "https://registry.yarnpkg.com/pidtree/-/pidtree-0.5.0.tgz#ad5fbc1de78b8a5f99d6fbdd4f6e4eee21d1aca1" + integrity sha512-9nxspIM7OpZuhBxPg73Zvyq7j1QMPMPsGKTqRc2XOaFQauDvoNz9fM1Wdkjmeo7l9GXOZiRs97sPkuayl39wjA== pify@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/pify/-/pify-3.0.0.tgz#e5a4acd2c101fdf3d9a4d07f0dbc4db49dd28176" - integrity sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY= + integrity sha512-C3FsVNH1udSEX48gGX1xfvwTWfsYWj5U+8/uK15BGzIGrKoUpghX8hWZwa/OFnakBiiVNmBvemTJR5mcy7iPcg== pkg-conf@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/pkg-conf/-/pkg-conf-2.1.0.tgz#2126514ca6f2abfebd168596df18ba57867f0058" - integrity sha1-ISZRTKbyq/69FoWW3xi6V4Z/AFg= + integrity sha512-C+VUP+8jis7EsQZIhDYmS5qlNtjv2yP4SNtjXK9AP1ZcTRlnSfuumaTnRfYZnYgUUYVIKqL0fRvmUGDV2fmp6g== dependencies: find-up "^2.0.0" load-json-file "^4.0.0" @@ -6718,7 +7508,7 @@ postgres-array@~2.0.0: postgres-bytea@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/postgres-bytea/-/postgres-bytea-1.0.0.tgz#027b533c0aa890e26d172d47cf9ccecc521acd35" - integrity sha1-AntTPAqokOJtFy1Hz5zOzFIazTU= + integrity sha512-xy3pmLuQqRBZBXDULy7KbaitYqLcmxigw14Q5sj8QBVLqEwXfeybIKVWiqAXTlcvdvb0+xkOtDbfQMOf4lST1w== postgres-date@~1.0.4: version "1.0.7" @@ -6740,7 +7530,7 @@ prelude-ls@^1.2.1: prelude-ls@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" - integrity sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ= + integrity sha512-ESF23V4SKG6lVSGZgYNpbsiaAkdab6ZgOxe52p7+Kid3W3u3bxR4Vfd/o21dmN7jSt0IwgZ4v5MUd26FEtXE9w== proc-log@^1.0.0: version "1.0.0" @@ -6762,12 +7552,7 @@ process-on-spawn@^1.0.0: process@^0.11.10: version "0.11.10" resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182" - integrity sha1-czIwDoQBYb2j5podHZGn1LwW8YI= - -progress@^2.0.0: - version "2.0.3" - resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.3.tgz#7e8cf8d8f5b8f239c1bc68beb4eb78567d572ef8" - integrity sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA== + integrity sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A== promise-all-reject-late@^1.0.0: version "1.0.1" @@ -6775,14 +7560,14 @@ promise-all-reject-late@^1.0.0: integrity sha512-vuf0Lf0lOxyQREH7GDIOUMLS7kz+gs8i6B+Yi8dC68a2sychGrHTJYghMBD6k7eUcH0H5P73EckCA48xijWqXw== promise-call-limit@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/promise-call-limit/-/promise-call-limit-1.0.1.tgz#4bdee03aeb85674385ca934da7114e9bcd3c6e24" - integrity sha512-3+hgaa19jzCGLuSCbieeRsu5C2joKfYn8pY6JAuXFRVfF4IO+L7UPpFWNTeWT9pM7uhskvbPPd/oEOktCn317Q== + version "1.0.2" + resolved "https://registry.yarnpkg.com/promise-call-limit/-/promise-call-limit-1.0.2.tgz#f64b8dd9ef7693c9c7613e7dfe8d6d24de3031ea" + integrity sha512-1vTUnfI2hzui8AEIixbdAJlFY4LFDXqQswy/2eOlThAscXCY4It8FdVuI0fMJGAB2aWGbdQf/gv0skKYXmdrHA== promise-inflight@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/promise-inflight/-/promise-inflight-1.0.1.tgz#98472870bf228132fcbdd868129bad12c3c029e3" - integrity sha1-mEcocL8igTL8vdhoEputEsPAKeM= + integrity sha512-6zWPyEOFaQBJYcGMHBKTKJ3u6TBsnMFOIZSa6ce1e/ZrrsOlnHRHbabMjLiBYKp+n44X9eUI6VUPaukCXHuG4g== promise-retry@^2.0.1: version "2.0.1" @@ -6795,19 +7580,33 @@ promise-retry@^2.0.1: promzard@^0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/promzard/-/promzard-0.3.0.tgz#26a5d6ee8c7dee4cb12208305acfb93ba382a9ee" - integrity sha1-JqXW7ox97kyxIggwWs+5O6OCqe4= + integrity sha512-JZeYqd7UAcHCwI+sTOeUDYkvEU+1bQ7iE0UT1MgB/tERkAPkesW46MrpIySzODi+owTjZtiF8Ay5j9m60KmMBw== dependencies: read "1" -pseudomap@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3" - integrity sha1-8FKijacOYYkX7wqKw0wa5aaChrM= +proxy-agent@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/proxy-agent/-/proxy-agent-5.0.0.tgz#d31405c10d6e8431fde96cba7a0c027ce01d633b" + integrity sha512-gkH7BkvLVkSfX9Dk27W6TyNOWWZWRilRfk1XxGNWOYJ2TuedAv1yFpCaU9QSBmBe716XOTNpYNOzhysyw8xn7g== + dependencies: + agent-base "^6.0.0" + debug "4" + http-proxy-agent "^4.0.0" + https-proxy-agent "^5.0.0" + lru-cache "^5.1.1" + pac-proxy-agent "^5.0.0" + proxy-from-env "^1.0.0" + socks-proxy-agent "^5.0.0" -psl@^1.1.28, psl@^1.1.33: - version "1.8.0" - resolved "https://registry.yarnpkg.com/psl/-/psl-1.8.0.tgz#9326f8bcfb013adcc005fdff056acce020e51c24" - integrity sha512-RIdOzyoavK+hA18OGGWDqUTsCLhtA7IcZ/6NCs4fFJaHBDab+pDDmDIByWFRQJq2Cd7r1OoQxBGKOaztq+hjIQ== +proxy-from-env@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz#e102f16ca355424865755d2c9e8ea4f24d58c3e2" + integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg== + +psl@^1.1.28: + version "1.9.0" + resolved "https://registry.yarnpkg.com/psl/-/psl-1.9.0.tgz#d0df2a137f00794565fcaf3b2c00cd09f8d5a5a7" + integrity sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag== pump@^1.0.0: version "1.0.3" @@ -6825,6 +7624,14 @@ pump@^2.0.0: end-of-stream "^1.1.0" once "^1.3.1" +pump@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/pump/-/pump-3.0.0.tgz#b4a2116815bde2f4e1ea602354e8c75565107a64" + integrity sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww== + dependencies: + end-of-stream "^1.1.0" + once "^1.3.1" + pumpify@^1.3.5: version "1.5.1" resolved "https://registry.yarnpkg.com/pumpify/-/pumpify-1.5.1.tgz#36513be246ab27570b1a374a5ce278bfd74370ce" @@ -6837,12 +7644,12 @@ pumpify@^1.3.5: punycode@1.3.2: version "1.3.2" resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.3.2.tgz#9653a036fb7c1ee42342f2325cceefea3926c48d" - integrity sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0= + integrity sha512-RofWgt/7fL5wP1Y7fxE7/EmTLzQVnB0ycyibJ0OOHIlJqTNzglYFxVwETOcIoJqJmpDXJ9xImDv+Fq34F/d4Dw== punycode@^2.1.0, punycode@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" - integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A== + version "2.3.0" + resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.3.0.tgz#f67fa67c94da8f4d0cfff981aee4118064199b8f" + integrity sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA== python-struct@^1.1.3: version "1.1.3" @@ -6854,22 +7661,29 @@ python-struct@^1.1.3: q@^1.5.1: version "1.5.1" resolved "https://registry.yarnpkg.com/q/-/q-1.5.1.tgz#7e32f75b41381291d04611f1bf14109ac00651d7" - integrity sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc= + integrity sha512-kV/CThkXo6xyFEZUugw/+pIOywXcDbFYgSct5cT3gqlbkBE1SJdwy6UQoZvodiWF/ckQLZyDE/Bu1M6gVu5lVw== qrcode-terminal@^0.12.0: version "0.12.0" resolved "https://registry.yarnpkg.com/qrcode-terminal/-/qrcode-terminal-0.12.0.tgz#bb5b699ef7f9f0505092a3748be4464fe71b5819" integrity sha512-EXtzRZmC+YGmGlDFbXKxQiMZNwCLEO6BANKXG4iCtSIM0yqc/pappSx3RIKr4r0uh5JsBckOXeKrB3Iz7mdQpQ== +qs@^6.4.0: + version "6.11.2" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.11.2.tgz#64bea51f12c1f5da1bc01496f48ffcff7c69d7d9" + integrity sha512-tDNIz22aBzCDxLtVH++VnTfzxlfeK5CbqohpSqpJgj1Wg/cQbStNAz3NuqCs5vV+pjBsK4x4pN9HlVh7rcYRiA== + dependencies: + side-channel "^1.0.4" + qs@~6.5.2: - version "6.5.2" - resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.2.tgz#cb3ae806e8740444584ef154ce8ee98d403f3e36" - integrity sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA== + version "6.5.3" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.3.tgz#3aeeffc91967ef6e35c0e488ef46fb296ab76aad" + integrity sha512-qxXIEh4pCGfHICj1mAJQ2/2XVZkjCDTcEgfoSQxc/fYivUZxTkk7L3bDBJSoNrEzXI17oUO5Dp07ktqE5KzczA== querystring@0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/querystring/-/querystring-0.2.0.tgz#b209849203bb25df820da756e747005878521620" - integrity sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA= + integrity sha512-X/xY82scca2tau62i9mDyU9K+I+djTMUsvwf7xnUX5GLvVzgJybOJf4Y6o9Zx3oJK/LSXg5tTZBjwzqVPaPO2g== queue-microtask@^1.2.2: version "1.2.3" @@ -6882,11 +7696,21 @@ quick-lru@^4.0.1: integrity sha512-ARhCpm70fzdcvNQfPoy49IaanKkTlRWF2JMzqhcJbhSFRZv7nPTvZJdcY7301IPmvW+/p0RgIWnQDLJxifsQ7g== ramda@^0.27.1: - version "0.27.1" - resolved "https://registry.yarnpkg.com/ramda/-/ramda-0.27.1.tgz#66fc2df3ef873874ffc2da6aa8984658abacf5c9" - integrity sha512-PgIdVpn5y5Yns8vqb8FzBUEYn98V3xcPgawAkkgj0YJ0qDsnHCiNmZYfOGMgOvoB0eWFLpYbhxUR3mxfDIMvpw== + version "0.27.2" + resolved "https://registry.yarnpkg.com/ramda/-/ramda-0.27.2.tgz#84463226f7f36dc33592f6f4ed6374c48306c3f1" + integrity sha512-SbiLPU40JuJniHexQSAgad32hfwd+DRUdwF2PlVuI5RZD0/vahUco7R8vD86J/tcEKKF9vZrUVwgtmGCqlCKyA== + +raw-body@^2.2.0: + version "2.5.2" + resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.5.2.tgz#99febd83b90e08975087e8f1f9419a149366b68a" + integrity sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA== + dependencies: + bytes "3.1.2" + http-errors "2.0.0" + iconv-lite "0.4.24" + unpipe "1.0.0" -rc@^1.2.8: +rc@1.2.8, rc@^1.2.8: version "1.2.8" resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.8.tgz#cd924bf5200a075b83c188cd6b9e211b7fc0d3ed" integrity sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw== @@ -6910,9 +7734,9 @@ read-package-json-fast@^2.0.1, read-package-json-fast@^2.0.2, read-package-json- npm-normalize-package-bin "^1.0.1" read-package-json@^4.1.1: - version "4.1.1" - resolved "https://registry.yarnpkg.com/read-package-json/-/read-package-json-4.1.1.tgz#153be72fce801578c1c86b8ef2b21188df1b9eea" - integrity sha512-P82sbZJ3ldDrWCOSKxJT0r/CXMWR0OR3KRh55SgKo3p91GSIEEC32v3lSHAvO/UcH3/IoL7uqhOFBduAnwdldw== + version "4.1.2" + resolved "https://registry.yarnpkg.com/read-package-json/-/read-package-json-4.1.2.tgz#b444d047de7c75d4a160cb056d00c0693c1df703" + integrity sha512-Dqer4pqzamDE2O4M55xp1qZMuLPqi4ldk2ya648FOMHRjwMzFhuxVrG04wd0c38IsvkVdr3vgHI6z+QTPdAjrQ== dependencies: glob "^7.1.1" json-parse-even-better-errors "^2.3.0" @@ -6941,14 +7765,24 @@ read-pkg@^5.0.0, read-pkg@^5.2.0: read@1, read@^1.0.7, read@~1.0.1, read@~1.0.7: version "1.0.7" resolved "https://registry.yarnpkg.com/read/-/read-1.0.7.tgz#b3da19bd052431a97671d44a42634adf710b40c4" - integrity sha1-s9oZvQUkMal2cdRKQmNK33ELQMQ= + integrity sha512-rSOKNYUmaxy0om1BNjMN4ezNT6VKK+2xF4GBhc81mkH7L60i6dp8qPYrkndNLT3QPphoII3maL9PVC9XmhHwVQ== dependencies: mute-stream "~0.0.4" readable-stream@1.1: version "1.1.13" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.1.13.tgz#f6eef764f514c89e2b9e23146a75ba106756d23e" - integrity sha1-9u73ZPUUyJ4rniMUanW6EGdW0j4= + integrity sha512-E98tWzqShvKDGpR2MbjsDkDQWLW2TfWUC15H4tNQhIJ5Lsta84l8nUGL9/ybltGwe+wZzWPpc1Kmd2wQP4bdCA== + dependencies: + core-util-is "~1.0.0" + inherits "~2.0.1" + isarray "0.0.1" + string_decoder "~0.10.x" + +readable-stream@1.1.x: + version "1.1.14" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.1.14.tgz#7cf4c54ef648e3813084c636dd2079e166c081d9" + integrity sha512-+MeVjFf4L44XUkhM1eYbD8fyEsxcV81pqMSR5gblfcLCHfZvbrqy4/qYHE+/R5HoBUT11WV5O08Cr1n3YXkWVQ== dependencies: core-util-is "~1.0.0" inherits "~2.0.1" @@ -6956,18 +7790,18 @@ readable-stream@1.1: string_decoder "~0.10.x" readable-stream@3, readable-stream@^3.0.0, readable-stream@^3.0.1, readable-stream@^3.1.1, readable-stream@^3.4.0, readable-stream@^3.6.0: - version "3.6.0" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.0.tgz#337bbda3adc0706bd3e024426a286d4b4b2c9198" - integrity sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA== + version "3.6.2" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.2.tgz#56a9b36ea965c00c5a93ef31eb111a0f11056967" + integrity sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA== dependencies: inherits "^2.0.3" string_decoder "^1.1.1" util-deprecate "^1.0.1" -readable-stream@^2.0.0, readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.0.5, readable-stream@^2.0.6, readable-stream@^2.1.5, readable-stream@^2.3.0, readable-stream@^2.3.3, readable-stream@^2.3.5, readable-stream@^2.3.6, readable-stream@^2.3.7, readable-stream@~2.3.6: - version "2.3.7" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.7.tgz#1eca1cf711aef814c04f62252a36a62f6cb23b57" - integrity sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw== +readable-stream@^2.0.0, readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.0.5, readable-stream@^2.0.6, readable-stream@^2.1.5, readable-stream@^2.3.0, readable-stream@^2.3.3, readable-stream@^2.3.5, readable-stream@^2.3.6, readable-stream@~2.3.6: + version "2.3.8" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.8.tgz#91125e8042bba1b9887f49345f6277027ce8be9b" + integrity sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA== dependencies: core-util-is "~1.0.0" inherits "~2.0.3" @@ -6980,7 +7814,7 @@ readable-stream@^2.0.0, readable-stream@^2.0.1, readable-stream@^2.0.2, readable readable-stream@~1.0.31: version "1.0.34" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.0.34.tgz#125820e34bc842d2f2aaafafe4c2916ee32c157c" - integrity sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw= + integrity sha512-ok1qVCJuRkNmvebYikljxJA/UEsKwLl2nI1OmaqAu4/UE+h0wKCHok4XkL/gvi39OacXvw59RJUOFUkDib2rHg== dependencies: core-util-is "~1.0.0" inherits "~2.0.1" @@ -7015,7 +7849,7 @@ redent@^3.0.0: redeyed@~2.1.0: version "2.1.1" resolved "https://registry.yarnpkg.com/redeyed/-/redeyed-2.1.1.tgz#8984b5815d99cb220469c99eeeffe38913e6cc0b" - integrity sha1-iYS1gV2ZyyIEacme7v/jiRPmzAs= + integrity sha512-FNpGGo1DycYAdnrKFxCMmKYgo/mILAqtRYbkdQD8Ep/Hk2PQ5+aEAEx+IU713RTDmuBaH0c8P5ZozurNu5ObRQ== dependencies: esprima "~4.0.0" @@ -7024,10 +7858,14 @@ regenerator-runtime@^0.11.0: resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz#be05ad7f9bf7d22e056f9726cee5017fbf19e2e9" integrity sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg== -regexpp@^3.2.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-3.2.0.tgz#0425a2768d8f23bad70ca4b90461fa2f1213e1b2" - integrity sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg== +regexp.prototype.flags@^1.4.3: + version "1.5.0" + resolved "https://registry.yarnpkg.com/regexp.prototype.flags/-/regexp.prototype.flags-1.5.0.tgz#fe7ce25e7e4cca8db37b6634c8a2c7009199b9cb" + integrity sha512-0SutC3pNudRKgquxGoRGIz946MZVHqbNfPjBdxeOhBrdgDKlRoXmYLQN9xRbrR09ZXWeGAdPuif7egofn6v5LA== + dependencies: + call-bind "^1.0.2" + define-properties "^1.2.0" + functions-have-names "^1.2.3" regextras@^0.8.0: version "0.8.0" @@ -7035,16 +7873,16 @@ regextras@^0.8.0: integrity sha512-k519uI04Z3SaY0fLX843MRXnDeG2+vHOFsyhiPZvNLe7r8rD2YNRjq4BQLZZ0oAr2NrtvZlICsXysGNFPGa3CQ== registry-auth-token@^4.0.0: - version "4.2.1" - resolved "https://registry.yarnpkg.com/registry-auth-token/-/registry-auth-token-4.2.1.tgz#6d7b4006441918972ccd5fedcd41dc322c79b250" - integrity sha512-6gkSb4U6aWJB4SF2ZvLb76yCBjcvufXBqvvEx1HbmKPkutswjW1xNVRY0+daljIYRbogN7O0etYSlbiaEQyMyw== + version "4.2.2" + resolved "https://registry.yarnpkg.com/registry-auth-token/-/registry-auth-token-4.2.2.tgz#f02d49c3668884612ca031419491a13539e21fac" + integrity sha512-PC5ZysNb42zpFME6D/XlIgtNGdTl8bBOCw90xQLVMpzuuubJKYDWFAEuUNc+Cn8Z8724tg2SDhDRrkVEsqfDMg== dependencies: - rc "^1.2.8" + rc "1.2.8" release-zalgo@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/release-zalgo/-/release-zalgo-1.0.0.tgz#09700b7e5074329739330e535c5a90fb67851730" - integrity sha1-CXALflB0Mpc5Mw5TXFqQ+2eFFzA= + integrity sha512-gUAyHVHPPC5wdqX/LG4LWtRYtgjxyX78oanFNTMMyFEfOqdC54s3eE82imuWKbOeqYht2CrNf64Qb8vgmmtZGA== dependencies: es6-error "^4.0.1" @@ -7059,7 +7897,7 @@ remove-bom-buffer@^3.0.0: remove-bom-stream@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/remove-bom-stream/-/remove-bom-stream-1.2.0.tgz#05f1a593f16e42e1fb90ebf59de8e569525f9523" - integrity sha1-BfGlk/FuQuH7kOv1nejlaVJflSM= + integrity sha512-wigO8/O08XHb8YPzpDDT+QmRANfW6vLqxfaXm1YXhnFf3AkSLyjfG3GEFg4McZkmgL7KvCj5u2KczkvSP6NfHA== dependencies: remove-bom-buffer "^3.0.0" safe-buffer "^5.1.0" @@ -7068,19 +7906,19 @@ remove-bom-stream@^1.2.0: remove-trailing-separator@^1.0.1: version "1.1.0" resolved "https://registry.yarnpkg.com/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz#c24bce2a283adad5bc3f58e0d48249b92379d8ef" - integrity sha1-wkvOKig62tW8P1jg1IJJuSN52O8= + integrity sha512-/hS+Y0u3aOfIETiaiirUFwDBDzmXPvO+jAfKTitUngIPzdKc6Z0LoFjM/CK5PL4C+eKwHohlHAb6H0VFfmmUsw== repeating@^1.1.0: version "1.1.3" resolved "https://registry.yarnpkg.com/repeating/-/repeating-1.1.3.tgz#3d4114218877537494f97f77f9785fab810fa4ac" - integrity sha1-PUEUIYh3U3SU+X93+Xhfq4EPpKw= + integrity sha512-Nh30JLeMHdoI+AsQ5eblhZ7YlTsM9wiJQe/AHIunlK3KWzvXhXb36IJ7K1IOeRjIOtzMjdUHjwXUFxKJoPTSOg== dependencies: is-finite "^1.0.0" repeating@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/repeating/-/repeating-2.0.1.tgz#5214c53a926d3552707527fbab415dbc08d06dda" - integrity sha1-UhTFOpJtNVJwdSf7q0FdvAjQbdo= + integrity sha512-ZqtSMuVybkISo2OWvqvm7iHSWngvdaW3IpsT9/uP8v4gMi591LY6h35wdOfvQdWCKFWZWm2Y1Opp4kV7vQKT6A== dependencies: is-finite "^1.0.0" @@ -7115,18 +7953,10 @@ replace-ext@^1.0.0: tunnel-agent "^0.6.0" uuid "^3.3.2" -requestretry@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/requestretry/-/requestretry-6.0.0.tgz#a213b2133ee3b18f74c2bbc0f4e094e561b57335" - integrity sha512-X7O+BMlfHgzetfSDtgQIMinLn1BuT+95W12iffDzyOS+HLoBEIQqCZv++UTChUWVjOu+pudbocD76+4j+jK9ww== - dependencies: - extend "^3.0.2" - lodash "^4.17.15" - require-directory@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" - integrity sha1-jGStX9MNqxyXbiNE/+f3kqam30I= + integrity sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q== require-main-filename@^2.0.0: version "2.0.0" @@ -7153,17 +7983,18 @@ resolve-global@1.0.0, resolve-global@^1.0.0: resolve-options@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/resolve-options/-/resolve-options-1.1.0.tgz#32bb9e39c06d67338dc9378c0d6d6074566ad131" - integrity sha1-MrueOcBtZzONyTeMDW1gdFZq0TE= + integrity sha512-NYDgziiroVeDC29xq7bp/CacZERYsA9bXYd1ZmcJlF3BcrZv5pTb4NG7SjdyKDnXZ84aC4vo2u6sNKIA1LCu/A== dependencies: value-or-function "^3.0.0" resolve@^1.10.0: - version "1.20.0" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.20.0.tgz#629a013fb3f70755d6f0b7935cc1c2c5378b1975" - integrity sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A== + version "1.22.2" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.22.2.tgz#0ed0943d4e301867955766c9f3e1ae6d01c6845f" + integrity sha512-Sb+mjNHOULsBv818T40qSPeRiuWLyaGMa5ewydRLFimneixmVy2zdivRl+AF6jaYPC8ERxGDmFSiqui6SfPd+g== dependencies: - is-core-module "^2.2.0" - path-parse "^1.0.6" + is-core-module "^2.11.0" + path-parse "^1.0.7" + supports-preserve-symlinks-flag "^1.0.0" restore-cursor@^3.1.0: version "3.1.0" @@ -7173,21 +8004,29 @@ restore-cursor@^3.1.0: onetime "^5.1.0" signal-exit "^3.0.2" -retry-as-promised@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/retry-as-promised/-/retry-as-promised-5.0.0.tgz#f4ecc25133603a2d2a7aff4a128691d7bc506d54" - integrity sha512-6S+5LvtTl2ggBumk04hBo/4Uf6fRJUwIgunGZ7CYEBCeufGFW1Pu6ucUf/UskHeWOIsUcLOGLFXPig5tR5V1nA== +retry-as-promised@^7.0.4: + version "7.0.4" + resolved "https://registry.yarnpkg.com/retry-as-promised/-/retry-as-promised-7.0.4.tgz#9df73adaeea08cb2948b9d34990549dc13d800a2" + integrity sha512-XgmCoxKWkDofwH8WddD0w85ZfqYz+ZHlr5yo+3YUCfycWawU56T5ckWXsScsj5B8tqUcIG67DxXByo3VUgiAdA== -retry@^0.12.0: - version "0.12.0" - resolved "https://registry.yarnpkg.com/retry/-/retry-0.12.0.tgz#1b42a6266a21f07421d1b0b54b7dc167b01c013b" - integrity sha1-G0KmJmoh8HQh0bC1S33BZ7AcATs= +retry-request@^5.0.0: + version "5.0.2" + resolved "https://registry.yarnpkg.com/retry-request/-/retry-request-5.0.2.tgz#143d85f90c755af407fcc46b7166a4ba520e44da" + integrity sha512-wfI3pk7EE80lCIXprqh7ym48IHYdwmAAzESdbU8Q9l7pnRCk9LEhpbOTNKjz6FARLm/Bl5m+4F0ABxOkYUujSQ== + dependencies: + debug "^4.1.1" + extend "^3.0.2" -retry@^0.13.1: +retry@0.13.1: version "0.13.1" resolved "https://registry.yarnpkg.com/retry/-/retry-0.13.1.tgz#185b1587acf67919d63b357349e03537b2484658" integrity sha512-XQBQ3I8W1Cge0Seh+6gjj03LbmRFWuoszgK9ooCpwYIrhhoO80pfq4cUkU5DkknwfOfFteRwlZ56PYOGYyFWdg== +retry@^0.12.0: + version "0.12.0" + resolved "https://registry.yarnpkg.com/retry/-/retry-0.12.0.tgz#1b42a6266a21f07421d1b0b54b7dc167b01c013b" + integrity sha512-9LkiTwjUh6rT555DtE9rTX+BKByPfrMzEAtnlEtdEwr3Nkffwiihqe2bWADg+OQRjt9gl6ICdmB/ZFDCGAtSow== + reusify@^1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/reusify/-/reusify-1.0.4.tgz#90da382b1e126efc02146e90845a88db12925d76" @@ -7213,13 +8052,13 @@ rimraf@^3.0.0, rimraf@^3.0.2: glob "^7.1.3" run-con@~1.2.10: - version "1.2.10" - resolved "https://registry.yarnpkg.com/run-con/-/run-con-1.2.10.tgz#90de9d43d20274d00478f4c000495bd72f417d22" - integrity sha512-n7PZpYmMM26ZO21dd8y3Yw1TRtGABjRtgPSgFS/nhzfvbJMXFtJhJVyEgayMiP+w/23craJjsnfDvx4W4ue/HQ== + version "1.2.11" + resolved "https://registry.yarnpkg.com/run-con/-/run-con-1.2.11.tgz#0014ed430bad034a60568dfe7de2235f32e3f3c4" + integrity sha512-NEMGsUT+cglWkzEr4IFK21P4Jca45HqiAbIIZIBdX5+UZTB24Mb/21iNGgz9xZa8tL6vbW7CXmq7MFN42+VjNQ== dependencies: deep-extend "^0.6.0" - ini "~2.0.0" - minimist "^1.2.5" + ini "~3.0.0" + minimist "^1.2.6" strip-json-comments "~3.1.1" run-parallel@^1.1.9: @@ -7229,12 +8068,22 @@ run-parallel@^1.1.9: dependencies: queue-microtask "^1.2.2" -rxjs@^7.4.0: - version "7.4.0" - resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-7.4.0.tgz#a12a44d7eebf016f5ff2441b87f28c9a51cebc68" - integrity sha512-7SQDi7xeTMCJpqViXh8gL/lebcwlp3d831F05+9B44A4B0WfsEwUQHR64gsH1kvJ+Ep/J9K2+n1hVl1CsGN23w== +rxjs@^7.5.5: + version "7.8.1" + resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-7.8.1.tgz#6f6f3d99ea8044291efd92e7c7fcf562c4057543" + integrity sha512-AA3TVj+0A2iuIoQkWEK/tqFjBq2j+6PO6Y0zJcvzLAFhEFIO3HL0vls9hWLncZbAAbK0mar7oZ4V079I/qPMxg== + dependencies: + tslib "^2.1.0" + +safe-array-concat@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/safe-array-concat/-/safe-array-concat-1.0.0.tgz#2064223cba3c08d2ee05148eedbc563cd6d84060" + integrity sha512-9dVEFruWIsnie89yym+xWTAYASdpw3CJV7Li/6zBewGf9z2i1j31rP6jnY0pHEO4QZh6N0K11bFjWmdR8UGdPQ== dependencies: - tslib "~2.1.0" + call-bind "^1.0.2" + get-intrinsic "^1.2.0" + has-symbols "^1.0.3" + isarray "^2.0.5" safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.1, safe-buffer@^5.1.2, safe-buffer@~5.2.0: version "5.2.1" @@ -7246,10 +8095,19 @@ safe-buffer@~5.1.0, safe-buffer@~5.1.1: resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== -safe-stable-stringify@^1.1.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/safe-stable-stringify/-/safe-stable-stringify-1.1.1.tgz#c8a220ab525cd94e60ebf47ddc404d610dc5d84a" - integrity sha512-ERq4hUjKDbJfE4+XtZLFPCDi8Vb1JqaxAPTxWFLBx8XcAlf9Bda/ZJdVezs/NAfsMQScyIlUMx+Yeu7P7rx5jw== +safe-regex-test@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/safe-regex-test/-/safe-regex-test-1.0.0.tgz#793b874d524eb3640d1873aad03596db2d4f2295" + integrity sha512-JBUUzyOgEwXQY1NuPtvcj/qcBDbDmEvWufhlnXZIm75DEHp+afM1r1ujJpJsV/gSM4t59tpDyPi1sd6ZaPFfsA== + dependencies: + call-bind "^1.0.2" + get-intrinsic "^1.1.3" + is-regex "^1.1.4" + +safe-stable-stringify@^2.3.1: + version "2.4.3" + resolved "https://registry.yarnpkg.com/safe-stable-stringify/-/safe-stable-stringify-2.4.3.tgz#138c84b6f6edb3db5f8ef3ef7115b8f55ccbf886" + integrity sha512-e2bDA2WJT0wxseVd4lsDP4+3ONX6HpMXQa1ZhFQ7SU+GjvORCmShbCMltrtIDfkYhVHrOcPtj+KhmDBdPdZD1g== "safer-buffer@>= 2.1.2 < 3", "safer-buffer@>= 2.1.2 < 3.0.0", safer-buffer@^2.0.2, safer-buffer@^2.1.0, safer-buffer@~2.1.0: version "2.1.2" @@ -7259,7 +8117,7 @@ safe-stable-stringify@^1.1.0: sax@1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.1.tgz#7b8e656190b228e81a66aea748480d828cd2d37a" - integrity sha1-e45lYZCyKOgaZq6nSEgNgozS03o= + integrity sha512-8I2a3LovHTOpm7NV5yOyO8IHqgVsfK4+UuySrXU8YXkSRX7k6hCV9b3HrkKCr3nMpgj+0bmocaJJWpvp1oc7ZA== sax@>=0.6.0, sax@^1.1.4: version "1.2.4" @@ -7308,7 +8166,7 @@ semantic-release@^18.0.1: semver-compare@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/semver-compare/-/semver-compare-1.0.0.tgz#0dee216a1c941ab37e9efb1788f6afc5ff5537fc" - integrity sha1-De4hahyUGrN+nvsXiPavxf9VN/w= + integrity sha512-YM3/ITh2MJ5MtzaM429anh+x2jiLVjqILF4m4oyQB18W7Ggea7BfqdH/wGMK7dDiMghv/6WG7znWMwUDzJiXow== semver-diff@^3.1.1: version "3.1.1" @@ -7318,16 +8176,16 @@ semver-diff@^3.1.1: semver "^6.3.0" semver-regex@^3.1.2: - version "3.1.3" - resolved "https://registry.yarnpkg.com/semver-regex/-/semver-regex-3.1.3.tgz#b2bcc6f97f63269f286994e297e229b6245d0dc3" - integrity sha512-Aqi54Mk9uYTjVexLnR67rTyBusmwd04cLkHy9hNvk3+G3nT2Oyg7E0l4XVbOaNwIvQ3hHeYxGcyEy+mKreyBFQ== + version "3.1.4" + resolved "https://registry.yarnpkg.com/semver-regex/-/semver-regex-3.1.4.tgz#13053c0d4aa11d070a2f2872b6b1e3ae1e1971b4" + integrity sha512-6IiqeZNgq01qGf0TId0t3NvKzSvUsjcpdEO3AQNeIjR6A2+ckTnQlDpl4qu1bjRv0RzN3FP9hzFmws3lKqRWkA== -"semver@2 || 3 || 4 || 5", semver@^5.4.1, semver@^5.6.0, semver@^5.7.0: +"semver@2 || 3 || 4 || 5", semver@^5.0.1, semver@^5.4.1, semver@^5.7.0: version "5.7.1" resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== -semver@7.3.5, semver@^7.1.1, semver@^7.1.2, semver@^7.1.3, semver@^7.2.1, semver@^7.3.2, semver@^7.3.4, semver@^7.3.5: +semver@7.3.5: version "7.3.5" resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.5.tgz#0b621c879348d8998e4b0e4be94b3f12e6018ef7" integrity sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ== @@ -7339,10 +8197,24 @@ semver@^6.0.0, semver@^6.3.0: resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== +semver@^7.1.1, semver@^7.1.2, semver@^7.3.2, semver@^7.3.4, semver@^7.3.5, semver@^7.3.7, semver@^7.3.8: + version "7.5.2" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.2.tgz#5b851e66d1be07c1cdaf37dfc856f543325a2beb" + integrity sha512-SoftuTROv/cRjCze/scjGyiDtcUyxw1rgYQSZY7XTmtR5hX+dm76iDbTH8TkLPHCQmlbQVSSbNZCPM2hb0knnQ== + dependencies: + lru-cache "^6.0.0" + +semver@^7.1.3, semver@^7.5.4: + version "7.5.4" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.4.tgz#483986ec4ed38e1c6c48c34894a9182dbff68a6e" + integrity sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA== + dependencies: + lru-cache "^6.0.0" + seq-queue@^0.0.5: version "0.0.5" resolved "https://registry.yarnpkg.com/seq-queue/-/seq-queue-0.0.5.tgz#d56812e1c017a6e4e7c3e3a37a1da6d78dd3c93e" - integrity sha1-1WgS4cAXpuTnw+Ojeh2m143TyT4= + integrity sha512-hr3Wtp/GZIc/6DAGPDcV4/9WoZhjrkXsi5B/07QgX8tsdc6ilr7BFM6PM6rbdAX1kFSDYeZGLipIZZKyQP0O5Q== sequelize-pool@^7.1.0: version "7.1.0" @@ -7352,12 +8224,17 @@ sequelize-pool@^7.1.0: set-blocking@^2.0.0, set-blocking@~2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" - integrity sha1-BF+XgtARrppoA93TgrJDkrPYkPc= + integrity sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw== setimmediate@~1.0.4: version "1.0.5" resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285" - integrity sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU= + integrity sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA== + +setprototypeof@1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.2.0.tgz#66c9a24a73f9fc28cbe66b09fed3d33dcaf1b424" + integrity sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw== shebang-command@^2.0.0: version "2.0.0" @@ -7385,10 +8262,10 @@ side-channel@^1.0.4: get-intrinsic "^1.0.2" object-inspect "^1.9.0" -signal-exit@^3.0.0, signal-exit@^3.0.2, signal-exit@^3.0.3: - version "3.0.6" - resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.6.tgz#24e630c4b0f03fea446a2bd299e62b4a6ca8d0af" - integrity sha512-sDl4qMFpijcGw22U5w63KmD3cZJfBuFlVNbVMKje2keoKML7X2UzWbc4XrmEbDwg0NXJc3yv4/ox7b+JWb57kQ== +signal-exit@^3.0.0, signal-exit@^3.0.2, signal-exit@^3.0.3, signal-exit@^3.0.7: + version "3.0.7" + resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.7.tgz#a9a1767f8af84155114eaabd73f99273c8f59ad9" + integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ== signale@^1.2.1: version "1.4.0" @@ -7399,15 +8276,15 @@ signale@^1.2.1: figures "^2.0.0" pkg-conf "^2.1.0" -simple-lru-cache@0.0.2, simple-lru-cache@^0.0.2: +simple-lru-cache@^0.0.2: version "0.0.2" resolved "https://registry.yarnpkg.com/simple-lru-cache/-/simple-lru-cache-0.0.2.tgz#d59cc3a193c1a5d0320f84ee732f6e4713e511dd" - integrity sha1-1ZzDoZPBpdAyD4Tucy9uRxPlEd0= + integrity sha512-uEv/AFO0ADI7d99OHDmh1QfYzQk/izT1vCmu/riQfh7qjBVUUgRT87E5s5h7CxWCA/+YoZerykpEthzVrW3LIw== simple-swizzle@^0.2.2: version "0.2.2" resolved "https://registry.yarnpkg.com/simple-swizzle/-/simple-swizzle-0.2.2.tgz#a4da6b635ffcccca33f70d17cb92592de95e557a" - integrity sha1-pNprY1/8zMoz9w0Xy5JZLeleVXo= + integrity sha512-JA//kQgZtbuY83m+xT+tXJkmJncGMTFT+C+g2h2R9uxkYIrE2yy9sgmcLhCnw57/WSD+Eh3J97FPEDFnbXnDUg== dependencies: is-arrayish "^0.3.1" @@ -7459,70 +8336,77 @@ slice-ansi@^5.0.0: ansi-styles "^6.0.0" is-fullwidth-code-point "^4.0.0" -smart-buffer@^4.1.0: +smart-buffer@^4.2.0: version "4.2.0" resolved "https://registry.yarnpkg.com/smart-buffer/-/smart-buffer-4.2.0.tgz#6e1d71fa4f18c05f7d0ff216dd16a481d0e8d9ae" integrity sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg== snowflake-sdk@^1.6.6: - version "1.6.6" - resolved "https://registry.yarnpkg.com/snowflake-sdk/-/snowflake-sdk-1.6.6.tgz#7ab8a1abc0a73b1e7a1c73ffe341310b83a7cb57" - integrity sha512-b8mbYI6TFGe8H0m0eviNd4FC/3jsw02OHNt21k9sLWkBp4re2VUhaJf7555ln7thMSnMcbkdAB8zQBZcbqdoPg== + version "1.6.23" + resolved "https://registry.yarnpkg.com/snowflake-sdk/-/snowflake-sdk-1.6.23.tgz#f6b16bcfce1fadaa0b2c51d8aabaaa6f1bf4b5d2" + integrity sha512-meKcFQ2NggyhItmZ019JJ5UAeQiN0n98P7plAhM9DjVvI04JngvprUsmluu7c6Ujo/IYQC6jC8/7+cmgiMC7Bw== dependencies: - "@azure/storage-blob" "^12.5.0" - agent-base "^4.3.0" + "@azure/storage-blob" "^12.11.0" + "@google-cloud/storage" "^6.9.3" + "@techteamer/ocsp" "1.0.0" + agent-base "^6.0.2" asn1.js-rfc2560 "^5.0.0" asn1.js-rfc5280 "^3.0.0" + async "^3.2.3" aws-sdk "^2.878.0" - axios "^0.21.4" + axios "^0.27.2" + better-eval "^1.3.0" big-integer "^1.6.43" bignumber.js "^2.4.0" binascii "0.0.2" + bn.js "^5.2.1" browser-request "^0.3.3" debug "^3.2.6" expand-tilde "^2.0.2" extend "^3.0.2" + fast-xml-parser "^4.1.3" generic-pool "^3.8.2" glob "^7.1.6" - http-signature "^1.3.6" - https-proxy-agent "^3.0.0" - json-schema "^0.4.0" - jsonwebtoken "^8.5.1" - jsprim "^2.0.2" - lodash "^4.17.21" + https-proxy-agent "^5.0.1" + jsonwebtoken "^9.0.0" mime-types "^2.1.29" mkdirp "^1.0.3" - mock-require "^3.0.3" - moment "^2.23.0" + moment "^2.29.4" moment-timezone "^0.5.15" - ocsp "^1.2.0" open "^7.3.1" python-struct "^1.1.3" - request "^2.88.2" - requestretry "^6.0.0" simple-lru-cache "^0.0.2" string-similarity "^4.0.4" - test-console "^2.0.0" tmp "^0.2.1" + urllib "^2.38.0" uuid "^3.3.2" winston "^3.1.0" +socks-proxy-agent@5, socks-proxy-agent@^5.0.0: + version "5.0.1" + resolved "https://registry.yarnpkg.com/socks-proxy-agent/-/socks-proxy-agent-5.0.1.tgz#032fb583048a29ebffec2e6a73fca0761f48177e" + integrity sha512-vZdmnjb9a2Tz6WEQVIurybSwElwPxMZaIc7PzqbJTrezcKNznv6giT7J7tZDZ1BojVaa1jvO/UiUdhDVB0ACoQ== + dependencies: + agent-base "^6.0.2" + debug "4" + socks "^2.3.3" + socks-proxy-agent@^6.0.0: - version "6.1.1" - resolved "https://registry.yarnpkg.com/socks-proxy-agent/-/socks-proxy-agent-6.1.1.tgz#e664e8f1aaf4e1fb3df945f09e3d94f911137f87" - integrity sha512-t8J0kG3csjA4g6FTbsMOWws+7R7vuRC8aQ/wy3/1OWmsgwA68zs/+cExQ0koSitUDXqhufF/YJr9wtNMZHw5Ew== + version "6.2.1" + resolved "https://registry.yarnpkg.com/socks-proxy-agent/-/socks-proxy-agent-6.2.1.tgz#2687a31f9d7185e38d530bef1944fe1f1496d6ce" + integrity sha512-a6KW9G+6B3nWZ1yB8G7pJwL3ggLy1uTzKAgCb7ttblwqdz9fMGJUuTy3uFzEP48FAs9FLILlmzDlE2JJhVQaXQ== dependencies: agent-base "^6.0.2" - debug "^4.3.1" - socks "^2.6.1" + debug "^4.3.3" + socks "^2.6.2" -socks@^2.6.1: - version "2.6.1" - resolved "https://registry.yarnpkg.com/socks/-/socks-2.6.1.tgz#989e6534a07cf337deb1b1c94aaa44296520d30e" - integrity sha512-kLQ9N5ucj8uIcxrDwjm0Jsqk06xdpBjGNQtpXy4Q8/QY2k+fY7nZH8CARy+hkbG+SGAovmzzuauCpBlb8FrnBA== +socks@^2.3.3, socks@^2.6.2: + version "2.7.1" + resolved "https://registry.yarnpkg.com/socks/-/socks-2.7.1.tgz#d8e651247178fde79c0663043e07240196857d55" + integrity sha512-7maUZy1N7uo6+WVEX6psASxtNlKaNVMlGQKkG/63nEDdLOWNbiUMoLK7X4uYoLhQstau72mLgfEWcXcwsaHbYQ== dependencies: - ip "^1.1.5" - smart-buffer "^4.1.0" + ip "^2.0.0" + smart-buffer "^4.2.0" source-map-support@^0.5.17, source-map-support@^0.5.21: version "0.5.21" @@ -7535,7 +8419,7 @@ source-map-support@^0.5.17, source-map-support@^0.5.21: source-map@^0.5.0, source-map@^0.5.7: version "0.5.7" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" - integrity sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w= + integrity sha512-LbrmJOMUSdEVxIKvdcJzQC+nQhe8FUZQTXQy6+I75skNgn3OoQ0DZA8YnFa7gp8tqtL3KPf1kmo0R5DoApeSGQ== source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.1: version "0.6.1" @@ -7545,7 +8429,7 @@ source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.1: spawn-error-forwarder@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/spawn-error-forwarder/-/spawn-error-forwarder-1.0.0.tgz#1afd94738e999b0346d7b9fc373be55e07577029" - integrity sha1-Gv2Uc46ZmwNG17n8NzvlXgdXcCk= + integrity sha512-gRjMgK5uFjbCvdibeGJuy3I5OYz6VLoVdsOJdA6wV0WlfQVLFueoqMxwwYD9RODdgb6oUIvlRlsyFSiQkMKu0g== spawn-wrap@^2.0.0: version "2.0.0" @@ -7560,9 +8444,9 @@ spawn-wrap@^2.0.0: which "^2.0.1" spdx-correct@^3.0.0: - version "3.1.1" - resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-3.1.1.tgz#dece81ac9c1e6713e5f7d1b6f17d468fa53d89a9" - integrity sha512-cOYcUWwhCuHCXi49RhFRCyJEK3iPj1Ziz9DpViV3tbZOwXD49QzIN3MpOLJNxh2qwq2lJJZaKMVw9qNi4jTC0w== + version "3.2.0" + resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-3.2.0.tgz#4f5ab0668f0059e34f9c00dce331784a12de4e9c" + integrity sha512-kN9dJbvnySHULIluDHy32WHRUu3Og7B9sbY7tsFLctQkIqnMh3hErYgdMjTYuqmcXX+lK5T1lnUt3G7zNswmZA== dependencies: spdx-expression-parse "^3.0.0" spdx-license-ids "^3.0.0" @@ -7581,21 +8465,26 @@ spdx-expression-parse@^3.0.0, spdx-expression-parse@^3.0.1: spdx-license-ids "^3.0.0" spdx-license-ids@^3.0.0: - version "3.0.11" - resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-3.0.11.tgz#50c0d8c40a14ec1bf449bae69a0ea4685a9d9f95" - integrity sha512-Ctl2BrFiM0X3MANYgj3CkygxhRmr9mi6xhejbdO960nF6EDJApTYpn0BQnDKlnNBULKiCN1n3w9EBkHK8ZWg+g== + version "3.0.13" + resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-3.0.13.tgz#7189a474c46f8d47c7b0da4b987bb45e908bd2d5" + integrity sha512-XkD+zwiqXHikFZm4AX/7JSCXA98U5Db4AFd5XUg/+9UNtnH75+Z9KxtpYiJZx36mUDVOwH83pl7yvCer6ewM3w== -split2@^3.0.0, split2@^3.1.1: +split2@^3.0.0: version "3.2.2" resolved "https://registry.yarnpkg.com/split2/-/split2-3.2.2.tgz#bf2cf2a37d838312c249c89206fd7a17dd12365f" integrity sha512-9NThjpgZnifTkJpzTZ7Eue85S49QwpNhZTq6GRJwObb6jnLFNGB7Qm73V5HewTROPyxD0C29xqmaI68bQtV+hg== dependencies: readable-stream "^3.0.0" +split2@^4.1.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/split2/-/split2-4.2.0.tgz#c9c5920904d148bab0b9f67145f245a86aadbfa4" + integrity sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg== + split2@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/split2/-/split2-1.0.0.tgz#52e2e221d88c75f9a73f90556e263ff96772b314" - integrity sha1-UuLiIdiMdfmnP5BVbiY/+WdysxQ= + integrity sha512-NKywug4u4pX/AZBB1FCPzZ6/7O+Xhz1qMVbzTvvKvikjO99oPN87SkK08mEY9P63/5lWjK+wgOOgApnTg5r6qg== dependencies: through2 "~2.0.0" @@ -7614,24 +8503,28 @@ sprintf-js@^1.1.2: sprintf-js@~1.0.2: version "1.0.3" resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" - integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw= + integrity sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g== -"sqlite3@npm:@vscode/sqlite3@^5.0.7": - version "5.0.7" - resolved "https://registry.yarnpkg.com/@vscode/sqlite3/-/sqlite3-5.0.7.tgz#358df36bb0e9e735c54785e3e4b9b2dce1d32895" - integrity sha512-NlsOf+Hir2r4zopI1qMvzWXPwPJuFscirkmFTniTAT24Yz2FWcyZxzK7UT8iSNiTqOCPz48yF55ZVHaz7tTuVQ== +sqlite3@^5.1.6: + version "5.1.6" + resolved "https://registry.yarnpkg.com/sqlite3/-/sqlite3-5.1.6.tgz#1d4fbc90fe4fbd51e952e0a90fd8f6c2b9098e97" + integrity sha512-olYkWoKFVNSSSQNvxVUfjiVbz3YtBwTJj+mfV5zpHmqW3sELx2Cf4QCdirMelhM5Zh+KDVaKgQHqCxrqiWHybw== dependencies: + "@mapbox/node-pre-gyp" "^1.0.0" node-addon-api "^4.2.0" + tar "^6.1.11" + optionalDependencies: + node-gyp "8.x" sqlstring@^2.3.2: - version "2.3.2" - resolved "https://registry.yarnpkg.com/sqlstring/-/sqlstring-2.3.2.tgz#cdae7169389a1375b18e885f2e60b3e460809514" - integrity sha512-vF4ZbYdKS8OnoJAWBmMxCQDkiEBkGQYU7UZPtL8flbDRSNkhaXvRJ279ZtI6M+zDaQovVU4tuRgzK5fVhvFAhg== + version "2.3.3" + resolved "https://registry.yarnpkg.com/sqlstring/-/sqlstring-2.3.3.tgz#2ddc21f03bce2c387ed60680e739922c65751d0c" + integrity sha512-qC9iz2FlN7DQl3+wjwn3802RTyjCx7sDvfQEXchwa6CWOx07/WVfh91gBmQ9fahw8snwGEWU3xGzOt4tFyHLxg== -sshpk@^1.14.1, sshpk@^1.7.0: - version "1.16.1" - resolved "https://registry.yarnpkg.com/sshpk/-/sshpk-1.16.1.tgz#fb661c0bef29b39db40769ee39fa70093d6f6877" - integrity sha512-HXXqVUq7+pcKeLqqZj6mHFUMvXtOJt1uoUx09pFW6011inTMxqI8BA8PM95myrIyyKwdnzjdFjLiE6KBPVtJIg== +sshpk@^1.7.0: + version "1.17.0" + resolved "https://registry.yarnpkg.com/sshpk/-/sshpk-1.17.0.tgz#578082d92d4fe612b13007496e543fa0fbcbe4c5" + integrity sha512-/9HIEs1ZXGhSPE8X6Ccm7Nam1z8KcoCqPdI7ecm1N33EzAetWahvQWVqLZtaZQ+IDKX4IyA2o0gBzqIMkAagHQ== dependencies: asn1 "~0.2.3" assert-plus "^1.0.0" @@ -7653,30 +8546,47 @@ ssri@^8.0.0, ssri@^8.0.1: stack-chain@^1.3.7: version "1.3.7" resolved "https://registry.yarnpkg.com/stack-chain/-/stack-chain-1.3.7.tgz#d192c9ff4ea6a22c94c4dd459171e3f00cea1285" - integrity sha1-0ZLJ/06moiyUxN1FkXHj8AzqEoU= + integrity sha512-D8cWtWVdIe/jBA7v5p5Hwl5yOSOrmZPWDPe2KxQ5UAGD+nxbxU0lKXA4h85Ta6+qgdKVL3vUxsbIZjc1kBG7ug== stack-trace@0.0.x: version "0.0.10" resolved "https://registry.yarnpkg.com/stack-trace/-/stack-trace-0.0.10.tgz#547c70b347e8d32b4e108ea1a2a159e5fdde19c0" - integrity sha1-VHxws0fo0ytOEI6hoqFZ5f3eGcA= + integrity sha512-KGzahc7puUKkzyMt+IqAep+TVNbKP+k2Lmwhub39m1AsTSkaDutx56aDCo+HLDzf/D26BIHTJWNiTG1KAJiQCg== + +statuses@2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/statuses/-/statuses-2.0.1.tgz#55cb000ccf1d48728bd23c685a063998cf1a1b63" + integrity sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ== + +statuses@^1.3.1: + version "1.5.0" + resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c" + integrity sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA== stream-combiner2@~1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/stream-combiner2/-/stream-combiner2-1.1.1.tgz#fb4d8a1420ea362764e21ad4780397bebcb41cbe" - integrity sha1-+02KFCDqNidk4hrUeAOXvry0HL4= + integrity sha512-3PnJbYgS56AeWgtKF5jtJRT6uFJe56Z0Hc5Ngg/6sI6rIt8iiMBTa9cvdyFfpMQjaVHr8dusbNeFGIIonxOvKw== dependencies: duplexer2 "~0.1.0" readable-stream "^2.0.2" +stream-events@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/stream-events/-/stream-events-1.0.5.tgz#bbc898ec4df33a4902d892333d47da9bf1c406d5" + integrity sha512-E1GUzBSgvct8Jsb3v2X15pjzN1tYebtbLaMg+eBOUOAxgbLoSbT2NS91ckc5lJD1KfLjId+jXJRgo0qnV5Nerg== + dependencies: + stubs "^3.0.0" + stream-shift@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/stream-shift/-/stream-shift-1.0.1.tgz#d7088281559ab2778424279b0877da3c392d5a3d" integrity sha512-AiisoFqQ0vbGcZgQPY1cdP2I76glaVA/RauYR4G4thNFgkTqr90yXTo4LYX60Jl+sIlPNHHdGSwo01AvbKUSVQ== string-argv@^0.3.1: - version "0.3.1" - resolved "https://registry.yarnpkg.com/string-argv/-/string-argv-0.3.1.tgz#95e2fbec0427ae19184935f816d74aaa4c5c19da" - integrity sha512-a1uQGz7IyVy9YwhqjZIZu1c8JO8dNIe20xBmSS6qu9kv++k3JGzCVmprbNN5Kn+BgzD5E7YYwg1CcjuJMRNsvg== + version "0.3.2" + resolved "https://registry.yarnpkg.com/string-argv/-/string-argv-0.3.2.tgz#2b6d0ef24b656274d957d54e0a4bbf6153dc02b6" + integrity sha512-aqD2Q0144Z+/RqG52NeHEkZauTAUWJO8c6yTftGJKO3Tja5tUgIfmIl6kExvhtxSDP7fXB6DvzkfMpCd/F3G+Q== string-similarity@^4.0.4: version "4.0.4" @@ -7686,13 +8596,13 @@ string-similarity@^4.0.4: string-width@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/string-width/-/string-width-1.0.2.tgz#118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3" - integrity sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M= + integrity sha512-0XsVpQLnVCXHJfyEs8tC0zpTVIr5PKKsQtkT29IwupnPTjtPmQ3xT/4yCREF9hYkV/3M3kzcUTSAZT6a6h81tw== dependencies: code-point-at "^1.0.0" is-fullwidth-code-point "^1.0.0" strip-ansi "^3.0.0" -"string-width@^1.0.1 || ^2.0.0", "string-width@^1.0.2 || 2", string-width@^2.0.0: +"string-width@^1.0.2 || 2", string-width@^2.0.0: version "2.1.1" resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e" integrity sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw== @@ -7700,7 +8610,7 @@ string-width@^1.0.1: is-fullwidth-code-point "^2.0.0" strip-ansi "^4.0.0" -"string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0, string-width@^4.2.0: +"string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: version "4.2.3" resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== @@ -7719,29 +8629,40 @@ string-width@^3.0.0, string-width@^3.1.0: strip-ansi "^5.1.0" string-width@^5.0.0: - version "5.0.1" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-5.0.1.tgz#0d8158335a6cfd8eb95da9b6b262ce314a036ffd" - integrity sha512-5ohWO/M4//8lErlUUtrFy3b11GtNOuMOU0ysKCDXFcfXuuvUXu95akgj/i8ofmaGdN0hCqyl6uu9i8dS/mQp5g== + version "5.1.2" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-5.1.2.tgz#14f8daec6d81e7221d2a357e668cab73bdbca794" + integrity sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA== dependencies: + eastasianwidth "^0.2.0" emoji-regex "^9.2.2" - is-fullwidth-code-point "^4.0.0" strip-ansi "^7.0.1" -string.prototype.trimend@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/string.prototype.trimend/-/string.prototype.trimend-1.0.4.tgz#e75ae90c2942c63504686c18b287b4a0b1a45f80" - integrity sha512-y9xCjw1P23Awk8EvTpcyL2NIr1j7wJ39f+k6lvRnSMz+mz9CGz9NYPelDk42kOz6+ql8xjfK8oYzy3jAP5QU5A== +string.prototype.trim@^1.2.7: + version "1.2.7" + resolved "https://registry.yarnpkg.com/string.prototype.trim/-/string.prototype.trim-1.2.7.tgz#a68352740859f6893f14ce3ef1bb3037f7a90533" + integrity sha512-p6TmeT1T3411M8Cgg9wBTMRtY2q9+PNy9EV1i2lIXUN/btt763oIfxwN3RR8VU6wHX8j/1CFy0L+YuThm6bgOg== dependencies: call-bind "^1.0.2" - define-properties "^1.1.3" + define-properties "^1.1.4" + es-abstract "^1.20.4" -string.prototype.trimstart@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/string.prototype.trimstart/-/string.prototype.trimstart-1.0.4.tgz#b36399af4ab2999b4c9c648bd7a3fb2bb26feeed" - integrity sha512-jh6e984OBfvxS50tdY2nRZnoC5/mLFKOREQfw8t5yytkoUsJRNxvI/E39qu1sD0OtWI3OC0XgKSmcWwziwYuZw== +string.prototype.trimend@^1.0.6: + version "1.0.6" + resolved "https://registry.yarnpkg.com/string.prototype.trimend/-/string.prototype.trimend-1.0.6.tgz#c4a27fa026d979d79c04f17397f250a462944533" + integrity sha512-JySq+4mrPf9EsDBEDYMOb/lM7XQLulwg5R/m1r0PXEFqrV0qHvl58sdTilSXtKOflCsK2E8jxf+GKC0T07RWwQ== dependencies: call-bind "^1.0.2" - define-properties "^1.1.3" + define-properties "^1.1.4" + es-abstract "^1.20.4" + +string.prototype.trimstart@^1.0.6: + version "1.0.6" + resolved "https://registry.yarnpkg.com/string.prototype.trimstart/-/string.prototype.trimstart-1.0.6.tgz#e90ab66aa8e4007d92ef591bbf3cd422c56bdcf4" + integrity sha512-omqjMDaY92pbn5HOX7f9IccLA+U1tA9GvtU4JrodiXFfYB7jPzzHpRzpglLAjtUV6bB557zwClJezTqnAiYnQA== + dependencies: + call-bind "^1.0.2" + define-properties "^1.1.4" + es-abstract "^1.20.4" string_decoder@^1.1.1: version "1.3.0" @@ -7753,7 +8674,7 @@ string_decoder@^1.1.1: string_decoder@~0.10.x: version "0.10.31" resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-0.10.31.tgz#62e203bc41766c6c28c9fc84301dab1c5310fa94" - integrity sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ= + integrity sha512-ev2QzSzWPYmy9GuqfIVildA4OdcGLeFZQrq5ys6RtiuF+RQQiZWr8TZNyAcuVXyQRYfEO+MsoB/1BuQVhOJuoQ== string_decoder@~1.1.1: version "1.1.1" @@ -7770,14 +8691,14 @@ stringify-package@^1.0.1: strip-ansi@^3.0.0, strip-ansi@^3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-3.0.1.tgz#6a385fb8853d952d5ff05d0e8aaf94278dc63dcf" - integrity sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8= + integrity sha512-VhumSSbBqDTP8p2ZLKj40UjBCV4+v8bUSEpUb4KjRgWk9pbqGF4REFj6KEagidb2f/M6AzC0EmFyDNGaw9OCzg== dependencies: ansi-regex "^2.0.0" -"strip-ansi@^3.0.1 || ^4.0.0", strip-ansi@^4.0.0: +strip-ansi@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-4.0.0.tgz#a8479022eb1ac368a871389b635262c505ee368f" - integrity sha1-qEeQIusaw2iocTibY1JixQXuNo8= + integrity sha512-4XaJ2zQdCzROZDivEVIDPkcQn8LMFSa8kj8Gxb/Lnwzv9A8VctNZ+lfivC/sV3ivW8ElJTERXZoPBRrZKkNKow== dependencies: ansi-regex "^3.0.0" @@ -7796,16 +8717,16 @@ strip-ansi@^6.0.0, strip-ansi@^6.0.1: ansi-regex "^5.0.1" strip-ansi@^7.0.1: - version "7.0.1" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.0.1.tgz#61740a08ce36b61e50e65653f07060d000975fb2" - integrity sha512-cXNxvT8dFNRVfhVME3JAe98mkXDYN2O1l7jmcwMnOslDeESg1rF/OZMtK0nRAhiari1unG5cD4jG3rapUAkLbw== + version "7.1.0" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45" + integrity sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ== dependencies: ansi-regex "^6.0.1" strip-bom@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3" - integrity sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM= + integrity sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA== strip-bom@^4.0.0: version "4.0.0" @@ -7827,13 +8748,23 @@ strip-indent@^3.0.0: strip-json-comments@2.0.1, strip-json-comments@~2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" - integrity sha1-PFMZQukIwml8DsNEhYwobHygpgo= + integrity sha512-4gB8na07fecVVkOI6Rs4e7T6NOTki5EmL7TUduTs6bu3EdnSycntVJ4re8kgZA+wx9IueI2Y11bfbgwtzuE0KQ== strip-json-comments@^3.1.0, strip-json-comments@^3.1.1, strip-json-comments@~3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006" integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig== +strnum@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/strnum/-/strnum-1.0.5.tgz#5c4e829fe15ad4ff0d20c3db5ac97b73c9b072db" + integrity sha512-J8bbNyKKXl5qYcR36TIO8W3mVGVHrmmxsd5PAItGkmyzwJvybiw2IVq5nqd0i4LSNSkB/sx9VHllbfFdr9k1JA== + +stubs@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/stubs/-/stubs-3.0.0.tgz#e8d2ba1fa9c90570303c030b6900f7d5f89abe5b" + integrity sha512-PdHt7hHUJKxvTCgbKX9C1V/ftOcjJQgz8BZwNfV5c4B6dcGqlpelTbJ999jBGZ2jYiPAwcX5dP6oBwVlBlUbxw== + supports-color@6.0.0: version "6.0.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-6.0.0.tgz#76cfe742cf1f41bb9b1c29ad03068c05b4c0e40a" @@ -7844,7 +8775,7 @@ supports-color@6.0.0: supports-color@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7" - integrity sha1-U10EXOa2Nj+kARcIRimZXp3zJMc= + integrity sha512-KKNVtd6pCYgPIKU4cp2733HWYCpplQhddZLBUryaAHou723x+FRzQ5Df824Fj+IyyuiQTRoub4SnIFfIcrp70g== supports-color@^5.3.0: version "5.5.0" @@ -7860,19 +8791,24 @@ supports-color@^7.0.0, supports-color@^7.1.0, supports-color@^7.2.0: dependencies: has-flag "^4.0.0" -supports-color@^9.2.1: - version "9.2.1" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-9.2.1.tgz#599dc9d45acf74c6176e0d880bab1d7d718fe891" - integrity sha512-Obv7ycoCTG51N7y175StI9BlAXrmgZrFhZOb0/PyjHBher/NmsdBgbbQ1Inhq+gIhz6+7Gb+jWF2Vqi7Mf1xnQ== +supports-color@^9.2.2: + version "9.3.1" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-9.3.1.tgz#34e4ad3c71c9a39dae3254ecc46c9b74e89e15a6" + integrity sha512-knBY82pjmnIzK3NifMo3RxEIRD9E0kIzV4BKcyTZ9+9kWgLMxd4PrsTSMoFQUabgRBbF8KOLRDCyKgNV+iK44Q== supports-hyperlinks@^2.1.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/supports-hyperlinks/-/supports-hyperlinks-2.2.0.tgz#4f77b42488765891774b70c79babd87f9bd594bb" - integrity sha512-6sXEzV5+I5j8Bmq9/vUphGRM/RJNT9SCURJLjwfOg51heRtguGWDzcaBlgAzKhQa0EVNpPEKzQuBwZ8S8WaCeQ== + version "2.3.0" + resolved "https://registry.yarnpkg.com/supports-hyperlinks/-/supports-hyperlinks-2.3.0.tgz#3943544347c1ff90b15effb03fc14ae45ec10624" + integrity sha512-RpsAZlpWcDwOPQA22aCH4J0t7L8JmAvsCxfOSEwm7cQs3LshN36QaTkwd70DnBOXDWGssw2eUoc8CaRWT0XunA== dependencies: has-flag "^4.0.0" supports-color "^7.0.0" +supports-preserve-symlinks-flag@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09" + integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w== + "symbol-tree@>= 3.1.0 < 4.0.0": version "3.2.4" resolved "https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.2.4.tgz#430637d248ba77e078883951fb9aa0eed7c63fa2" @@ -7881,12 +8817,12 @@ supports-hyperlinks@^2.1.0: taffydb@2.7.2: version "2.7.2" resolved "https://registry.yarnpkg.com/taffydb/-/taffydb-2.7.2.tgz#7bf8106a5c1a48251b3e3bc0a0e1732489fd0dc8" - integrity sha1-e/gQalwaSCUbPjvAoOFzJIn9Dcg= + integrity sha512-R6es6/C/m1xXZckrSam4j07YKbd74437mRJ/R944S1hLG7mIl2/EQW7tQPI4XiX7jTduFzz31g7466a2BcsglQ== taffydb@2.7.3: version "2.7.3" resolved "https://registry.yarnpkg.com/taffydb/-/taffydb-2.7.3.tgz#2ad37169629498fca5bc84243096d3cde0ec3a34" - integrity sha1-KtNxaWKUmPylvIQkMJbTzeDsOjQ= + integrity sha512-GQ3gtYFSOAxSMN/apGtDKKkbJf+8izz5YfbGqIsUc7AMiQOapARZ76dhilRY2h39cynYxBFdafQo5HUL5vgkrg== tar-fs@^1.8.1: version "1.16.3" @@ -7911,14 +8847,14 @@ tar-stream@^1.1.2: to-buffer "^1.1.1" xtend "^4.0.0" -tar@^6.0.2, tar@^6.1.0, tar@^6.1.11: - version "6.1.11" - resolved "https://registry.yarnpkg.com/tar/-/tar-6.1.11.tgz#6760a38f003afa1b2ffd0ffe9e9abbd0eab3d621" - integrity sha512-an/KZQzQUkZCkuoAA64hM92X0Urb6VpRhAFllDzz44U2mcD5scmT3zBc4VgVpkugF580+DQn8eAFSyoQt0tznA== +tar@^6.0.2, tar@^6.1.0, tar@^6.1.11, tar@^6.1.2: + version "6.1.15" + resolved "https://registry.yarnpkg.com/tar/-/tar-6.1.15.tgz#c9738b0b98845a3b344d334b8fa3041aaba53a69" + integrity sha512-/zKt9UyngnxIT/EAGYuxaMYgOIJiP81ab9ZfkILq4oNLPFX50qyYmu7jRj9qeXoxmJHjGlbH0+cm2uy1WCs10A== dependencies: chownr "^2.0.0" fs-minipass "^2.0.0" - minipass "^3.0.0" + minipass "^5.0.0" minizlib "^2.1.1" mkdirp "^1.0.3" yallist "^4.0.0" @@ -7926,7 +8862,7 @@ tar@^6.0.2, tar@^6.1.0, tar@^6.1.11: targz@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/targz/-/targz-1.0.1.tgz#8f76a523694cdedfbb5d60a4076ff6eeecc5398f" - integrity sha1-j3alI2lM3t+7XWCkB2/27uzFOY8= + integrity sha512-6q4tP9U55mZnRuMTBqnqc3nwYQY3kv+QthCFZuMk+Tn1qYUnMPmL/JZ/mzgXINzFpSqfU+242IFmFU9VPvqaQw== dependencies: tar-fs "^1.8.1" @@ -7946,6 +8882,17 @@ tedious@8.3.0: readable-stream "^3.6.0" sprintf-js "^1.1.2" +teeny-request@^8.0.0: + version "8.0.3" + resolved "https://registry.yarnpkg.com/teeny-request/-/teeny-request-8.0.3.tgz#5cb9c471ef5e59f2fca8280dc3c5909595e6ca24" + integrity sha512-jJZpA5He2y52yUhA7pyAGZlgQpcB+xLjcN0eUFxr9c8hP/H7uOXbBNVo/O0C/xVfJLJs680jvkFgVJEEvk9+ww== + dependencies: + http-proxy-agent "^5.0.0" + https-proxy-agent "^5.0.0" + node-fetch "^2.6.1" + stream-events "^1.0.5" + uuid "^9.0.0" + temp-dir@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/temp-dir/-/temp-dir-2.0.0.tgz#bde92b05bdfeb1516e804c9c00ad45177f31321e" @@ -7962,11 +8909,6 @@ tempy@^1.0.0: type-fest "^0.16.0" unique-string "^2.0.0" -test-console@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/test-console/-/test-console-2.0.0.tgz#a279f7e2e148815224d8446ffa5208f0077d68fb" - integrity sha512-ciILzfCQCny8zy1+HEw2yBLKus7LNMsAHymsp2fhvGTVh5pWE5v2EB7V+5ag3WM9aO2ULtgsXVQePWYE+fb7pA== - test-exclude@^6.0.0: version "6.0.0" resolved "https://registry.yarnpkg.com/test-exclude/-/test-exclude-6.0.0.tgz#04a8698661d805ea6fa293b6cb9e63ac044ef15e" @@ -7989,7 +8931,21 @@ text-hex@1.0.x: text-table@^0.2.0, text-table@~0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" - integrity sha1-f17oI66AUgfACvLfSoTsP8+lcLQ= + integrity sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw== + +thenify-all@^1.0.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/thenify-all/-/thenify-all-1.6.0.tgz#1a1918d402d8fc3f98fbf234db0bcc8cc10e9726" + integrity sha512-RNxQH/qI8/t3thXJDwcstUO4zeqo64+Uy/+sNVRBx4Xn2OX+OZ9oP+iJnNFqplFra2ZUVeKCSa2oVWi3T4uVmA== + dependencies: + thenify ">= 3.1.0 < 4" + +"thenify@>= 3.1.0 < 4": + version "3.3.1" + resolved "https://registry.yarnpkg.com/thenify/-/thenify-3.3.1.tgz#8932e686a4066038a016dd9e2ca46add9838a95f" + integrity sha512-RVZSIV5IG10Hk3enotrhvz0T9em6cyHBLkH/YAZuKqd8hRkKhSfCGIcP2KUY0EPxndzANBmNllzWPwak+bheSw== + dependencies: + any-promise "^1.0.0" through2-filter@^3.0.0: version "3.0.0" @@ -8014,10 +8970,10 @@ through2@^4.0.0: dependencies: readable-stream "3" -through@2, "through@>=2.2.7 <3", through@^2.3.8: +through@2, "through@>=2.2.7 <3", through@^2.3.8, through@~2.3: version "2.3.8" resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" - integrity sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU= + integrity sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg== tiny-relative-date@^1.3.0: version "1.3.0" @@ -8034,7 +8990,7 @@ tmp@^0.2.1: to-absolute-glob@^2.0.0: version "2.0.2" resolved "https://registry.yarnpkg.com/to-absolute-glob/-/to-absolute-glob-2.0.2.tgz#1865f43d9e74b0822db9f145b78cff7d0f7c849b" - integrity sha1-GGX0PZ50sIItufFFt4z/fQ98hJs= + integrity sha512-rtwLUQEwT8ZeKQbyFJyomBRYXyE16U5VKuy0ftxLMK/PZb2fkOsg5r9kHdauuVDbsNdIBoC/HCthpidamQFXYA== dependencies: is-absolute "^1.0.0" is-negated-glob "^1.0.0" @@ -8047,12 +9003,12 @@ to-buffer@^1.1.1: to-fast-properties@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-1.0.3.tgz#b83571fa4d8c25b82e231b06e3a3055de4ca1a47" - integrity sha1-uDVx+k2MJbguIxsG46MFXeTKGkc= + integrity sha512-lxrWP8ejsq+7E3nNjwYmUBMAgjMTZoTI+sdBOpvNyijeDLa29LUn9QaoXAHv4+Z578hbmHHJKZknzxVtvo77og== to-fast-properties@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-2.0.0.tgz#dc5e698cbd079265bc73e0377681a4e4e83f616e" - integrity sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4= + integrity sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog== to-regex-range@^5.0.1: version "5.0.1" @@ -8064,14 +9020,19 @@ to-regex-range@^5.0.1: to-through@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/to-through/-/to-through-2.0.0.tgz#fc92adaba072647bc0b67d6b03664aa195093af6" - integrity sha1-/JKtq6ByZHvAtn1rA2ZKoZUJOvY= + integrity sha512-+QIz37Ly7acM4EMdw2PRN389OneM5+d844tirkGp4dPKzI5OE72V9OsbFp+CIYJDahZ41ZV05hNtcPAQUAm9/Q== dependencies: through2 "^2.0.3" +toidentifier@1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.1.tgz#3be34321a88a820ed1bd80dfaa33e479fbb8dd35" + integrity sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA== + toposort-class@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/toposort-class/-/toposort-class-1.0.1.tgz#7ffd1f78c8be28c3ba45cd4e1a3f5ee193bd9988" - integrity sha1-f/0feMi+KMO6Rc1OGj9e4ZO9mYg= + integrity sha512-OsLcGGbYF3rMjPUf8oKktyvCiUxSbqMMS39m33MAjLTC1DVIH6x3WSt63/M77ihI09+Sdfk1AXvfhCEeUmC7mg== tough-cookie@^2.2.0, tough-cookie@^2.4.3, tough-cookie@~2.5.0: version "2.5.0" @@ -8081,29 +9042,20 @@ tough-cookie@^2.2.0, tough-cookie@^2.4.3, tough-cookie@~2.5.0: psl "^1.1.28" punycode "^2.1.1" -tough-cookie@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-4.0.0.tgz#d822234eeca882f991f0f908824ad2622ddbece4" - integrity sha512-tHdtEpQCMrc1YLrMaqXXcj6AxhYi/xgit6mZu1+EDWUn+qhUf8wMQoFIy9NXuq23zAwtcB0t/MjACGR18pcRbg== - dependencies: - psl "^1.1.33" - punycode "^2.1.1" - universalify "^0.1.2" - tr46@~0.0.1, tr46@~0.0.3: version "0.0.3" resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a" - integrity sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o= + integrity sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw== "traverse@>=0.3.0 <0.4": version "0.3.9" resolved "https://registry.yarnpkg.com/traverse/-/traverse-0.3.9.tgz#717b8f220cc0bb7b44e40514c22b2e8bbc70d8b9" - integrity sha1-cXuPIgzAu3tE5AUUwisui7xw2Lk= + integrity sha512-iawgk0hLP3SxGKDfnDJf8wTz4p2qImnyihM5Hh/sGvQ3K37dPi/w8sRhdNIxYA1TwFwc5mDhIJq+O0RsvXBKdQ== traverse@~0.6.6: - version "0.6.6" - resolved "https://registry.yarnpkg.com/traverse/-/traverse-0.6.6.tgz#cbdf560fd7b9af632502fed40f918c157ea97137" - integrity sha1-y99WD9e5r2MlAv7UD5GMFX6pcTc= + version "0.6.7" + resolved "https://registry.yarnpkg.com/traverse/-/traverse-0.6.7.tgz#46961cd2d57dd8706c36664acde06a248f1173fe" + integrity sha512-/y956gpUo9ZNCb99YjxG7OaslxZWHfCHAUUfshwqOXmxUIvqLjVO581BT+gM59+QV9tFe6/CGG53tsA1Y7RSdg== treeverse@^1.0.4: version "1.0.4" @@ -8118,9 +9070,9 @@ trim-newlines@^3.0.0: trim-right@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003" - integrity sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM= + integrity sha512-WZGXGstmCWgeevgTL54hrCuw1dyMQIzWy7ZfqRJfSmJZBwklI15egmQytFP6bPidmw3M8d5yEowl1niq4vmqZw== -triple-beam@^1.2.0, triple-beam@^1.3.0: +triple-beam@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/triple-beam/-/triple-beam-1.3.0.tgz#a595214c7298db8339eeeee083e4d10bd8cb8dd9" integrity sha512-XrHUvV5HpdLmIj4uVMxHggLbFSZYIn7HEWsqePZcI50pco+MPqJ50wMGY794X7AOOhxOBAjbkqfAbEe/QMp2Lw== @@ -8142,15 +9094,10 @@ tslib@^1.8.1, tslib@^1.9.2: resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00" integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg== -tslib@^2, tslib@^2.0.0, tslib@^2.2.0: - version "2.3.1" - resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.3.1.tgz#e8a335add5ceae51aa261d32a490158ef042ef01" - integrity sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw== - -tslib@~2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.1.0.tgz#da60860f1c2ecaa5703ab7d39bc05b6bf988b97a" - integrity sha512-hcVC3wYEziELGGmEEXue7D75zbwIIVUMWAVbHItGPx0ziyXxrOMQx4rQEVEV45Ut/1IotuEvwqPopzIOkDMf0A== +tslib@^2, tslib@^2.0.1, tslib@^2.1.0, tslib@^2.2.0: + version "2.5.3" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.5.3.tgz#24944ba2d990940e6e982c4bea147aba80209913" + integrity sha512-mSxlJJwl3BMEQCUNnxXBU9jP4JBktcEGhURcPR6VQVlnP0FdDEsIaz0C35dXNGLyRfrATNofF0F5p2KPxQgB+w== tsutils@^3.21.0: version "3.21.0" @@ -8162,7 +9109,7 @@ tsutils@^3.21.0: tunnel-agent@^0.6.0: version "0.6.0" resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.6.0.tgz#27a5dea06b36b04a0a9966774b290868f0fc40fd" - integrity sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0= + integrity sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w== dependencies: safe-buffer "^5.0.1" @@ -8174,7 +9121,7 @@ tunnel@0.0.6, tunnel@^0.0.6: tweetnacl@^0.14.3, tweetnacl@~0.14.0: version "0.14.5" resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.5.tgz#5ae68177f192d4456269d108afa93ff8743f4f64" - integrity sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q= + integrity sha512-KXXFFdAbFXY4geFIwoyNK+f5Z1b7swfXABfL7HXCmoIWMKU3dmS26672A4EeQtDzLKy7SXmfBu51JolvEKwtGA== type-check@^0.4.0, type-check@~0.4.0: version "0.4.0" @@ -8186,7 +9133,7 @@ type-check@^0.4.0, type-check@~0.4.0: type-check@~0.3.2: version "0.3.2" resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.3.2.tgz#5884cab512cf1d355e3fb784f30804b2b520db72" - integrity sha1-WITKtRLPHTVeP7eE8wgEsrUg23I= + integrity sha512-ZCmOJdvOWDBYJlzAoFkC+Q0+bUyEOS1ltgp1MGU03fqHG+dbi9tBFU2Rd9QKiDZFAYrhPh2JUf7rZRIuHRKtOg== dependencies: prelude-ls "~1.1.2" @@ -8225,6 +9172,15 @@ type-fest@^0.8.0, type-fest@^0.8.1: resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.8.1.tgz#09e249ebde851d3b1e48d27c105444667f17b83d" integrity sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA== +typed-array-length@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/typed-array-length/-/typed-array-length-1.0.4.tgz#89d83785e5c4098bec72e08b319651f0eac9c1bb" + integrity sha512-KjZypGq+I/H7HI5HlOoGHkWUUGq+Q0TPhQurLbyrVrvnKTBgzLhIJ7j6J/XTQOi0d1RjyZ0wdas8bKs2p0x3Ng== + dependencies: + call-bind "^1.0.2" + for-each "^0.3.3" + is-typed-array "^1.1.9" + typedarray-to-buffer@^3.1.5: version "3.1.5" resolved "https://registry.yarnpkg.com/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz#a97ee7a9ff42691b9f783ff1bc5112fe3fca9080" @@ -8232,15 +9188,10 @@ typedarray-to-buffer@^3.1.5: dependencies: is-typedarray "^1.0.0" -typescript@^4.4.3: - version "4.5.2" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.5.2.tgz#8ac1fba9f52256fdb06fb89e4122fa6a346c2998" - integrity sha512-5BlMof9H1yGt0P8/WF+wPNw6GfctgGjXp5hkblpyT+8rkASSmkUKMXrxR0Xg8ThVCi/JnHQiKXeBaEwCeQwMFw== - -typescript@^4.5.4: - version "4.5.4" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.5.4.tgz#a17d3a0263bf5c8723b9c52f43c5084edf13c2e8" - integrity sha512-VgYs2A2QIRuGphtzFV7aQJduJ2gyfTljngLzjpfW9FoYZF6xuw1W0vW9ghCKLfcWrCFxK81CSGRAvS1pn4fIUg== +typescript@^4.4.3, typescript@^4.5.4: + version "4.9.5" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.5.tgz#095979f9bcc0d09da324d58d03ce8f8374cbe65a" + integrity sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g== uc.micro@^1.0.1, uc.micro@^1.0.5: version "1.0.6" @@ -8248,29 +9199,36 @@ uc.micro@^1.0.1, uc.micro@^1.0.5: integrity sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA== uglify-js@^3.1.4: - version "3.14.3" - resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.14.3.tgz#c0f25dfea1e8e5323eccf59610be08b6043c15cf" - integrity sha512-mic3aOdiq01DuSVx0TseaEzMIVqebMZ0Z3vaeDhFEh9bsc24hV1TFvN74reA2vs08D0ZWfNjAcJ3UbVLaBss+g== + version "3.17.4" + resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.17.4.tgz#61678cf5fa3f5b7eb789bb345df29afb8257c22c" + integrity sha512-T9q82TJI9e/C1TAxYvfb16xO120tMVFZrGA3f9/P4424DNu6ypK103y0GPFVa17yotwSyZW5iYXgjYHkGrJW/g== -unbox-primitive@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/unbox-primitive/-/unbox-primitive-1.0.1.tgz#085e215625ec3162574dc8859abee78a59b14471" - integrity sha512-tZU/3NqK3dA5gpE1KtyiJUrEB0lxnGkMFHptJ7q6ewdZ8s12QrODwNbhIJStmJkd1QDXa1NRA8aF2A1zk/Ypyw== +unbox-primitive@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/unbox-primitive/-/unbox-primitive-1.0.2.tgz#29032021057d5e6cdbd08c5129c226dff8ed6f9e" + integrity sha512-61pPlCD9h51VoreyJ0BReideM3MDKMKnh6+V9L08331ipq6Q8OFXZYiqP6n/tbHx4s5I9uRhcye6BrbkizkBDw== dependencies: - function-bind "^1.1.1" - has-bigints "^1.0.1" - has-symbols "^1.0.2" + call-bind "^1.0.2" + has-bigints "^1.0.2" + has-symbols "^1.0.3" which-boxed-primitive "^1.0.2" unc-path-regex@^0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/unc-path-regex/-/unc-path-regex-0.1.2.tgz#e73dd3d7b0d7c5ed86fbac6b0ae7d8c6a69d50fa" - integrity sha1-5z3T17DXxe2G+6xrCufYxqadUPo= + integrity sha512-eXL4nmJT7oCpkZsHZUOJo8hcX3GbsiDOa0Qu9F646fi8dT3XuSVopVqAcEiVzSKKH7UoDti23wNX3qGFxcW5Qg== "underscore@>= 1.3.1", underscore@^1.13.1: - version "1.13.1" - resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.13.1.tgz#0c1c6bd2df54b6b69f2314066d65b6cde6fcf9d1" - integrity sha512-hzSoAVtJF+3ZtiFX0VgfFPHEDRm7Y/QPjGyNo4TVdnDTdft3tr8hEkD25a1jC+TjTuE7tkHGKkhwCgs9dgBB2g== + version "1.13.6" + resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.13.6.tgz#04786a1f589dc6c09f761fc5f45b89e935136441" + integrity sha512-+A5Sja4HP1M08MaXya7p5LvjuM7K6q/2EaC0+iovj/wOcMsTzMvDFbasi/oSapiwOlt252IqsKqPjCl7huKS0A== + +unescape@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/unescape/-/unescape-1.0.1.tgz#956e430f61cad8a4d57d82c518f5e6cc5d0dda96" + integrity sha512-O0+af1Gs50lyH1nUu3ZyYS1cRh01Q/kUKatTOkSs7jukXE6/NebucDVxyiDsA9AQ4JC1V1jUH9EO8JX2nMDgGQ== + dependencies: + extend-shallow "^2.0.1" unique-filename@^1.1.1: version "1.1.1" @@ -8306,7 +9264,7 @@ universal-user-agent@^6.0.0: resolved "https://registry.yarnpkg.com/universal-user-agent/-/universal-user-agent-6.0.0.tgz#3381f8503b251c0d9cd21bc1de939ec9df5480ee" integrity sha512-isyNax3wXoKaulPDZWHQqbmIx1k2tb9fb3GGDBRxCscfYV2Ch7WxPArBsFEG8s/safwXTT7H4QGhaIkTp9447w== -universalify@^0.1.0, universalify@^0.1.2: +universalify@^0.1.0: version "0.1.2" resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66" integrity sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg== @@ -8316,15 +9274,20 @@ universalify@^2.0.0: resolved "https://registry.yarnpkg.com/universalify/-/universalify-2.0.0.tgz#75a4984efedc4b08975c5aeb73f530d02df25717" integrity sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ== +unpipe@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec" + integrity sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ== + untildify@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/untildify/-/untildify-4.0.0.tgz#2bc947b953652487e4600949fb091e3ae8cd919b" integrity sha512-KK8xQ1mkzZeg9inewmFVDNkg3l5LUhoq9kN6iWYB/CC9YMG8HA+c1Q8HwDe6dEX7kErrEVNVBO3fWsVq5iDgtw== unzipper@^0.10.11: - version "0.10.11" - resolved "https://registry.yarnpkg.com/unzipper/-/unzipper-0.10.11.tgz#0b4991446472cbdb92ee7403909f26c2419c782e" - integrity sha512-+BrAq2oFqWod5IESRjL3S8baohbevGcVA+teAIOYWM3pDVdseogqbzhhvvmiyQrUNKFUnDMtELW3X8ykbyDCJw== + version "0.10.14" + resolved "https://registry.yarnpkg.com/unzipper/-/unzipper-0.10.14.tgz#d2b33c977714da0fbc0f82774ad35470a7c962b1" + integrity sha512-ti4wZj+0bQTiX2KmKWuwj7lhV+2n//uXEotUmGuQqrbVZSEGFMbI68+c6JCQ8aAmUWYvtHEz2A8K6wXvueR/6g== dependencies: big-integer "^1.6.17" binary "~0.3.0" @@ -8337,6 +9300,14 @@ unzipper@^0.10.11: readable-stream "~2.3.6" setimmediate "~1.0.4" +update-browserslist-db@^1.0.11: + version "1.0.11" + resolved "https://registry.yarnpkg.com/update-browserslist-db/-/update-browserslist-db-1.0.11.tgz#9a2a641ad2907ae7b3616506f4b977851db5b940" + integrity sha512-dCwEFf0/oT85M1fHBg4F0jtLwJrutGoHSQXCh7u4o2t1drG+c0a9Flnqww6XUKSfQMPpJBRjU8d4RXB09qtvaA== + dependencies: + escalade "^3.1.1" + picocolors "^1.0.0" + uri-js@^4.2.2: version "4.4.1" resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.4.1.tgz#9b1a52595225859e55f669d928f88c6c57f2a77e" @@ -8352,35 +9323,78 @@ url-join@^4.0.0: url@0.10.3: version "0.10.3" resolved "https://registry.yarnpkg.com/url/-/url-0.10.3.tgz#021e4d9c7705f21bbf37d03ceb58767402774c64" - integrity sha1-Ah5NnHcF8hu/N9A861h2dAJ3TGQ= + integrity sha512-hzSUW2q06EqL1gKM/a+obYHLIO6ct2hwPuviqTTOcfFVc61UbfJ2Q32+uGL/HCPxKqrdGB5QUwIe7UqlDgwsOQ== dependencies: punycode "1.3.2" querystring "0.2.0" +urllib@^2.38.0: + version "2.40.0" + resolved "https://registry.yarnpkg.com/urllib/-/urllib-2.40.0.tgz#c63d4425081908560d7e1c4dc651f7d723a3cf76" + integrity sha512-XDZjoijtzsbkXTXgM+A/sJM002nwoYsc46YOYr6MNH2jUUw1nCBf2ywT1WaPsVEWJX4Yr+9isGmYj4+yofFn9g== + dependencies: + any-promise "^1.3.0" + content-type "^1.0.2" + debug "^2.6.9" + default-user-agent "^1.0.0" + digest-header "^1.0.0" + ee-first "~1.1.1" + formstream "^1.1.0" + humanize-ms "^1.2.0" + iconv-lite "^0.4.15" + ip "^1.1.5" + proxy-agent "^5.0.0" + pump "^3.0.0" + qs "^6.4.0" + statuses "^1.3.1" + utility "^1.16.1" + util-deprecate@^1.0.1, util-deprecate@~1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" - integrity sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8= + integrity sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw== -uuid@3.3.2: - version "3.3.2" - resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.3.2.tgz#1b4af4955eb3077c501c23872fc6513811587131" - integrity sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA== +util@^0.12.4: + version "0.12.5" + resolved "https://registry.yarnpkg.com/util/-/util-0.12.5.tgz#5f17a6059b73db61a875668781a1c2b136bd6fbc" + integrity sha512-kZf/K6hEIrWHI6XqOFUiiMa+79wE/D8Q+NCNAWclkyg3b4d2k7s0QGepNjiABc+aR3N1PAyHL7p6UcLY6LmrnA== + dependencies: + inherits "^2.0.3" + is-arguments "^1.0.4" + is-generator-function "^1.0.7" + is-typed-array "^1.1.3" + which-typed-array "^1.1.2" + +utility@^1.16.1: + version "1.18.0" + resolved "https://registry.yarnpkg.com/utility/-/utility-1.18.0.tgz#af55f62e6d5a272e0cb02b0ab3e7f37c46435f36" + integrity sha512-PYxZDA+6QtvRvm//++aGdmKG/cI07jNwbROz0Ql+VzFV1+Z0Dy55NI4zZ7RHc9KKpBePNFwoErqIuqQv/cjiTA== + dependencies: + copy-to "^2.0.1" + escape-html "^1.0.3" + mkdirp "^0.5.1" + mz "^2.7.0" + unescape "^1.0.1" + +uuid@8.0.0: + version "8.0.0" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.0.0.tgz#bc6ccf91b5ff0ac07bbcdbf1c7c4e150db4dbb6c" + integrity sha512-jOXGuXZAWdsTH7eZLtyXMqUb9EcWMGZNbL9YcGBJl4MH4nrxHmZJhEHvyLFrkxo+28uLb/NYRcStH48fnD0Vzw== -uuid@^3.1.0, uuid@^3.2.1, uuid@^3.3.2, uuid@^3.3.3: +uuid@^3.1.0, uuid@^3.2.1, uuid@^3.3.2: version "3.4.0" resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee" integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A== -uuid@^8.3.0, uuid@^8.3.2: +uuid@^8.0.0, uuid@^8.3.0, uuid@^8.3.2: version "8.3.2" resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2" integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg== -v8-compile-cache@^2.0.3: - version "2.3.0" - resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz#2de19618c66dc247dcfb6f99338035d8245a2cee" - integrity sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA== +uuid@^9.0.0: + version "9.0.0" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-9.0.0.tgz#592f550650024a38ceb0c562f2f6aa435761efb5" + integrity sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg== validate-npm-package-license@^3.0.1, validate-npm-package-license@^3.0.4: version "3.0.4" @@ -8393,24 +9407,24 @@ validate-npm-package-license@^3.0.1, validate-npm-package-license@^3.0.4: validate-npm-package-name@^3.0.0, validate-npm-package-name@~3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/validate-npm-package-name/-/validate-npm-package-name-3.0.0.tgz#5fa912d81eb7d0c74afc140de7317f0ca7df437e" - integrity sha1-X6kS2B630MdK/BQN5zF/DKffQ34= + integrity sha512-M6w37eVCMMouJ9V/sdPGnC5H4uDr73/+xdq0FBLO3TFFX1+7wiUY6Es328NN+y43tmY+doUdN9g9J21vqB7iLw== dependencies: builtins "^1.0.3" -validator@^13.7.0: - version "13.7.0" - resolved "https://registry.yarnpkg.com/validator/-/validator-13.7.0.tgz#4f9658ba13ba8f3d82ee881d3516489ea85c0857" - integrity sha512-nYXQLCBkpJ8X6ltALua9dRrZDHVYxjJ1wgskNt1lH9fzGjs3tgojGSCBjmEPwkWS1y29+DrizMTW19Pr9uB2nw== +validator@^13.9.0: + version "13.9.0" + resolved "https://registry.yarnpkg.com/validator/-/validator-13.9.0.tgz#33e7b85b604f3bbce9bb1a05d5c3e22e1c2ff855" + integrity sha512-B+dGG8U3fdtM0/aNK4/X8CXq/EcxU2WPrPEkJGslb47qyHsxmbggTWK0yEA4qnYVNF+nxNlN88o14hIcPmSIEA== value-or-function@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/value-or-function/-/value-or-function-3.0.0.tgz#1c243a50b595c1be54a754bfece8563b9ff8d813" - integrity sha1-HCQ6ULWVwb5Up1S/7OhWO5/42BM= + integrity sha512-jdBB2FrWvQC/pnPtIqcLsMaQgjhdb6B7tk1MMyTKapox+tQZbdRP4uLxu/JY0t7fbfDCUMnuelzEYv5GsxHhdg== verror@1.10.0: version "1.10.0" resolved "https://registry.yarnpkg.com/verror/-/verror-1.10.0.tgz#3a105ca17053af55d6e270c1f8288682e18da400" - integrity sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA= + integrity sha512-ZZKSmDAEFOijERBLkmYfJ+vmk3w+7hOLYDNkRCuRuMJGEmqYNCNLyBBFwWKVMhfwaEF3WOd0Zlw86U/WC/+nYw== dependencies: assert-plus "^1.0.0" core-util-is "1.0.2" @@ -8442,7 +9456,7 @@ vinyl-fs@^3.0.2: vinyl-sourcemap@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/vinyl-sourcemap/-/vinyl-sourcemap-1.1.0.tgz#92a800593a38703a8cdb11d8b300ad4be63b3e16" - integrity sha1-kqgAWTo4cDqM2xHYswCtS+Y7PhY= + integrity sha512-NiibMgt6VJGJmyw7vtzhctDcfKch4e4n9TBeoWlirb7FMg9/1Ov9k+A5ZRAtywBpRPiyECvQRQllYM8dECegVA== dependencies: append-buffer "^1.0.2" convert-source-map "^1.5.0" @@ -8464,6 +9478,14 @@ vinyl@^2.0.0, vinyl@^2.1.0: remove-trailing-separator "^1.0.1" replace-ext "^1.0.0" +vm2@^3.9.17: + version "3.9.19" + resolved "https://registry.yarnpkg.com/vm2/-/vm2-3.9.19.tgz#be1e1d7a106122c6c492b4d51c2e8b93d3ed6a4a" + integrity sha512-J637XF0DHDMV57R6JyVsTak7nIL8gy5KH4r1HiwWLf/4GBbb5MKL5y7LpmF4A8E2nR6XmzpmMFQ7V7ppPTmUQg== + dependencies: + acorn "^8.7.0" + acorn-walk "^8.2.0" + walk-up-path@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/walk-up-path/-/walk-up-path-1.0.0.tgz#d4745e893dd5fd0dbb58dd0a4c6a33d9c9fec53e" @@ -8472,31 +9494,31 @@ walk-up-path@^1.0.0: wcwidth@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/wcwidth/-/wcwidth-1.0.1.tgz#f0b0dcf915bc5ff1528afadb2c0e17b532da2fe8" - integrity sha1-8LDc+RW8X/FSivrbLA4XtTLaL+g= + integrity sha512-XHPEwS0q6TaxcvG85+8EYkbiCux2XtWG2mkc47Ng2A77BQu9+DqIOJldST4HgPkuea7dvKSj5VgX3P1d4rW8Tg== dependencies: defaults "^1.0.3" webidl-conversions@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-2.0.1.tgz#3bf8258f7d318c7443c36f2e169402a1a6703506" - integrity sha1-O/glj30xjHRDw28uFpQCoaZwNQY= + integrity sha512-OZ7I/f0sM+T28T2/OXinNGfmvjm3KKptdyQy8NPRZyLfYBn+9vt72Bfr+uQaE9OvWyxJjQ5kHFygH2wOTUb76g== webidl-conversions@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871" - integrity sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE= + integrity sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ== whatwg-url-compat@~0.6.5: version "0.6.5" resolved "https://registry.yarnpkg.com/whatwg-url-compat/-/whatwg-url-compat-0.6.5.tgz#00898111af689bb097541cd5a45ca6c8798445bf" - integrity sha1-AImBEa9om7CXVBzVpFymyHmERb8= + integrity sha512-vbg5+JVNwGtHRI3GheZGWrcUlxF9BXHbA80dLa+2XqJjlV/BK6upoi2j8dIRW9FGPUUyaMm7Hf1pTexHnsk85g== dependencies: tr46 "~0.0.1" whatwg-url@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d" - integrity sha1-lmRU6HZUYuN2RNNib2dCzotwll0= + integrity sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw== dependencies: tr46 "~0.0.3" webidl-conversions "^3.0.0" @@ -8513,9 +9535,21 @@ which-boxed-primitive@^1.0.2: is-symbol "^1.0.3" which-module@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a" - integrity sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho= + version "2.0.1" + resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.1.tgz#776b1fe35d90aebe99e8ac15eb24093389a4a409" + integrity sha512-iBdZ57RDvnOR9AGBhML2vFZf7h8vmBjhoaZqODJBFWHVtKkDmKuHai3cx5PgVMrX5YDNp27AofYbAwctSS+vhQ== + +which-typed-array@^1.1.2, which-typed-array@^1.1.9: + version "1.1.9" + resolved "https://registry.yarnpkg.com/which-typed-array/-/which-typed-array-1.1.9.tgz#307cf898025848cf995e795e8423c7f337efbde6" + integrity sha512-w9c4xkx6mPidwp7180ckYWfMmvxpjlZuIudNtDf4N/tTAUB8VJbX25qZoAsrtGuYNnGw3pa0AXgbGKRB8/EceA== + dependencies: + available-typed-arrays "^1.0.5" + call-bind "^1.0.2" + for-each "^0.3.3" + gopd "^1.0.1" + has-tostringtag "^1.0.0" + is-typed-array "^1.1.10" which@1.3.1: version "1.3.1" @@ -8538,35 +9572,45 @@ wide-align@1.1.3: dependencies: string-width "^1.0.2 || 2" -wide-align@^1.1.0, wide-align@^1.1.2: +wide-align@^1.1.0, wide-align@^1.1.2, wide-align@^1.1.5: version "1.1.5" resolved "https://registry.yarnpkg.com/wide-align/-/wide-align-1.1.5.tgz#df1d4c206854369ecf3c9a4898f1b23fbd9d15d3" integrity sha512-eDMORYaPNZ4sQIuuYPDHdQvf4gyCF9rEEV/yPxGfwPkRodwEgiMUUXTx/dex+Me0wxx53S+NgUHaP7y3MGlDmg== dependencies: string-width "^1.0.2 || 2 || 3 || 4" -winston-transport@^4.4.0: - version "4.4.0" - resolved "https://registry.yarnpkg.com/winston-transport/-/winston-transport-4.4.0.tgz#17af518daa690d5b2ecccaa7acf7b20ca7925e59" - integrity sha512-Lc7/p3GtqtqPBYYtS6KCN3c77/2QCev51DvcJKbkFPQNoj1sinkGwLGFDxkXY9J6p9+EPnYs+D90uwbnaiURTw== +win-release@^1.0.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/win-release/-/win-release-1.1.1.tgz#5fa55e02be7ca934edfc12665632e849b72e5209" + integrity sha512-iCRnKVvGxOQdsKhcQId2PXV1vV3J/sDPXKA4Oe9+Eti2nb2ESEsYHRYls/UjoUW3bIc5ZDO8dTH50A/5iVN+bw== dependencies: - readable-stream "^2.3.7" - triple-beam "^1.2.0" + semver "^5.0.1" + +winston-transport@^4.5.0: + version "4.5.0" + resolved "https://registry.yarnpkg.com/winston-transport/-/winston-transport-4.5.0.tgz#6e7b0dd04d393171ed5e4e4905db265f7ab384fa" + integrity sha512-YpZzcUzBedhlTAfJg6vJDlyEai/IFMIVcaEZZyl3UXIl4gmqRpU7AE89AHLkbzLUsv0NVmw7ts+iztqKxxPW1Q== + dependencies: + logform "^2.3.2" + readable-stream "^3.6.0" + triple-beam "^1.3.0" winston@^3.1.0: - version "3.3.3" - resolved "https://registry.yarnpkg.com/winston/-/winston-3.3.3.tgz#ae6172042cafb29786afa3d09c8ff833ab7c9170" - integrity sha512-oEXTISQnC8VlSAKf1KYSSd7J6IWuRPQqDdo8eoRNaYKLvwSb5+79Z3Yi1lrl6KDpU6/VWaxpakDAtb1oQ4n9aw== + version "3.9.0" + resolved "https://registry.yarnpkg.com/winston/-/winston-3.9.0.tgz#2bbdeb8167a75fac6d9a0c6d002890cd908016c2" + integrity sha512-jW51iW/X95BCW6MMtZWr2jKQBP4hV5bIDq9QrIjfDk6Q9QuxvTKEAlpUNAzP+HYHFFCeENhph16s0zEunu4uuQ== dependencies: + "@colors/colors" "1.5.0" "@dabh/diagnostics" "^2.0.2" - async "^3.1.0" + async "^3.2.3" is-stream "^2.0.0" - logform "^2.2.0" + logform "^2.4.0" one-time "^1.0.0" readable-stream "^3.4.0" + safe-stable-stringify "^2.3.1" stack-trace "0.0.x" triple-beam "^1.3.0" - winston-transport "^4.4.0" + winston-transport "^4.5.0" wkx@^0.5.0: version "0.5.0" @@ -8583,7 +9627,7 @@ word-wrap@^1.2.3, word-wrap@~1.2.3: wordwrap@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb" - integrity sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus= + integrity sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q== wrap-ansi@^5.1.0: version "5.1.0" @@ -8615,7 +9659,7 @@ wrap-ansi@^7.0.0: wrappy@1: version "1.0.2" resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" - integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= + integrity sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ== write-file-atomic@^3.0.0, write-file-atomic@^3.0.3: version "3.0.3" @@ -8630,15 +9674,15 @@ write-file-atomic@^3.0.0, write-file-atomic@^3.0.3: "xml-name-validator@>= 2.0.1 < 3.0.0": version "2.0.1" resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-2.0.1.tgz#4d8b8f1eccd3419aa362061becef515e1e559635" - integrity sha1-TYuPHszTQZqjYgYb7O9RXh5VljU= + integrity sha512-jRKe/iQYMyVJpzPH+3HL97Lgu5HrCfii+qSo+TfjKHtOnvbnvdVfMYrn9Q34YV81M2e5sviJlI6Ko9y+nByzvA== -xml2js@0.4.19: - version "0.4.19" - resolved "https://registry.yarnpkg.com/xml2js/-/xml2js-0.4.19.tgz#686c20f213209e94abf0d1bcf1efaa291c7827a7" - integrity sha512-esZnJZJOiJR9wWKMyuvSE1y6Dq5LCuJanqhxslH2bxM6duahNZ+HMpCLhBQGZkbX6xRf8x1Y2eJlgt2q3qo49Q== +xml2js@0.5.0, xml2js@^0.5.0: + version "0.5.0" + resolved "https://registry.yarnpkg.com/xml2js/-/xml2js-0.5.0.tgz#d9440631fbb2ed800203fad106f2724f62c493b7" + integrity sha512-drPFnkQJik/O+uPKpqSgr22mpuFHqKdbS835iAQrUC73L2F5WkboIRd63ai/2Yg6I1jzifPFKH2NTK+cfglkIA== dependencies: sax ">=0.6.0" - xmlbuilder "~9.0.1" + xmlbuilder "~11.0.0" xml2js@^0.4.19: version "0.4.23" @@ -8653,11 +9697,6 @@ xmlbuilder@~11.0.0: resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-11.0.1.tgz#be9bae1c8a046e76b31127726347d0ad7002beb3" integrity sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA== -xmlbuilder@~9.0.1: - version "9.0.7" - resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-9.0.7.tgz#132ee63d2ec5565c557e20f4c22df9aca686b10d" - integrity sha1-Ey7mPS7FVlxVfiD0wi35rKaGsQ0= - "xmldom@>= 0.1.x": version "0.6.0" resolved "https://registry.yarnpkg.com/xmldom/-/xmldom-0.6.0.tgz#43a96ecb8beece991cef382c08397d82d4d0c46f" @@ -8668,6 +9707,11 @@ xpath.js@~1.1.0: resolved "https://registry.yarnpkg.com/xpath.js/-/xpath.js-1.1.0.tgz#3816a44ed4bb352091083d002a383dd5104a5ff1" integrity sha512-jg+qkfS4K8E7965sqaUl8mRngXiKb3WZGfONgE18pr03FUQiuSV6G+Ej4tS55B+rIQSFEIw3phdVAQ4pPqNWfQ== +xregexp@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/xregexp/-/xregexp-2.0.0.tgz#52a63e56ca0b84a7f3a5f3d61872f126ad7a5943" + integrity sha512-xl/50/Cf32VsGq/1R8jJE5ajH1yMCQkpmoS10QbFZWl2Oor4H0Me64Pu2yxvsRWK3m6soJbmGfzSR7BYmDcWAA== + xtend@^4.0.0, xtend@~4.0.0, xtend@~4.0.1: version "4.0.2" resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54" @@ -8683,10 +9727,10 @@ y18n@^5.0.5: resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55" integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA== -yallist@^2.1.2: - version "2.1.2" - resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.1.2.tgz#1c11f9218f076089a47dd512f93c6699a6a81d52" - integrity sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI= +yallist@^3.0.2: + version "3.1.1" + resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.1.1.tgz#dbb7daf9bfd8bac9ab45ebf602b8cbad0d5d08fd" + integrity sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g== yallist@^4.0.0: version "4.0.0" @@ -8719,6 +9763,11 @@ yargs-parser@^20.2.2, yargs-parser@^20.2.3: resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.9.tgz#2eb7dc3b0289718fc295f362753845c41a0c94ee" integrity sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w== +yargs-parser@^21.1.1: + version "21.1.1" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-21.1.1.tgz#9096bceebf990d21bb31fa9516e0ede294a77d35" + integrity sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw== + yargs-unparser@1.6.0: version "1.6.0" resolved "https://registry.yarnpkg.com/yargs-unparser/-/yargs-unparser-1.6.0.tgz#ef25c2c769ff6bd09e4b0f9d7c605fb27846ea9f" @@ -8775,17 +9824,17 @@ yargs@^16.1.0, yargs@^16.2.0: yargs-parser "^20.2.2" yargs@^17.0.0: - version "17.2.1" - resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.2.1.tgz#e2c95b9796a0e1f7f3bf4427863b42e0418191ea" - integrity sha512-XfR8du6ua4K6uLGm5S6fA+FIJom/MdJcFNVY8geLlp2v8GYbOXD4EB1tPNZsRn4vBzKGMgb5DRZMeWuFc2GO8Q== + version "17.7.2" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.7.2.tgz#991df39aca675a192b816e1e0363f9d75d2aa269" + integrity sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w== dependencies: - cliui "^7.0.2" + cliui "^8.0.1" escalade "^3.1.1" get-caller-file "^2.0.5" require-directory "^2.1.1" - string-width "^4.2.0" + string-width "^4.2.3" y18n "^5.0.5" - yargs-parser "^20.2.2" + yargs-parser "^21.1.1" yn@3.1.1: version "3.1.1"