@paddle/paddle-node-sdk 2.1.2 → 2.1.3
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 +6 -0
- package/dist/cjs/internal/base/index.js +1 -0
- package/dist/cjs/internal/base/transform.js +21 -0
- package/dist/cjs/notifications/events/generic/generic-event.js +12 -0
- package/dist/cjs/notifications/events/generic/index.js +17 -0
- package/dist/cjs/notifications/events/index.js +1 -0
- package/dist/cjs/notifications/helpers/webhooks.js +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/internal/base/index.js +1 -0
- package/dist/esm/internal/base/transform.js +17 -0
- package/dist/esm/notifications/events/generic/generic-event.js +8 -0
- package/dist/esm/notifications/events/generic/index.js +1 -0
- package/dist/esm/notifications/events/index.js +1 -0
- package/dist/esm/notifications/helpers/webhooks.js +2 -2
- package/dist/esm/version.js +1 -1
- package/dist/types/entities/events/event-collection.d.ts +2 -2
- package/dist/types/entities/notifications/notification.d.ts +1 -1
- package/dist/types/internal/base/index.d.ts +1 -0
- package/dist/types/internal/base/transform.d.ts +1 -0
- package/dist/types/notifications/events/generic/generic-event.d.ts +6 -0
- package/dist/types/notifications/events/generic/index.d.ts +1 -0
- package/dist/types/notifications/events/index.d.ts +1 -0
- package/dist/types/notifications/helpers/webhooks.d.ts +2 -2
- package/dist/types/version.d.ts +1 -1
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -12,6 +12,12 @@ When we make [non-breaking changes](https://developer.paddle.com/api-reference/a
|
|
|
12
12
|
|
|
13
13
|
This means when upgrading minor versions of the SDK, you may notice type errors. You can safely ignore these or fix by adding additional type guards.
|
|
14
14
|
|
|
15
|
+
## 2.1.3 - 2024-11-29
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
- `paddle.webhooks.unmarshal` will now return an event for unhandled event types instead of `null` this is only possible for legacy/no longer supported events or for new events that have not been added to the sdk yet
|
|
20
|
+
|
|
15
21
|
## 2.1.2 - 2024-11-26
|
|
16
22
|
|
|
17
23
|
### Fixed
|
|
@@ -18,3 +18,4 @@ __exportStar(require("./base-resource.js"), exports);
|
|
|
18
18
|
__exportStar(require("./query-parameters.js"), exports);
|
|
19
19
|
__exportStar(require("./path-parameters.js"), exports);
|
|
20
20
|
__exportStar(require("./collection.js"), exports);
|
|
21
|
+
__exportStar(require("./transform.js"), exports);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.convertKeysToCamelCase = void 0;
|
|
4
|
+
function toCamelCase(str) {
|
|
5
|
+
return str.toLowerCase().replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
6
|
+
}
|
|
7
|
+
function convertKeysToCamelCase(obj) {
|
|
8
|
+
if (obj === null || typeof obj !== 'object') {
|
|
9
|
+
return obj;
|
|
10
|
+
}
|
|
11
|
+
if (Array.isArray(obj)) {
|
|
12
|
+
return obj.map(convertKeysToCamelCase);
|
|
13
|
+
}
|
|
14
|
+
const converted = {};
|
|
15
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
16
|
+
const camelCaseKey = toCamelCase(key);
|
|
17
|
+
converted[camelCaseKey] = convertKeysToCamelCase(value);
|
|
18
|
+
}
|
|
19
|
+
return converted;
|
|
20
|
+
}
|
|
21
|
+
exports.convertKeysToCamelCase = convertKeysToCamelCase;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GenericEvent = void 0;
|
|
4
|
+
const event_js_1 = require("../../../entities/events/event.js");
|
|
5
|
+
const index_js_1 = require("../../../internal/base/index.js");
|
|
6
|
+
class GenericEvent extends event_js_1.Event {
|
|
7
|
+
constructor(response) {
|
|
8
|
+
super(response);
|
|
9
|
+
this.data = (0, index_js_1.convertKeysToCamelCase)(response.data);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.GenericEvent = GenericEvent;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./generic-event.js"), exports);
|
|
@@ -19,6 +19,7 @@ __exportStar(require("./adjustment/index.js"), exports);
|
|
|
19
19
|
__exportStar(require("./business/index.js"), exports);
|
|
20
20
|
__exportStar(require("./customer/index.js"), exports);
|
|
21
21
|
__exportStar(require("./discount/index.js"), exports);
|
|
22
|
+
__exportStar(require("./generic/index.js"), exports);
|
|
22
23
|
__exportStar(require("./payment-method/index.js"), exports);
|
|
23
24
|
__exportStar(require("./payout/index.js"), exports);
|
|
24
25
|
__exportStar(require("./price/index.js"), exports);
|
package/dist/cjs/version.js
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
function toCamelCase(str) {
|
|
2
|
+
return str.toLowerCase().replace(/_([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
3
|
+
}
|
|
4
|
+
export function convertKeysToCamelCase(obj) {
|
|
5
|
+
if (obj === null || typeof obj !== 'object') {
|
|
6
|
+
return obj;
|
|
7
|
+
}
|
|
8
|
+
if (Array.isArray(obj)) {
|
|
9
|
+
return obj.map(convertKeysToCamelCase);
|
|
10
|
+
}
|
|
11
|
+
const converted = {};
|
|
12
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
13
|
+
const camelCaseKey = toCamelCase(key);
|
|
14
|
+
converted[camelCaseKey] = convertKeysToCamelCase(value);
|
|
15
|
+
}
|
|
16
|
+
return converted;
|
|
17
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Event } from '../../../entities/events/event.js';
|
|
2
|
+
import { convertKeysToCamelCase } from '../../../internal/base/index.js';
|
|
3
|
+
export class GenericEvent extends Event {
|
|
4
|
+
constructor(response) {
|
|
5
|
+
super(response);
|
|
6
|
+
this.data = convertKeysToCamelCase(response.data);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './generic-event.js';
|
|
@@ -3,6 +3,7 @@ export * from './adjustment/index.js';
|
|
|
3
3
|
export * from './business/index.js';
|
|
4
4
|
export * from './customer/index.js';
|
|
5
5
|
export * from './discount/index.js';
|
|
6
|
+
export * from './generic/index.js';
|
|
6
7
|
export * from './payment-method/index.js';
|
|
7
8
|
export * from './payout/index.js';
|
|
8
9
|
export * from './price/index.js';
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { WebhooksValidator } from './webhooks-validator.js';
|
|
11
11
|
import { EventName } from './types.js';
|
|
12
|
-
import { AddressCreatedEvent, AddressImportedEvent, AddressUpdatedEvent, AdjustmentCreatedEvent, AdjustmentUpdatedEvent, BusinessCreatedEvent, BusinessImportedEvent, BusinessUpdatedEvent, CustomerCreatedEvent, CustomerImportedEvent, CustomerUpdatedEvent, DiscountCreatedEvent, DiscountImportedEvent, DiscountUpdatedEvent, PaymentMethodDeletedEvent, PaymentMethodSavedEvent, PayoutCreatedEvent, PayoutPaidEvent, PriceCreatedEvent, PriceImportedEvent, PriceUpdatedEvent, ProductCreatedEvent, ProductImportedEvent, ProductUpdatedEvent, ReportCreatedEvent, ReportUpdatedEvent, SubscriptionActivatedEvent, SubscriptionCanceledEvent, SubscriptionCreatedEvent, SubscriptionImportedEvent, SubscriptionPastDueEvent, SubscriptionPausedEvent, SubscriptionResumedEvent, SubscriptionTrialingEvent, SubscriptionUpdatedEvent, TransactionBilledEvent, TransactionCanceledEvent, TransactionCompletedEvent, TransactionCreatedEvent, TransactionPaidEvent, TransactionPastDueEvent, TransactionPaymentFailedEvent, TransactionReadyEvent, TransactionUpdatedEvent, } from '../events/index.js';
|
|
12
|
+
import { AddressCreatedEvent, AddressImportedEvent, AddressUpdatedEvent, AdjustmentCreatedEvent, AdjustmentUpdatedEvent, BusinessCreatedEvent, BusinessImportedEvent, BusinessUpdatedEvent, CustomerCreatedEvent, CustomerImportedEvent, CustomerUpdatedEvent, DiscountCreatedEvent, DiscountImportedEvent, DiscountUpdatedEvent, GenericEvent, PaymentMethodDeletedEvent, PaymentMethodSavedEvent, PayoutCreatedEvent, PayoutPaidEvent, PriceCreatedEvent, PriceImportedEvent, PriceUpdatedEvent, ProductCreatedEvent, ProductImportedEvent, ProductUpdatedEvent, ReportCreatedEvent, ReportUpdatedEvent, SubscriptionActivatedEvent, SubscriptionCanceledEvent, SubscriptionCreatedEvent, SubscriptionImportedEvent, SubscriptionPastDueEvent, SubscriptionPausedEvent, SubscriptionResumedEvent, SubscriptionTrialingEvent, SubscriptionUpdatedEvent, TransactionBilledEvent, TransactionCanceledEvent, TransactionCompletedEvent, TransactionCreatedEvent, TransactionPaidEvent, TransactionPastDueEvent, TransactionPaymentFailedEvent, TransactionReadyEvent, TransactionUpdatedEvent, } from '../events/index.js';
|
|
13
13
|
import { Logger } from '../../internal/base/logger.js';
|
|
14
14
|
export class Webhooks {
|
|
15
15
|
unmarshal(requestBody, secretKey, signature) {
|
|
@@ -121,7 +121,7 @@ export class Webhooks {
|
|
|
121
121
|
return new ReportUpdatedEvent(data);
|
|
122
122
|
default:
|
|
123
123
|
Logger.log(`Unknown event_type ${data.event_type}`);
|
|
124
|
-
return
|
|
124
|
+
return new GenericEvent(data);
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
}
|
package/dist/esm/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = '2.1.
|
|
1
|
+
export const SDK_VERSION = '2.1.3';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type IEvents, type IEventsResponse } from '../../types/index.js';
|
|
2
2
|
import { Collection } from '../../internal/base/index.js';
|
|
3
3
|
import { type EventEntity } from '../../notifications/index.js';
|
|
4
|
-
export declare class EventCollection extends Collection<IEventsResponse, EventEntity
|
|
5
|
-
fromJson(data: IEvents): EventEntity
|
|
4
|
+
export declare class EventCollection extends Collection<IEventsResponse, EventEntity> {
|
|
5
|
+
fromJson(data: IEvents): EventEntity;
|
|
6
6
|
}
|
|
@@ -5,7 +5,7 @@ export declare class Notification {
|
|
|
5
5
|
readonly id: string;
|
|
6
6
|
readonly type: IEventName;
|
|
7
7
|
readonly status: NotificationStatus;
|
|
8
|
-
readonly payload: EventEntity
|
|
8
|
+
readonly payload: EventEntity;
|
|
9
9
|
readonly occurredAt: string;
|
|
10
10
|
readonly deliveredAt: null | string;
|
|
11
11
|
readonly replayedAt: null | string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function convertKeysToCamelCase(obj: object): object;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './generic-event.js';
|
|
@@ -3,6 +3,7 @@ export * from './adjustment/index.js';
|
|
|
3
3
|
export * from './business/index.js';
|
|
4
4
|
export * from './customer/index.js';
|
|
5
5
|
export * from './discount/index.js';
|
|
6
|
+
export * from './generic/index.js';
|
|
6
7
|
export * from './payment-method/index.js';
|
|
7
8
|
export * from './payout/index.js';
|
|
8
9
|
export * from './price/index.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type IEvents } from '../../types/index.js';
|
|
2
2
|
import { type EventEntity } from './types.js';
|
|
3
3
|
export declare class Webhooks {
|
|
4
|
-
unmarshal(requestBody: string, secretKey: string, signature: string): Promise<EventEntity
|
|
4
|
+
unmarshal(requestBody: string, secretKey: string, signature: string): Promise<EventEntity>;
|
|
5
5
|
isSignatureValid(requestBody: string, secretKey: string, signature: string): Promise<boolean>;
|
|
6
|
-
static fromJson(data: IEvents): EventEntity
|
|
6
|
+
static fromJson(data: IEvents): EventEntity;
|
|
7
7
|
}
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "2.1.
|
|
1
|
+
export declare const SDK_VERSION = "2.1.3";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paddle/paddle-node-sdk",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.3",
|
|
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/cjs/index.cjs.node.js",
|
|
6
6
|
"module": "dist/esm/index.esm.node.js",
|
|
@@ -68,5 +68,6 @@
|
|
|
68
68
|
"import": "./dist/esm/index.esm.node.js",
|
|
69
69
|
"require": "./dist/cjs/index.cjs.node.js"
|
|
70
70
|
}
|
|
71
|
-
}
|
|
71
|
+
},
|
|
72
|
+
"dependencies": {}
|
|
72
73
|
}
|