Skip to content

Commit

Permalink
Merge pull request #1462 from tediousjs/arthur/breaking-changes
Browse files Browse the repository at this point in the history
Release breaking changes on `beta` branch
  • Loading branch information
arthurschreiber authored Jul 11, 2022
2 parents 3f19bc7 + a6dc9fa commit 89ef3b2
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 67 deletions.
19 changes: 10 additions & 9 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Use Node.js 12
- name: Use Node.js 14
uses: actions/setup-node@v1
with:
node-version: 12
node-version: 14

- name: Determine npm cache directory
id: npm-cache
Expand Down Expand Up @@ -63,7 +63,7 @@ jobs:

strategy:
matrix:
node-version: [12.x, 14.x, 16.x, 18.x]
node-version: [14.x, 16.x, 18.x]
fail-fast: false

services:
Expand Down Expand Up @@ -175,18 +175,18 @@ jobs:
token: ${{ secrets.CODECOV_TOKEN }}

azure:
name: Azure SQL Server / Node.js 12.x
name: Azure SQL Server / Node.js 14.x
runs-on: ubuntu-latest

# Only run these tests if we have access to the secrets
if: ${{ github.event_name == 'push' || github.repository == github.event.pull_request.head.repo.full_name }}

steps:
- uses: actions/checkout@v1
- name: Use Node.js 12
- name: Use Node.js 14
uses: actions/setup-node@v1
with:
node-version: 12
node-version: 14

- name: Determine npm cache directory
id: npm-cache
Expand Down Expand Up @@ -238,7 +238,8 @@ jobs:
"authentication": {
"type": "azure-active-directory-password",
"options": {
"domain": "${{ secrets.AZURE_AD_TENANT_ID }}",
"clientId": "${{ secrets.AZURE_AD_SP_CLIENT_ID }}",
"tenantId": "${{ secrets.AZURE_AD_TENANT_ID }}",
"userName": "${{ secrets.AZURE_AD_USERNAME }}",
"password": "${{ secrets.AZURE_AD_PASSWORD }}"
}
Expand Down Expand Up @@ -292,10 +293,10 @@ jobs:

steps:
- uses: actions/checkout@v1
- name: Use Node.js 12
- name: Use Node.js 14
uses: actions/setup-node@v1
with:
node-version: 12
node-version: 14

- name: Determine npm cache directory
id: npm-cache
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Use Node.js 12
- name: Use Node.js 14
uses: actions/setup-node@v1
with:
node-version: 12
node-version: 14

- name: Tag latest release
run: |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
read next latest <<< $(npm info tedious --json | jq -r '."dist-tags".next, ."dist-tags".latest')
if [ "$(printf '%s\n' "$latest" "$next" | sort -V | tail -n 1)" != "$latest" ]; then
date_format="%Y-%m-%dT%H:%M:%SZ"
Expand Down
1 change: 0 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ version: "{build}"

environment:
matrix:
- nodejs_version: "12"
- nodejs_version: "14"
- nodejs_version: "16"
- nodejs_version: "18"
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"url": "https://github.com/tediousjs/tedious.git"
},
"engines": {
"node": ">=12.3.0"
"node": ">=14"
},
"publishConfig": {
"tag": "next"
Expand Down Expand Up @@ -109,7 +109,7 @@
"@babel/preset-env",
{
"targets": {
"node": 12
"node": 14
}
}
],
Expand Down
59 changes: 7 additions & 52 deletions src/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,25 +49,6 @@ import { version } from '../package.json';
import { URL } from 'url';
import { AttentionTokenHandler, InitialSqlTokenHandler, Login7TokenHandler, RequestTokenHandler, TokenHandler } from './token/handler';

let trustServerWarningEmitted = false;

const emitTrustServerCertificateWarning = () => {
if (!trustServerWarningEmitted) {
trustServerWarningEmitted = true;
process.emitWarning('`config.options.trustServerCertificate` will default to false in the future. To silence this message, specify a value explicitly in the config options');
}
};

let domainRenameToTenantIdWarningEmitted = false;
const emitDomainRenameToTenantIdWarning = () => {
if (!domainRenameToTenantIdWarningEmitted) {
domainRenameToTenantIdWarningEmitted = true;
process.emitWarning('`When using authentication type `azure-active-directory-password`,' +
' config.authentication.options.domain` will be renamed to config.authentications.options.tenantId`' +
' in the future. Rename `domain` to `tenantId` to silence this message.');
}
};

type BeginTransactionCallback =
/**
* The callback is called when the request to start the transaction has completed,
Expand Down Expand Up @@ -1112,6 +1093,10 @@ class Connection extends EventEmitter {
}
};
} else if (type === 'azure-active-directory-password') {
if (typeof options.clientId !== 'string') {
throw new TypeError('The "config.authentication.options.clientId" property must be of type string.');
}

if (options.userName !== undefined && typeof options.userName !== 'string') {
throw new TypeError('The "config.authentication.options.userName" property must be of type string.');
}
Expand All @@ -1120,18 +1105,6 @@ class Connection extends EventEmitter {
throw new TypeError('The "config.authentication.options.password" property must be of type string.');
}

if (options.clientId !== undefined && typeof options.clientId !== 'string') {
throw new TypeError('The "config.authentication.options.clientId" property must be of type string.');
} else if (options.clientId === undefined) {
emitAzureADPasswordClientIdDeprecationWarning();
}

if (options.domain !== undefined && typeof options.domain !== 'string') {
throw new TypeError('The "config.authentication.options.domain" property must be of type string.');
} else if (options.domain !== undefined) {
emitDomainRenameToTenantIdWarning();
}

if (options.tenantId !== undefined && typeof options.tenantId !== 'string') {
throw new TypeError('The "config.authentication.options.tenantId" property must be of type string.');
}
Expand All @@ -1141,8 +1114,8 @@ class Connection extends EventEmitter {
options: {
userName: options.userName,
password: options.password,
tenantId: options.tenantId ?? options.domain,
clientId: options.clientId ?? '7f98cb04-cd1e-40df-9140-3bf7e2cea4db'
tenantId: options.tenantId,
clientId: options.clientId
}
};
} else if (type === 'azure-active-directory-access-token') {
Expand Down Expand Up @@ -1290,7 +1263,7 @@ class Connection extends EventEmitter {
tdsVersion: DEFAULT_TDS_VERSION,
textsize: DEFAULT_TEXTSIZE,
trustedServerNameAE: undefined,
trustServerCertificate: true,
trustServerCertificate: false,
useColumnNames: false,
useUTC: true,
workstationId: undefined,
Expand Down Expand Up @@ -1675,8 +1648,6 @@ class Connection extends EventEmitter {
}

this.config.options.trustServerCertificate = config.options.trustServerCertificate;
} else {
emitTrustServerCertificateWarning();
}

if (config.options.useColumnNames !== undefined) {
Expand Down Expand Up @@ -3138,22 +3109,6 @@ class Connection extends EventEmitter {
}
}

let azureADPasswordClientIdDeprecationWarningEmitted = false;
function emitAzureADPasswordClientIdDeprecationWarning() {
if (azureADPasswordClientIdDeprecationWarningEmitted) {
return;
}

azureADPasswordClientIdDeprecationWarningEmitted = true;

process.emitWarning(
'When using the `azure-active-directory-password` authentication method, please provide a value for the `clientId` option. ' +
'This option will be required in a future release.',
'DeprecationWarning',
Connection.prototype.on
);
}

function isTransientError(error: AggregateError | ConnectionError): boolean {
if (error instanceof AggregateError) {
error = error.errors[0];
Expand Down

0 comments on commit 89ef3b2

Please sign in to comment.