Skip to content

Commit 75a58f2

Browse files
Merge pull request #241 from avadev/jwenger/typescript-support-with-logging
Jwenger/typescript support with logging
2 parents 272147e + 590902e commit 75a58f2

File tree

410 files changed

+34459
-8359
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

410 files changed

+34459
-8359
lines changed

.github/workflows/npm-publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
steps:
1313
- uses: actions/checkout@v2
1414
- run: npm ci
15-
- run: npm run build
15+
- run: npm run build-tsc
1616
- uses: actions/setup-node@v2
1717
with:
1818
node-version: 16

README.md

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,19 @@ var Avatax = require('avatax');
2727
// es6/7 import
2828
// import Avatax from 'avatax';
2929

30-
// resolve configuration and credentials
30+
// resolve configuration, credentials and logOptions
3131
const config = {
3232
appName: 'your-app',
3333
appVersion: '1.0',
3434
environment: 'sandbox',
3535
machineName: 'your-machine-name'
36-
timeout: 5000 // optional, default 20 min
36+
timeout: 5000, // optional, default 20 min
37+
logOptions: {
38+
logEnabled: true, // toggle logging on or off, by default its off.
39+
logLevel: 3, // logLevel that will be used, Options are LogLevel.Error (0), LogLevel.Warn (1), LogLevel.Info (2), LogLevel.Debug (3)
40+
logRequestAndResponseInfo: true, // Toggle logging of the request and response bodies on and off.
41+
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.
42+
}
3743
};
3844

3945
const creds = {
@@ -101,10 +107,16 @@ return client.resolveAddress(address)
101107
```
102108
## Release Notes
103109

104-
In the JS-SDK 21.2.1 release, the SDK can now return big integers from API responses.
105-
Big integers in JavaScript are displayed in responses by appending an 'n' to the end of an integer literal. For example, 618368842515476464 -> 618368842515476464n.
106-
Numbers are presented as before. For example, 8456123 -> 8456123.
107-
For more information, refer to the following Mozilla documentation: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt
110+
Please see the [Github releases](https://github.com/avadev/AvaTax-REST-V2-JS-SDK/releases) for in-depth release notes.
111+
112+
## Typescript support
113+
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.
114+
115+
Models and Enums can be imported into Typescript projects as follows:
116+
```typescript
117+
import { AddressResolutionModel } from 'avatax/models';
118+
import { AddressCategoryId } from 'avatax/enums';
119+
```
108120

109121
## SDK Development
110122

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

index.js renamed to index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
*/
55

66
import client from './lib/AvaTaxClient';
7-
module.exports = client;
7+
export default client;
8+
module.exports = exports["default"];
89

lib/AvaTaxClient.js renamed to lib/AvaTaxClient.ts

Lines changed: 8918 additions & 8344 deletions
Large diffs are not rendered by default.

lib/enums.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './enums/index';

lib/enums/AccountStatusId.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* AvaTax Software Development Kit for JavaScript
3+
*
4+
* (c) 2004-2022 Avalara, Inc.
5+
*
6+
* For the full copyright and license information, please view the LICENSE
7+
* file that was distributed with this source code.
8+
*
9+
* @author Jonathan Wenger <[email protected]>
10+
* @author Sachin Baijal <[email protected]>
11+
* @copyright 2004-2018 Avalara, Inc.
12+
* @license https://www.apache.org/licenses/LICENSE-2.0
13+
* @version 22.10.0
14+
* @link https://github.com/avadev/AvaTax-REST-V2-JS-SDK
15+
*/
16+
17+
/**
18+
* @export
19+
* @enum {string}
20+
*/
21+
export enum AccountStatusId {
22+
Inactive = 0,
23+
Active = 1,
24+
Test = 2,
25+
New = 3,
26+
}

lib/enums/AccountTypeId.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* AvaTax Software Development Kit for JavaScript
3+
*
4+
* (c) 2004-2022 Avalara, Inc.
5+
*
6+
* For the full copyright and license information, please view the LICENSE
7+
* file that was distributed with this source code.
8+
*
9+
* @author Jonathan Wenger <[email protected]>
10+
* @author Sachin Baijal <[email protected]>
11+
* @copyright 2004-2018 Avalara, Inc.
12+
* @license https://www.apache.org/licenses/LICENSE-2.0
13+
* @version 22.10.0
14+
* @link https://github.com/avadev/AvaTax-REST-V2-JS-SDK
15+
*/
16+
17+
/**
18+
* @export
19+
* @enum {string}
20+
*/
21+
export enum AccountTypeId {
22+
Regular = 1,
23+
Firm = 2,
24+
FirmClient = 3,
25+
}

lib/enums/AccrualType.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* AvaTax Software Development Kit for JavaScript
3+
*
4+
* (c) 2004-2022 Avalara, Inc.
5+
*
6+
* For the full copyright and license information, please view the LICENSE
7+
* file that was distributed with this source code.
8+
*
9+
* @author Jonathan Wenger <[email protected]>
10+
* @author Sachin Baijal <[email protected]>
11+
* @copyright 2004-2018 Avalara, Inc.
12+
* @license https://www.apache.org/licenses/LICENSE-2.0
13+
* @version 22.10.0
14+
* @link https://github.com/avadev/AvaTax-REST-V2-JS-SDK
15+
*/
16+
17+
/**
18+
* @export
19+
* @enum {string}
20+
*/
21+
export enum AccrualType {
22+
Filing = 1,
23+
Accrual = 2,
24+
}

lib/enums/AddressCategoryId.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* AvaTax Software Development Kit for JavaScript
3+
*
4+
* (c) 2004-2022 Avalara, Inc.
5+
*
6+
* For the full copyright and license information, please view the LICENSE
7+
* file that was distributed with this source code.
8+
*
9+
* @author Jonathan Wenger <[email protected]>
10+
* @author Sachin Baijal <[email protected]>
11+
* @copyright 2004-2018 Avalara, Inc.
12+
* @license https://www.apache.org/licenses/LICENSE-2.0
13+
* @version 22.10.0
14+
* @link https://github.com/avadev/AvaTax-REST-V2-JS-SDK
15+
*/
16+
17+
/**
18+
* @export
19+
* @enum {string}
20+
*/
21+
export enum AddressCategoryId {
22+
Storefront = 1,
23+
MainOffice = 2,
24+
Warehouse = 3,
25+
Salesperson = 4,
26+
Other = 5,
27+
SellerRemitsTax = 6,
28+
MarketplaceRemitsTax = 7,
29+
NonPhysical = 8,
30+
}

lib/enums/AddressTypeId.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* AvaTax Software Development Kit for JavaScript
3+
*
4+
* (c) 2004-2022 Avalara, Inc.
5+
*
6+
* For the full copyright and license information, please view the LICENSE
7+
* file that was distributed with this source code.
8+
*
9+
* @author Jonathan Wenger <[email protected]>
10+
* @author Sachin Baijal <[email protected]>
11+
* @copyright 2004-2018 Avalara, Inc.
12+
* @license https://www.apache.org/licenses/LICENSE-2.0
13+
* @version 22.10.0
14+
* @link https://github.com/avadev/AvaTax-REST-V2-JS-SDK
15+
*/
16+
17+
/**
18+
* @export
19+
* @enum {string}
20+
*/
21+
export enum AddressTypeId {
22+
Location = 1,
23+
Salesperson = 2,
24+
Marketplace = 3,
25+
}

0 commit comments

Comments
 (0)