@paddle/paddle-node-sdk 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,18 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
7
7
  Check our main [developer changelog](https://developer.paddle.com/?utm_source=dx&utm_medium=paddle-node-sdk) for information about changes to the Paddle Billing platform, the Paddle API, and other developer tools.
8
8
 
9
9
 
10
+ ## 1.0.2 - 2024-03-12
11
+
12
+ ### Added
13
+
14
+ - Exported `ApiError` class for usage in `try/catch` block.
15
+
16
+ ### Changed
17
+
18
+ - Added `customerId` property to `Address` and `Business` entities, see [related changelog](https://developer.paddle.com/changelog/2024/address-business-webhooks-customer-id?utm_source=dx&utm_medium=paddle-node-sdk).
19
+
20
+ ---
21
+
10
22
  ## 1.0.1 - 2024-02-20
11
23
 
12
24
  ### Changed
package/README.md CHANGED
@@ -206,6 +206,26 @@ const product = await archiveProduct('id')
206
206
  console.log('Product', product)
207
207
  ```
208
208
 
209
+ ### Error Handling
210
+
211
+ If a request fails, Paddle returns an `error` object that contains the same information as [errors returned by the API](https://developer.paddle.com/api-reference/about/errors?utm_source=dx&utm_medium=paddle-node-sdk). You can use the `code` attribute to search an error in [the error reference](https://developer.paddle.com/errors/overview?utm_source=dx&utm_medium=paddle-node-sdk) and to handle the error in your app. Validation errors also return an array of `errors` that tell you which fields failed validation.
212
+
213
+ This example shows how to handle an error with the code `conflict`:
214
+
215
+ ```typescript
216
+ import { ApiError } from '@paddle/paddle-node-sdk'
217
+
218
+ try {
219
+ // Call functions from the SDK
220
+ } catch (e: any) {
221
+ // e.code will always follow the error code defined in our documentation
222
+ const paddleApiError = e as ApiError;
223
+ if (paddleApiError.code === 'conflict') {
224
+ // Handle Conflict error
225
+ }
226
+ }
227
+ ```
228
+
209
229
  ## Resources
210
230
 
211
231
  ### Webhook signature verification
@@ -265,4 +285,4 @@ The Node.js SDK has complete feature parity with the Paddle API. All operations
265
285
  ## Learn more
266
286
 
267
287
  - [Paddle API reference](https://developer.paddle.com/api-reference/overview?utm_source=dx&utm_medium=paddle-node-sdk)
268
- - [Sign up for Paddle Billing](https://login.paddle.com/signup?utm_source=dx&utm_medium=paddle-node-sdk)
288
+ - [Sign up for Paddle Billing](https://login.paddle.com/signup?utm_source=dx&utm_medium=paddle-node-sdk)
@@ -3,6 +3,7 @@ import { type CountryCode, type Status } from '../../enums';
3
3
  import { type IAddressResponse } from '../../types';
4
4
  export declare class Address {
5
5
  readonly id: string;
6
+ readonly customerId: string;
6
7
  readonly description: string | null;
7
8
  readonly firstLine: string | null;
8
9
  readonly secondLine: string | null;
@@ -5,6 +5,7 @@ const index_1 = require("../index");
5
5
  class Address {
6
6
  constructor(address) {
7
7
  this.id = address.id;
8
+ this.customerId = address.customer_id;
8
9
  this.description = address.description ? address.description : null;
9
10
  this.firstLine = address.first_line ? address.first_line : null;
10
11
  this.secondLine = address.second_line ? address.second_line : null;
@@ -3,6 +3,7 @@ import { type Status } from '../../enums';
3
3
  import { type IBusinessResponse } from '../../types';
4
4
  export declare class Business {
5
5
  readonly id: string;
6
+ readonly customerId: string;
6
7
  readonly name: string;
7
8
  readonly companyNumber: string | null;
8
9
  readonly taxIdentifier: string | null;
@@ -5,6 +5,7 @@ const index_1 = require("../index");
5
5
  class Business {
6
6
  constructor(business) {
7
7
  this.id = business.id;
8
+ this.customerId = business.customer_id;
8
9
  this.name = business.name;
9
10
  this.companyNumber = business.company_number ? business.company_number : null;
10
11
  this.taxIdentifier = business.tax_identifier ? business.tax_identifier : null;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { Environment } from './internal';
1
+ export { Environment, ApiError, type PaddleOptions } from './internal';
2
2
  export { SDK_VERSION } from './version';
3
3
  export { Paddle } from './paddle';
4
4
  export * from './entities';
package/dist/index.js CHANGED
@@ -14,9 +14,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.Paddle = exports.SDK_VERSION = exports.Environment = void 0;
17
+ exports.Paddle = exports.SDK_VERSION = exports.ApiError = exports.Environment = void 0;
18
18
  var internal_1 = require("./internal");
19
19
  Object.defineProperty(exports, "Environment", { enumerable: true, get: function () { return internal_1.Environment; } });
20
+ Object.defineProperty(exports, "ApiError", { enumerable: true, get: function () { return internal_1.ApiError; } });
20
21
  var version_1 = require("./version");
21
22
  Object.defineProperty(exports, "SDK_VERSION", { enumerable: true, get: function () { return version_1.SDK_VERSION; } });
22
23
  var paddle_1 = require("./paddle");
@@ -1,3 +1,4 @@
1
1
  export type { ErrorResponse, ResponsePaginated, Response, ErrorDetail, ErrorField } from './types/response';
2
2
  export type { PaddleOptions } from './types/config';
3
3
  export * from './api';
4
+ export { ApiError } from './errors/generic';
@@ -14,4 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.ApiError = void 0;
17
18
  __exportStar(require("./api"), exports);
19
+ var generic_1 = require("./errors/generic");
20
+ Object.defineProperty(exports, "ApiError", { enumerable: true, get: function () { return generic_1.ApiError; } });
@@ -1,4 +1,4 @@
1
- import { type Environment } from '../api/environment';
1
+ import { type Environment } from '../api';
2
2
  export interface PaddleOptions {
3
3
  environment?: Environment;
4
4
  }
@@ -3,6 +3,7 @@ import { type CustomData, ImportMeta } from '../../../entities';
3
3
  import { type IAddressNotificationResponse } from '../../types';
4
4
  export declare class AddressNotification {
5
5
  readonly id: string;
6
+ readonly customerId: string | null;
6
7
  readonly description: string | null;
7
8
  readonly firstLine: string | null;
8
9
  readonly secondLine: string | null;
@@ -4,7 +4,9 @@ exports.AddressNotification = void 0;
4
4
  const entities_1 = require("../../../entities");
5
5
  class AddressNotification {
6
6
  constructor(address) {
7
+ var _a;
7
8
  this.id = address.id;
9
+ this.customerId = (_a = address.customer_id) !== null && _a !== void 0 ? _a : null;
8
10
  this.description = address.description ? address.description : null;
9
11
  this.firstLine = address.first_line ? address.first_line : null;
10
12
  this.secondLine = address.second_line ? address.second_line : null;
@@ -4,6 +4,7 @@ import { type IBusinessNotificationResponse } from '../../types';
4
4
  import { type CustomData } from '../../../entities';
5
5
  export declare class BusinessNotification {
6
6
  readonly id: string;
7
+ readonly customerId: string | null;
7
8
  readonly name: string;
8
9
  readonly companyNumber: string | null;
9
10
  readonly taxIdentifier: string | null;
@@ -4,7 +4,9 @@ exports.BusinessNotification = void 0;
4
4
  const index_1 = require("../index");
5
5
  class BusinessNotification {
6
6
  constructor(business) {
7
+ var _a;
7
8
  this.id = business.id;
9
+ this.customerId = (_a = business.customer_id) !== null && _a !== void 0 ? _a : null;
8
10
  this.name = business.name;
9
11
  this.companyNumber = business.company_number ? business.company_number : null;
10
12
  this.taxIdentifier = business.tax_identifier ? business.tax_identifier : null;
@@ -2,6 +2,7 @@ import { type CountryCode, type Status } from '../../../enums';
2
2
  import { type ICustomData, type IImportMetaResponse } from '../../../types';
3
3
  export interface IAddressNotificationResponse {
4
4
  id: string;
5
+ customer_id?: string | null;
5
6
  description?: string | null;
6
7
  first_line?: string | null;
7
8
  second_line?: string | null;
@@ -3,6 +3,7 @@ import { type Status } from '../../../enums';
3
3
  import { type ICustomData } from '../../../types';
4
4
  export interface IBusinessNotificationResponse {
5
5
  id: string;
6
+ customer_id?: string | null;
6
7
  name: string;
7
8
  company_number?: string | null;
8
9
  tax_identifier?: string | null;
@@ -2,6 +2,7 @@ import { type ICustomData, type IImportMetaResponse } from '../index';
2
2
  import { type CountryCode, type Status } from '../../enums';
3
3
  export interface IAddressResponse {
4
4
  id: string;
5
+ customer_id: string;
5
6
  description?: string | null;
6
7
  first_line?: string | null;
7
8
  second_line?: string | null;
@@ -2,6 +2,7 @@ import { type IBusinessContacts, type ICustomData, type IImportMetaResponse } fr
2
2
  import { type Status } from '../../enums';
3
3
  export interface IBusinessResponse {
4
4
  id: string;
5
+ customer_id: string;
5
6
  name: string;
6
7
  company_number?: string | null;
7
8
  tax_identifier?: string | null;
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "1.0.1";
1
+ export declare const SDK_VERSION = "1.0.2";
package/dist/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SDK_VERSION = void 0;
4
- exports.SDK_VERSION = '1.0.1';
4
+ exports.SDK_VERSION = '1.0.2';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paddle/paddle-node-sdk",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "A Node.js SDK that you can use to integrate Paddle Billing with applications written in server-side JavaScript.",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",