Skip to content

Commit

Permalink
Merge pull request #241 from avadev/jwenger/typescript-support-with-l…
Browse files Browse the repository at this point in the history
…ogging

Jwenger/typescript support with logging
  • Loading branch information
svc-developer authored Nov 2, 2022
2 parents 272147e + 590902e commit 75a58f2
Show file tree
Hide file tree
Showing 410 changed files with 34,459 additions and 8,359 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- run: npm ci
- run: npm run build
- run: npm run build-tsc
- uses: actions/setup-node@v2
with:
node-version: 16
Expand Down
27 changes: 19 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,19 @@ var Avatax = require('avatax');
// es6/7 import
// import Avatax from 'avatax';

// resolve configuration and credentials
// resolve configuration, credentials and logOptions
const config = {
appName: 'your-app',
appVersion: '1.0',
environment: 'sandbox',
machineName: 'your-machine-name'
timeout: 5000 // optional, default 20 min
timeout: 5000, // optional, default 20 min
logOptions: {
logEnabled: true, // toggle logging on or off, by default its off.
logLevel: 3, // logLevel that will be used, Options are LogLevel.Error (0), LogLevel.Warn (1), LogLevel.Info (2), LogLevel.Debug (3)
logRequestAndResponseInfo: true, // Toggle logging of the request and response bodies on and off.
logger: myCustomLogger // (OPTIONAL) Custom logger can be passed in that implements the BaseLogger interface (e.g. debug, info, warn, error, and log functions) Otherwise console.log/error etc will be used by default.
}
};

const creds = {
Expand Down Expand Up @@ -101,10 +107,16 @@ return client.resolveAddress(address)
```
## Release Notes

In the JS-SDK 21.2.1 release, the SDK can now return big integers from API responses.
Big integers in JavaScript are displayed in responses by appending an 'n' to the end of an integer literal. For example, 618368842515476464 -> 618368842515476464n.
Numbers are presented as before. For example, 8456123 -> 8456123.
For more information, refer to the following Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt
Please see the [Github releases](https://github.com/avadev/AvaTax-REST-V2-JS-SDK/releases) for in-depth release notes.

## Typescript support
As of version 22.11.0, Typescript support is included in the SDK. Models and Enums included in addition to typing for all of the API methods and parameters. The team welcomes any feedback on this feature.

Models and Enums can be imported into Typescript projects as follows:
```typescript
import { AddressResolutionModel } from 'avatax/models';
import { AddressCategoryId } from 'avatax/enums';
```

## SDK Development

Expand Down Expand Up @@ -139,5 +151,4 @@ https://github.com/avadev/AvaTax-REST-V2-JS-SDK/blob/master/test/helpers/load_cr
``` bash
# assuming a tag of v17.5.2 and a remote of 'upstream'
git push upstream v17.5.2
```

```
3 changes: 2 additions & 1 deletion index.js → index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
*/

import client from './lib/AvaTaxClient';
module.exports = client;
export default client;
module.exports = exports["default"];

17,262 changes: 8,918 additions & 8,344 deletions lib/AvaTaxClient.js → lib/AvaTaxClient.ts

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions lib/enums.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './enums/index';
26 changes: 26 additions & 0 deletions lib/enums/AccountStatusId.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* AvaTax Software Development Kit for JavaScript
*
* (c) 2004-2022 Avalara, Inc.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @author Jonathan Wenger <[email protected]>
* @author Sachin Baijal <[email protected]>
* @copyright 2004-2018 Avalara, Inc.
* @license https://www.apache.org/licenses/LICENSE-2.0
* @version 22.10.0
* @link https://github.com/avadev/AvaTax-REST-V2-JS-SDK
*/

/**
* @export
* @enum {string}
*/
export enum AccountStatusId {
Inactive = 0,
Active = 1,
Test = 2,
New = 3,
}
25 changes: 25 additions & 0 deletions lib/enums/AccountTypeId.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* AvaTax Software Development Kit for JavaScript
*
* (c) 2004-2022 Avalara, Inc.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @author Jonathan Wenger <[email protected]>
* @author Sachin Baijal <[email protected]>
* @copyright 2004-2018 Avalara, Inc.
* @license https://www.apache.org/licenses/LICENSE-2.0
* @version 22.10.0
* @link https://github.com/avadev/AvaTax-REST-V2-JS-SDK
*/

/**
* @export
* @enum {string}
*/
export enum AccountTypeId {
Regular = 1,
Firm = 2,
FirmClient = 3,
}
24 changes: 24 additions & 0 deletions lib/enums/AccrualType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* AvaTax Software Development Kit for JavaScript
*
* (c) 2004-2022 Avalara, Inc.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @author Jonathan Wenger <[email protected]>
* @author Sachin Baijal <[email protected]>
* @copyright 2004-2018 Avalara, Inc.
* @license https://www.apache.org/licenses/LICENSE-2.0
* @version 22.10.0
* @link https://github.com/avadev/AvaTax-REST-V2-JS-SDK
*/

/**
* @export
* @enum {string}
*/
export enum AccrualType {
Filing = 1,
Accrual = 2,
}
30 changes: 30 additions & 0 deletions lib/enums/AddressCategoryId.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* AvaTax Software Development Kit for JavaScript
*
* (c) 2004-2022 Avalara, Inc.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @author Jonathan Wenger <[email protected]>
* @author Sachin Baijal <[email protected]>
* @copyright 2004-2018 Avalara, Inc.
* @license https://www.apache.org/licenses/LICENSE-2.0
* @version 22.10.0
* @link https://github.com/avadev/AvaTax-REST-V2-JS-SDK
*/

/**
* @export
* @enum {string}
*/
export enum AddressCategoryId {
Storefront = 1,
MainOffice = 2,
Warehouse = 3,
Salesperson = 4,
Other = 5,
SellerRemitsTax = 6,
MarketplaceRemitsTax = 7,
NonPhysical = 8,
}
25 changes: 25 additions & 0 deletions lib/enums/AddressTypeId.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* AvaTax Software Development Kit for JavaScript
*
* (c) 2004-2022 Avalara, Inc.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @author Jonathan Wenger <[email protected]>
* @author Sachin Baijal <[email protected]>
* @copyright 2004-2018 Avalara, Inc.
* @license https://www.apache.org/licenses/LICENSE-2.0
* @version 22.10.0
* @link https://github.com/avadev/AvaTax-REST-V2-JS-SDK
*/

/**
* @export
* @enum {string}
*/
export enum AddressTypeId {
Location = 1,
Salesperson = 2,
Marketplace = 3,
}
25 changes: 25 additions & 0 deletions lib/enums/AdjustmentPeriodTypeId.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* AvaTax Software Development Kit for JavaScript
*
* (c) 2004-2022 Avalara, Inc.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @author Jonathan Wenger <[email protected]>
* @author Sachin Baijal <[email protected]>
* @copyright 2004-2018 Avalara, Inc.
* @license https://www.apache.org/licenses/LICENSE-2.0
* @version 22.10.0
* @link https://github.com/avadev/AvaTax-REST-V2-JS-SDK
*/

/**
* @export
* @enum {string}
*/
export enum AdjustmentPeriodTypeId {
None = 0,
CurrentPeriod = 1,
NextPeriod = 2,
}
32 changes: 32 additions & 0 deletions lib/enums/AdjustmentReason.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* AvaTax Software Development Kit for JavaScript
*
* (c) 2004-2022 Avalara, Inc.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @author Jonathan Wenger <[email protected]>
* @author Sachin Baijal <[email protected]>
* @copyright 2004-2018 Avalara, Inc.
* @license https://www.apache.org/licenses/LICENSE-2.0
* @version 22.10.0
* @link https://github.com/avadev/AvaTax-REST-V2-JS-SDK
*/

/**
* @export
* @enum {string}
*/
export enum AdjustmentReason {
NotAdjusted = 0,
SourcingIssue = 1,
ReconciledWithGeneralLedger = 2,
ExemptCertApplied = 3,
PriceAdjusted = 4,
ProductReturned = 5,
ProductExchanged = 6,
BadDebt = 7,
Other = 8,
Offline = 9,
}
28 changes: 28 additions & 0 deletions lib/enums/AgeVerifyFailureCode.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* AvaTax Software Development Kit for JavaScript
*
* (c) 2004-2022 Avalara, Inc.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @author Jonathan Wenger <[email protected]>
* @author Sachin Baijal <[email protected]>
* @copyright 2004-2018 Avalara, Inc.
* @license https://www.apache.org/licenses/LICENSE-2.0
* @version 22.10.0
* @link https://github.com/avadev/AvaTax-REST-V2-JS-SDK
*/

/**
* @export
* @enum {string}
*/
export enum AgeVerifyFailureCode {
not_found = 0,
dob_unverifiable = 1,
under_age = 2,
suspected_fraud = 3,
deceased = 4,
unknown_error = 5,
}
25 changes: 25 additions & 0 deletions lib/enums/ApiCallStatus.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* AvaTax Software Development Kit for JavaScript
*
* (c) 2004-2022 Avalara, Inc.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @author Jonathan Wenger <[email protected]>
* @author Sachin Baijal <[email protected]>
* @copyright 2004-2018 Avalara, Inc.
* @license https://www.apache.org/licenses/LICENSE-2.0
* @version 22.10.0
* @link https://github.com/avadev/AvaTax-REST-V2-JS-SDK
*/

/**
* @export
* @enum {string}
*/
export enum ApiCallStatus {
OriginalApiCallAvailable = 0,
ReconstructedApiCallAvailable = 1,
Any = -1,
}
24 changes: 24 additions & 0 deletions lib/enums/ApiVersionSchema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* AvaTax Software Development Kit for JavaScript
*
* (c) 2004-2022 Avalara, Inc.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @author Jonathan Wenger <[email protected]>
* @author Sachin Baijal <[email protected]>
* @copyright 2004-2018 Avalara, Inc.
* @license https://www.apache.org/licenses/LICENSE-2.0
* @version 22.10.0
* @link https://github.com/avadev/AvaTax-REST-V2-JS-SDK
*/

/**
* @export
* @enum {string}
*/
export enum ApiVersionSchema {
C_2_1 = 0,
C_2_2 = 1,
}
26 changes: 26 additions & 0 deletions lib/enums/AuthenticationTypeId.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* AvaTax Software Development Kit for JavaScript
*
* (c) 2004-2022 Avalara, Inc.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @author Jonathan Wenger <[email protected]>
* @author Sachin Baijal <[email protected]>
* @copyright 2004-2018 Avalara, Inc.
* @license https://www.apache.org/licenses/LICENSE-2.0
* @version 22.10.0
* @link https://github.com/avadev/AvaTax-REST-V2-JS-SDK
*/

/**
* @export
* @enum {string}
*/
export enum AuthenticationTypeId {
None = 0,
UsernamePassword = 1,
AccountIdLicenseKey = 2,
OpenIdBearerToken = 3,
}
Loading

0 comments on commit 75a58f2

Please sign in to comment.