@paddle/paddle-node-sdk 1.3.0 → 1.4.0
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 +8 -0
- package/LICENSE +1 -12
- package/README.md +7 -0
- package/dist/cjs/index.js +2 -1
- package/dist/cjs/internal/api/client.js +3 -0
- package/dist/cjs/internal/api/index.js +3 -1
- package/dist/cjs/internal/api/log-level.js +10 -0
- package/dist/cjs/internal/base/logger.js +22 -3
- package/dist/cjs/paddle.js +1 -0
- package/dist/cjs/version.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/internal/api/client.js +3 -0
- package/dist/esm/internal/api/index.js +1 -0
- package/dist/esm/internal/api/log-level.js +7 -0
- package/dist/esm/internal/base/logger.js +22 -3
- package/dist/esm/paddle.js +2 -1
- package/dist/esm/version.js +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/internal/api/index.d.ts +1 -0
- package/dist/types/internal/api/log-level.d.ts +6 -0
- package/dist/types/internal/base/logger.d.ts +3 -0
- package/dist/types/internal/types/config.d.ts +2 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -12,6 +12,14 @@ 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
|
+
## 1.4.0 - 2024-06-20
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
|
|
19
|
+
- Added a new option to change the logging level of the SDK. You can now set the logging level to `verbose`, `warn`, `error` or `none`. The default logging level is `verbose`.
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
15
23
|
## 1.3.0 - 2024-04-18
|
|
16
24
|
|
|
17
25
|
### Changed
|
package/LICENSE
CHANGED
|
@@ -175,18 +175,7 @@
|
|
|
175
175
|
|
|
176
176
|
END OF TERMS AND CONDITIONS
|
|
177
177
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
To apply the Apache License to your work, attach the following
|
|
181
|
-
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
-
replaced with your own identifying information. (Don't include
|
|
183
|
-
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
-
comment syntax for the file format. We also recommend that a
|
|
185
|
-
file or class name and description of purpose be included on the
|
|
186
|
-
same "printed page" as the copyright notice for easier
|
|
187
|
-
identification within third-party archives.
|
|
188
|
-
|
|
189
|
-
Copyright [yyyy] [name of copyright owner]
|
|
178
|
+
Copyright 2024 Paddle.com Market Limited
|
|
190
179
|
|
|
191
180
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
181
|
you may not use this file except in compliance with the License.
|
package/README.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Paddle Node.js SDK
|
|
2
2
|
|
|
3
|
+
[](https://github.com/PaddleHQ/paddle-node-sdk/actions/workflows/build-test.yml?query=branch%3Amain)
|
|
4
|
+
[](https://www.npmjs.com/package/@paddle/paddle-node-sdk?activeTab=versions)
|
|
5
|
+
[](https://www.npmjs.com/package/@paddle/paddle-node-sdk)
|
|
6
|
+
[](https://github.com/PaddleHQ/paddle-node-sdk/blob/main/LICENSE)
|
|
7
|
+
|
|
8
|
+
|
|
3
9
|
[Paddle Billing](https://www.paddle.com/billing?utm_source=dx&utm_medium=paddle-node-sdk) is a complete digital product sales and subscription management platform, designed for modern software businesses. It helps you increase your revenue, retain customers, and scale your operations.
|
|
4
10
|
|
|
5
11
|
This is a [Node.js](https://nodejs.org/) SDK that you can use to integrate Paddle Billing with applications written in server-side JavaScript.
|
|
@@ -45,6 +51,7 @@ You can also pass an environment to work with the sandbox:
|
|
|
45
51
|
```typescript
|
|
46
52
|
const paddle = new Paddle('API_KEY', {
|
|
47
53
|
environment: Environment.production, // or Environment.sandbox for accessing sandbox API
|
|
54
|
+
logLevel: 'verbose' // or 'error' for less verbose logging
|
|
48
55
|
})
|
|
49
56
|
```
|
|
50
57
|
|
package/dist/cjs/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.ApiError = exports.Environment = void 0;
|
|
17
|
+
exports.Paddle = exports.SDK_VERSION = exports.ApiError = exports.LogLevel = 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, "LogLevel", { enumerable: true, get: function () { return internal_1.LogLevel; } });
|
|
20
21
|
Object.defineProperty(exports, "ApiError", { enumerable: true, get: function () { return internal_1.ApiError; } });
|
|
21
22
|
var version_1 = require("./version");
|
|
22
23
|
Object.defineProperty(exports, "SDK_VERSION", { enumerable: true, get: function () { return version_1.SDK_VERSION; } });
|
|
@@ -20,11 +20,14 @@ const environment_1 = require("./environment");
|
|
|
20
20
|
const node_crypto_1 = require("node:crypto");
|
|
21
21
|
const logger_1 = require("../base/logger");
|
|
22
22
|
const case_helpers_1 = require("./case-helpers");
|
|
23
|
+
const log_level_1 = require("./log-level");
|
|
23
24
|
class Client {
|
|
24
25
|
constructor(apiKey, options) {
|
|
26
|
+
var _a;
|
|
25
27
|
this.apiKey = apiKey;
|
|
26
28
|
this.options = options;
|
|
27
29
|
this.baseUrl = this.getBaseUrl(this.options.environment);
|
|
30
|
+
logger_1.Logger.logLevel = (_a = this.options.logLevel) !== null && _a !== void 0 ? _a : log_level_1.LogLevel.verbose;
|
|
28
31
|
}
|
|
29
32
|
getBaseUrl(environment) {
|
|
30
33
|
const urlBasedOnEnv = constants_1.API_ENVIRONMENT_TO_BASE_URL_MAP[environment !== null && environment !== void 0 ? environment : environment_1.Environment.production];
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.convertToSnakeCase = exports.Environment = void 0;
|
|
3
|
+
exports.LogLevel = exports.convertToSnakeCase = exports.Environment = void 0;
|
|
4
4
|
var environment_1 = require("./environment");
|
|
5
5
|
Object.defineProperty(exports, "Environment", { enumerable: true, get: function () { return environment_1.Environment; } });
|
|
6
6
|
var case_helpers_1 = require("./case-helpers");
|
|
7
7
|
Object.defineProperty(exports, "convertToSnakeCase", { enumerable: true, get: function () { return case_helpers_1.convertToSnakeCase; } });
|
|
8
|
+
var log_level_1 = require("./log-level");
|
|
9
|
+
Object.defineProperty(exports, "LogLevel", { enumerable: true, get: function () { return log_level_1.LogLevel; } });
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LogLevel = void 0;
|
|
4
|
+
var LogLevel;
|
|
5
|
+
(function (LogLevel) {
|
|
6
|
+
LogLevel["verbose"] = "verbose";
|
|
7
|
+
LogLevel["warn"] = "warn";
|
|
8
|
+
LogLevel["error"] = "error";
|
|
9
|
+
LogLevel["none"] = "none";
|
|
10
|
+
})(LogLevel || (exports.LogLevel = LogLevel = {}));
|
|
@@ -1,15 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Logger = void 0;
|
|
4
|
+
const api_1 = require("../api");
|
|
4
5
|
class Logger {
|
|
6
|
+
static shouldLog(level) {
|
|
7
|
+
switch (Logger.logLevel) {
|
|
8
|
+
case api_1.LogLevel.verbose:
|
|
9
|
+
return level !== api_1.LogLevel.none;
|
|
10
|
+
case api_1.LogLevel.warn:
|
|
11
|
+
return level === api_1.LogLevel.warn || level === api_1.LogLevel.error;
|
|
12
|
+
case api_1.LogLevel.error:
|
|
13
|
+
return level === api_1.LogLevel.error;
|
|
14
|
+
default:
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
5
18
|
static log(...args) {
|
|
6
|
-
|
|
19
|
+
if (Logger.shouldLog(api_1.LogLevel.verbose)) {
|
|
20
|
+
console.log('[Paddle] [LOG]', ...args);
|
|
21
|
+
}
|
|
7
22
|
}
|
|
8
23
|
static warn(...args) {
|
|
9
|
-
|
|
24
|
+
if (Logger.shouldLog(api_1.LogLevel.warn)) {
|
|
25
|
+
console.warn('[Paddle] [WARN]', ...args);
|
|
26
|
+
}
|
|
10
27
|
}
|
|
11
28
|
static error(...args) {
|
|
12
|
-
|
|
29
|
+
if (Logger.shouldLog(api_1.LogLevel.error)) {
|
|
30
|
+
console.error('[Paddle] [ERROR]', ...args);
|
|
31
|
+
}
|
|
13
32
|
}
|
|
14
33
|
static logRequest(method, url, headers) {
|
|
15
34
|
Logger.log('[Request]', method, url, 'Transaction ID:', headers['X-Transaction-ID']);
|
package/dist/cjs/paddle.js
CHANGED
|
@@ -10,6 +10,7 @@ class Paddle {
|
|
|
10
10
|
constructor(apiKey, options) {
|
|
11
11
|
this.defaultPaddleOptions = {
|
|
12
12
|
environment: internal_1.Environment.production,
|
|
13
|
+
logLevel: internal_1.LogLevel.verbose,
|
|
13
14
|
};
|
|
14
15
|
this.client = new client_1.Client(apiKey, options ? Object.assign(Object.assign({}, this.defaultPaddleOptions), options) : Object.assign({}, this.defaultPaddleOptions));
|
|
15
16
|
this.products = new resources_1.ProductsResource(this.client);
|
package/dist/cjs/version.js
CHANGED
package/dist/esm/index.js
CHANGED
|
@@ -14,11 +14,14 @@ import { Environment } from './environment';
|
|
|
14
14
|
import { randomUUID } from 'node:crypto';
|
|
15
15
|
import { Logger } from '../base/logger';
|
|
16
16
|
import { convertToSnakeCase } from './case-helpers';
|
|
17
|
+
import { LogLevel } from './log-level';
|
|
17
18
|
export class Client {
|
|
18
19
|
constructor(apiKey, options) {
|
|
20
|
+
var _a;
|
|
19
21
|
this.apiKey = apiKey;
|
|
20
22
|
this.options = options;
|
|
21
23
|
this.baseUrl = this.getBaseUrl(this.options.environment);
|
|
24
|
+
Logger.logLevel = (_a = this.options.logLevel) !== null && _a !== void 0 ? _a : LogLevel.verbose;
|
|
22
25
|
}
|
|
23
26
|
getBaseUrl(environment) {
|
|
24
27
|
const urlBasedOnEnv = API_ENVIRONMENT_TO_BASE_URL_MAP[environment !== null && environment !== void 0 ? environment : Environment.production];
|
|
@@ -1,12 +1,31 @@
|
|
|
1
|
+
import { LogLevel } from '../api';
|
|
1
2
|
export class Logger {
|
|
3
|
+
static shouldLog(level) {
|
|
4
|
+
switch (Logger.logLevel) {
|
|
5
|
+
case LogLevel.verbose:
|
|
6
|
+
return level !== LogLevel.none;
|
|
7
|
+
case LogLevel.warn:
|
|
8
|
+
return level === LogLevel.warn || level === LogLevel.error;
|
|
9
|
+
case LogLevel.error:
|
|
10
|
+
return level === LogLevel.error;
|
|
11
|
+
default:
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
2
15
|
static log(...args) {
|
|
3
|
-
|
|
16
|
+
if (Logger.shouldLog(LogLevel.verbose)) {
|
|
17
|
+
console.log('[Paddle] [LOG]', ...args);
|
|
18
|
+
}
|
|
4
19
|
}
|
|
5
20
|
static warn(...args) {
|
|
6
|
-
|
|
21
|
+
if (Logger.shouldLog(LogLevel.warn)) {
|
|
22
|
+
console.warn('[Paddle] [WARN]', ...args);
|
|
23
|
+
}
|
|
7
24
|
}
|
|
8
25
|
static error(...args) {
|
|
9
|
-
|
|
26
|
+
if (Logger.shouldLog(LogLevel.error)) {
|
|
27
|
+
console.error('[Paddle] [ERROR]', ...args);
|
|
28
|
+
}
|
|
10
29
|
}
|
|
11
30
|
static logRequest(method, url, headers) {
|
|
12
31
|
Logger.log('[Request]', method, url, 'Transaction ID:', headers['X-Transaction-ID']);
|
package/dist/esm/paddle.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { Client } from './internal/api/client';
|
|
2
2
|
import { AddressesResource, AdjustmentsResource, BusinessesResource, CustomersResource, DiscountsResource, EventTypesResource, NotificationSettingsResource, NotificationsResource, PricesResource, PricingPreviewResource, ProductsResource, ReportsResource, SubscriptionsResource, TransactionsResource, } from './resources';
|
|
3
|
-
import { Environment } from './internal';
|
|
3
|
+
import { Environment, LogLevel } from './internal';
|
|
4
4
|
import { EventsResource } from './resources/events';
|
|
5
5
|
import { Webhooks } from './notifications';
|
|
6
6
|
export class Paddle {
|
|
7
7
|
constructor(apiKey, options) {
|
|
8
8
|
this.defaultPaddleOptions = {
|
|
9
9
|
environment: Environment.production,
|
|
10
|
+
logLevel: LogLevel.verbose,
|
|
10
11
|
};
|
|
11
12
|
this.client = new Client(apiKey, options ? Object.assign(Object.assign({}, this.defaultPaddleOptions), options) : Object.assign({}, this.defaultPaddleOptions));
|
|
12
13
|
this.products = new ProductsResource(this.client);
|
package/dist/esm/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = '1.
|
|
1
|
+
export const SDK_VERSION = '1.4.0';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { type Response } from 'node-fetch';
|
|
2
|
+
import { LogLevel } from '../api';
|
|
2
3
|
type LogInputProps = Array<string | undefined | null>;
|
|
3
4
|
export declare class Logger {
|
|
5
|
+
static logLevel: LogLevel;
|
|
6
|
+
private static shouldLog;
|
|
4
7
|
static log(...args: LogInputProps): void;
|
|
5
8
|
static warn(...args: LogInputProps): void;
|
|
6
9
|
static error(...args: LogInputProps): void;
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "1.
|
|
1
|
+
export declare const SDK_VERSION = "1.4.0";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paddle/paddle-node-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
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.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|