Skip to content

Commit

Permalink
v2.0.0-rc.0 - Edge runtime support and more. (#45)
Browse files Browse the repository at this point in the history
## 2.0.0-rc.0 - 2024-09-26

> **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.

---
  • Loading branch information
vijayasingam-paddle authored Sep 26, 2024
1 parent 2b65e10 commit 0f73f54
Show file tree
Hide file tree
Showing 562 changed files with 2,402 additions and 1,997 deletions.
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:
- "*"
14 changes: 8 additions & 6 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ on:
push:
branches:
- main
- v1.X
- v1.x
- release/beta
pull_request:
branches:
- main
- v1.X
- v1.x
- release/beta

concurrency:
Expand All @@ -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
8 changes: 4 additions & 4 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ on:
push:
branches:
- main
- v1.X
- v1.x
- release/beta
pull_request:
branches:
- main
- v1.X
- v1.x
- release/beta

concurrency:
Expand All @@ -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.

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" =~ (rc) ]]; then
yarn publish:rc
else
yarn publish:latest
fi
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
1 change: 1 addition & 0 deletions .github/workflows/release-on-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- main
- v1.x

jobs:
release_on_push:
Expand Down
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-rc.0 - 2024-09-26

> **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
17 changes: 17 additions & 0 deletions UPGRADING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Upgrading

All breaking changes will be documented in this file to assist with upgrading to newer versions of the SDK.

## v2.0.0

There are two breaking changes in this release:

1. Minimum Node.js version is now 18.0.0.
- We had to restrict the minimum version as we would like to use native `fetch` API instead of `node-fetch` package.
- If you are using Node.js version 16 or below, you will need to upgrade to Node.js version 18 or above.

2. `Webhooks.unmarshal` and `Webhooks.isSignatureValid` now returns a promise.
- As we started supporting edge runtimes, we had to make these methods async as the edge version of crypto returns a promise.
- If you are using these methods, you will need to update your code to handle the promise.

---
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
40 changes: 30 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
{
"name": "@paddle/paddle-node-sdk",
"version": "1.7.0",
"version": "2.0.0-rc.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",
"lint:fix": "eslint --ext .ts,.tsx ./src --fix",
"clean": "rm -rf ./dist",
"release:beta": "yarn version --prerelease --preid beta --no-git-tag-version --no-commit-hooks",
"publish:beta": "yarn publish --tag beta --access public",
"release:rc": "yarn version --prerelease --preid rc --no-git-tag-version --no-commit-hooks",
"publish:beta": "yarn publish --tag rc --access public",
"publish:latest": "yarn publish --access public"
},
"files": [
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
Loading

0 comments on commit 0f73f54

Please sign in to comment.