Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2.0.0-rc.0 - Edge runtime support and more. #45

Merged
merged 9 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ rules:
ignorePatterns:
- 'jest.config.js'
- '**/__tests__/**'
- 'index.esm.*.ts'
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2
updates:
- package-ecosystem: npm
directory: /
schedule:
interval: "weekly"
day: "monday"
time: "08:00"
groups:
npm:
patterns:
- "*"
10 changes: 6 additions & 4 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,21 @@ jobs:
run-build-test:
name: Run Build & test
runs-on: ubuntu-latest

strategy:
matrix:
node: [ 18, 20, 22 ]
permissions:
contents: read
actions: write

steps:
- name: Check out git repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: lts/*
node-version: ${{ matrix.node }}
cache: "yarn"

- name: Install yarn dependencies
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ jobs:

steps:
- name: Check out git repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: lts/*
cache: "yarn"
Expand Down
40 changes: 0 additions & 40 deletions .github/workflows/publish-beta.yml

This file was deleted.

13 changes: 10 additions & 3 deletions .github/workflows/publish-latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- main
- v1.X

jobs:
run-publish:
Expand All @@ -16,10 +17,10 @@ jobs:

steps:
- name: Check out git repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: lts/*
cache: "yarn"
Expand All @@ -35,6 +36,12 @@ jobs:
run: yarn test

- name: Publish
run: yarn publish:latest
run: |
VERSION=$(node -p "require('./package.json').version" )
if [[ "$VERSION" =~ (beta) ]]; then
yarn publish:beta
else
yarn publish:latest
fi
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,23 @@ When we make [non-breaking changes](https://developer.paddle.com/api-reference/a

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.

## 2.0.0-beta.0 - 2024-09-25

> **Breaking changes:** This version includes major improvements that introduce breaking changes. These are called out below.

### Added

- Added support for edge runtime.

### Changed

- **Breaking change:** Updated the minimum required Node.js version to v18.
- **Breaking change:** `Webhooks.unmarshal` and `Webhooks.isSignatureValid` now returns a promise.
- Enabled conditional exports based on runtimes.
- Switched from `node-fetch` to native `fetch` API.

---

## 1.7.0 - 2024-09-18

### Fixed
Expand Down
3 changes: 3 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ const config = {
testMatch: ['**/__tests__/**/*.test.ts'],
testPathIgnorePatterns: ['/node_modules/', '/dist/'],
cacheDirectory: process.env.JEST_CACHE_FOLDER || '/tmp/node-sdk/.jest-cache',
moduleNameMapper: {
'(.+)\\.js': '$1',
},
coveragePathIgnorePatterns: [
'/src/types/',
'__tests__',
Expand Down
36 changes: 28 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
{
"name": "@paddle/paddle-node-sdk",
"version": "1.7.0",
"version": "2.0.0-beta.0",
"description": "A Node.js SDK that you can use to integrate Paddle Billing with applications written in server-side JavaScript.",
"main": "./dist/cjs/index.js",
"module": "./dist/esm/index.js",
"types": "./dist/types/index.d.ts",
"main": "dist/cjs/index.cjs.node.js",
"module": "dist/esm/index.esm.node.js",
"types": "dist/types/index.cjs.node.d.ts",
"engines": {
"node": ">=18"
},
"scripts": {
"test": "jest",
"prebuild": "node ./scripts/update-env-vars.js",
"build": "yarn clean && tsc -b ./tsconfig.cjs.json ./tsconfig.esm.json ./tsconfig.types.json",
"build": "yarn clean && yarn build-esm && yarn build-cjs && yarn build-types",
"build-esm": "tsc -b tsconfig.esm.json && echo '{\"type\":\"module\"}' > ./dist/esm/package.json",
"build-cjs": "tsc -b tsconfig.cjs.json && echo '{\"type\":\"commonjs\"}' > ./dist/cjs/package.json",
"build-types": "tsc -b tsconfig.types.json",
"prettier": "prettier --check ./src",
"prettier:fix": "prettier --check ./src --write",
"lint": "eslint --ext .ts,.tsx ./src",
Expand All @@ -28,14 +34,18 @@
"author": "paddle.com",
"license": "Apache-2.0",
"homepage": "https://developer.paddle.com/api-reference/overview",
"repository": {
"type": "git",
"url": "https://github.com/PaddleHQ/paddle-node-sdk.git"
},
"bugs": "https://github.com/PaddleHQ/paddle-node-sdk/issues",
"devDependencies": {
"@babel/core": "^7.23.0",
"@babel/preset-env": "^7.22.20",
"@babel/preset-typescript": "^7.23.0",
"@types/jest": "^29.5.6",
"@types/lodash": "^4.14.202",
"@types/node": "^20.6.0",
"@types/node-fetch": "^2.6.6",
"@typescript-eslint/eslint-plugin": "^6.4.0",
"babel-jest": "^29.7.0",
"dotenv": "^16.3.1",
Expand All @@ -49,7 +59,17 @@
"typescript": "^5.2.2"
},
"dependencies": {
"lodash": "^4.17.21",
"node-fetch": "^2.7.0"
"lodash": "^4.17.21"
},
"exports": {
"types": "./dist/types/index.cjs.node.d.ts",
"worker": {
"import": "./dist/esm/index.esm.edge.js",
"require": "./dist/cjs/index.cjs.edge.js"
},
"default": {
"import": "./dist/esm/index.esm.node.js",
"require": "./dist/cjs/index.cjs.node.js"
}
}
}
4 changes: 2 additions & 2 deletions src/__tests__/helpers/test-client.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Client } from '../../internal/api/client';
import { Environment } from '../../internal';
import { Client } from '../../internal/api/client.js';
import { Environment } from '../../internal/index.js';

export function getPaddleTestClient() {
return new Client('TEST_API_KEY', { environment: Environment.sandbox });
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/internal/logger.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { LogLevel } from '../../internal';
import { Logger } from '../../internal/base/logger';
import { type Response } from 'node-fetch';
import { LogLevel } from '../../internal/index.js';
import { Logger } from '../../internal/base/logger.js';

describe('logger', () => {
afterEach(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/internal/paddle.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Environment, Paddle } from '../../index';
import { Environment, Paddle } from '../../index.cjs.node.js';

describe('Paddle', () => {
test('Paddle class can be constructed', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/mocks/notifications/address-created.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* Changes may be overwritten as part of auto-generation.
*/

import { type IEventsResponse } from '../../../types';
import { IAddressNotificationResponse } from '../../../notifications';
import { type IEventsResponse } from '../../../types/index.js';
import { IAddressNotificationResponse } from '../../../notifications/index.js';

export const AddressCreatedMock: IEventsResponse<IAddressNotificationResponse> = {
event_id: 'evt_01h848pezaj15tkt3dsa36xe59',
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/mocks/notifications/address-imported.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* Changes may be overwritten as part of auto-generation.
*/

import { type IEventsResponse } from '../../../types';
import { IAddressNotificationResponse } from '../../../notifications';
import { IAddressNotificationResponse } from '../../../notifications/index.js';
import { IEventsResponse } from '../../../types/index.js';

export const AddressImportedMock: IEventsResponse<IAddressNotificationResponse> = {
event_id: 'evt_01hhy7cva3jgaez82k6n4n3x4b',
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/mocks/notifications/address-updated.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* Changes may be overwritten as part of auto-generation.
*/

import { type IEventsResponse } from '../../../types';
import { IAddressNotificationResponse } from '../../../notifications';
import { IAddressNotificationResponse } from '../../../notifications/index.js';
import { IEventsResponse } from '../../../types/index.js';

export const AddressUpdatedMock: IEventsResponse<IAddressNotificationResponse> = {
event_id: 'evt_01h849k5rs5jxgctb45s6pmkat',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Changes may be overwritten as part of auto-generation.
*/

import { type IEventsResponse, type IAdjustmentResponse } from '../../../types';
import { IAdjustmentResponse, IEventsResponse } from '../../../types/index.js';

export const AdjustmentCreatedMock: IEventsResponse<IAdjustmentResponse> = {
event_id: 'evt_01h8c6tc8aa58zqj6h8a13r103',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Changes may be overwritten as part of auto-generation.
*/

import { type IEventsResponse, type IAdjustmentResponse } from '../../../types';
import { IAdjustmentResponse, IEventsResponse } from '../../../types/index.js';

export const AdjustmentUpdatedMock: IEventsResponse<IAdjustmentResponse> = {
event_id: 'evt_01h8c6wz4ac017hxdehrgdvpz4',
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/mocks/notifications/business-created.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* Changes may be overwritten as part of auto-generation.
*/

import { type IEventsResponse } from '../../../types';
import { IBusinessNotificationResponse } from '../../../notifications';
import { IBusinessNotificationResponse } from '../../../notifications/index.js';
import { IEventsResponse } from '../../../types/index.js';

export const BusinessCreatedMock: IEventsResponse<IBusinessNotificationResponse> = {
event_id: 'evt_01h84a7j1cpqtrcdqs63ph1pqe',
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/mocks/notifications/business-imported.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* Changes may be overwritten as part of auto-generation.
*/

import { type IEventsResponse } from '../../../types';
import { IBusinessNotificationResponse } from '../../../notifications';
import { IBusinessNotificationResponse } from '../../../notifications/index.js';
import { IEventsResponse } from '../../../types/index.js';

export const BusinessImportedMock: IEventsResponse<IBusinessNotificationResponse> = {
event_id: 'evt_01hhvz7k9kekw1wfxw8v8gbqcy',
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/mocks/notifications/business-updated.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* Changes may be overwritten as part of auto-generation.
*/

import { type IEventsResponse } from '../../../types';
import { IBusinessNotificationResponse } from '../../../notifications';
import { IBusinessNotificationResponse } from '../../../notifications/index.js';
import { IEventsResponse } from '../../../types/index.js';

export const BusinessUpdatedMock: IEventsResponse<IBusinessNotificationResponse> = {
event_id: 'evt_01h84b8sq18asjb0m3tvn4g0dn',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Changes may be overwritten as part of auto-generation.
*/

import { type IEventsResponse, type ICustomerResponse } from '../../../types';
import { ICustomerResponse, IEventsResponse } from '../../../types/index.js';

export const CustomerCreatedMock: IEventsResponse<ICustomerResponse> = {
event_id: 'evt_01h8441jx8x1q971q9ksksqh82',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Changes may be overwritten as part of auto-generation.
*/

import { type IEventsResponse, type ICustomerResponse } from '../../../types';
import { ICustomerResponse, IEventsResponse } from '../../../types/index.js';

export const CustomerImportedMock: IEventsResponse<ICustomerResponse> = {
event_id: 'evt_01hhvz7k8twkw75ez34836tj0x',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Changes may be overwritten as part of auto-generation.
*/

import { type IEventsResponse, type ICustomerResponse } from '../../../types';
import { ICustomerResponse, IEventsResponse } from '../../../types/index.js';

export const CustomerUpdatedMock: IEventsResponse<ICustomerResponse> = {
event_id: 'evt_01h845v9ynfsazmdq3wntb3dzt',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Changes may be overwritten as part of auto-generation.
*/

import { type IEventsResponse, type IDiscountResponse } from '../../../types';
import { IDiscountResponse, IEventsResponse } from '../../../types/index.js';

export const DiscountCreatedMock: IEventsResponse<IDiscountResponse> = {
event_id: 'evt_01h8441jx8x1q971q9ksksqh82',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Changes may be overwritten as part of auto-generation.
*/

import { type IEventsResponse, type IDiscountResponse } from '../../../types';
import { IDiscountResponse, IEventsResponse } from '../../../types/index.js';

export const DiscountImportedMock: IEventsResponse<IDiscountResponse> = {
event_id: 'evt_01hdnnd4x84s4r5br068y3rm6d',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Changes may be overwritten as part of auto-generation.
*/

import { type IEventsResponse, type IDiscountResponse } from '../../../types';
import { IDiscountResponse, IEventsResponse } from '../../../types/index.js';

export const DiscountUpdatedMock: IEventsResponse<IDiscountResponse> = {
event_id: 'evt_01h90nmenze2c4yv1sfnx5ye17',
Expand Down
Loading