diff --git a/.changeset/famous-eggs-decide.md b/.changeset/famous-eggs-decide.md deleted file mode 100644 index 6af69a4c..00000000 --- a/.changeset/famous-eggs-decide.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@saleor/app-sdk": patch ---- - -Added `author` and `license` fields to `pacakge.json` diff --git a/.changeset/fluffy-ties-stop.md b/.changeset/fluffy-ties-stop.md deleted file mode 100644 index f831b52f..00000000 --- a/.changeset/fluffy-ties-stop.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@saleor/app-sdk": major ---- - -`requiredEnvVars` param was removed trom SaleorApp. Field was not used internally. Apps should validate it's envs. diff --git a/.changeset/fresh-onions-pretend.md b/.changeset/fresh-onions-pretend.md deleted file mode 100644 index dcf20390..00000000 --- a/.changeset/fresh-onions-pretend.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -"@saleor/app-sdk": patch ---- - -Updated project license: it previously used BSD 3-Clause for code and Creative Commons Attribution 4.0 International License for artwork. -Since this project doesn't include any artwork, Creative Commons license was removed. - -Updated `license` field in `package.json`: It incorrectly stated `ISC` license instead of `BSD-3-Clause`. diff --git a/.changeset/great-nails-grab.md b/.changeset/great-nails-grab.md deleted file mode 100644 index 092a07f5..00000000 --- a/.changeset/great-nails-grab.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@saleor/app-sdk": patch ---- - -Updated Typescript diff --git a/.changeset/grumpy-snakes-itch.md b/.changeset/grumpy-snakes-itch.md deleted file mode 100644 index 7bf42c97..00000000 --- a/.changeset/grumpy-snakes-itch.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@saleor/app-sdk": patch ---- - -Updated packages: vite, vitest, raw-body, prettier, tsup, jose diff --git a/.changeset/hip-queens-roll.md b/.changeset/hip-queens-roll.md deleted file mode 100644 index 87eebd74..00000000 --- a/.changeset/hip-queens-roll.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@saleor/app-sdk": major ---- - -Removed `/middlewares`, you should use `/handlers` instead. diff --git a/.changeset/hot-pens-attend.md b/.changeset/hot-pens-attend.md deleted file mode 100644 index f014b108..00000000 --- a/.changeset/hot-pens-attend.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@saleor/app-sdk": patch ---- - -Schema version passed to manifest handler will be string, not float diff --git a/.changeset/kind-zoos-raise.md b/.changeset/kind-zoos-raise.md deleted file mode 100644 index 6e0f67b1..00000000 --- a/.changeset/kind-zoos-raise.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -"@saleor/app-sdk": major ---- - -Removed deprecated fields fields and methods in `/handlers`: - -- `SaleorAsyncWebhook` and `SaleorSyncWebhook` - removed deprecated `asyncEvent` and `subscriptionQueryAst` -- Removed `processSaleorWebhook` and `processProtectedHandler` methods in favor of `SaleorSyncWebhook`, `SaleorAsyncWebhook` classes and `createProtectedHandler` handler -- Some types were moved from `/next` to `/shared` diff --git a/.changeset/long-mirrors-leave.md b/.changeset/long-mirrors-leave.md deleted file mode 100644 index c363320e..00000000 --- a/.changeset/long-mirrors-leave.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -"@saleor/app-sdk": major ---- - -### APL - -- `isReady` and `isConfigured` methods are now optional in the `APL` interface -- All APL implementations are now exported from dedicated paths `@saleor/app-sdk/APL/*` where `*` is one of the implementations. Now tree shaking is available diff --git a/.changeset/many-ghosts-shop.md b/.changeset/many-ghosts-shop.md deleted file mode 100644 index cb01baba..00000000 --- a/.changeset/many-ghosts-shop.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -"@saleor/app-sdk": major ---- - -Generating AppBridge action now uses native web API Crypto. - -- Some older browser may not be working -- Only localhost and https is supported now diff --git a/.changeset/new-paws-win.md b/.changeset/new-paws-win.md deleted file mode 100644 index d6098e0b..00000000 --- a/.changeset/new-paws-win.md +++ /dev/null @@ -1,37 +0,0 @@ ---- -"@saleor/app-sdk": major ---- - -Removed `ctx.buildResponse` parameter from SyncWebhookHandler ctx and replace with standalone `buildSyncWebhookResponsePayload` function - -Before - -```typescript - -new SaleorSyncWebhook(...).createHandler( - req, res, ctx -) { - - const typeSafePayload = ctx.buildResponse({ - // this must be valid response - }) -} -``` - -After - -```typescript -import { buildSyncWebhookResponsePayload } from "@saleor/app-sdk/handlers/shared"; - -new SaleorSyncWebhook(...).createHandler( - req, res, ctx -) -{ - - const typeSafePayload = buildSyncWebhookResponsePayload<"ORDER_CALCULATE_TAXES">({ - // this must be valid shape - }) -} -``` - -This change reduces complexity of TypeScript generics and make it easier to build abstractions on top of built-in handlers diff --git a/.changeset/rare-tools-change.md b/.changeset/rare-tools-change.md deleted file mode 100644 index 2dd56931..00000000 --- a/.changeset/rare-tools-change.md +++ /dev/null @@ -1,47 +0,0 @@ ---- -"@saleor/app-sdk": minor ---- - -Added handlers for Web API: Request and Response - -## Example - -This example uses Next.js app router - -```ts -/* /app/api/manifest/route.ts */ -import { createManifestHandler } from "@saleor/app-sdk/handlers/fetch-api"; -// or -import { createManifestHandler } from "@saleor/app-sdk/handlers/next-app-router"; - -export const GET = createManifestHandler({ - manifestFactory({ appBaseUrl, request }) { - return { - name: "Saleor App Template", - tokenTargetUrl: `${appBaseUrl}/api/register`, - appUrl: appBaseUrl, - permissions: ["MANAGE_ORDERS"], - id: "saleor.app", - version: "0.0.1", - webhooks: [orderCreatedWebhook.getWebhookManifest(apiBaseURL)], - author: "Saleor Commerce", - }; - }, -}); -``` - -```ts -/* /app/api/register/route.ts */ -import { createAppRegisterHandler } from "@saleor/app-sdk/handlers/fetch-api"; - -export const POST = createAppRegisterHandler({ - apl: saleorApp.apl, -}); -``` - -To see more details check these examples: - -- [Hono on Deno Deploy](https://github.com/witoszekdev/saleor-app-hono-deno-template) -- [Hono on Cloudflare Pages](https://github.com/witoszekdev/saleor-app-hono-cf-pages-template) -- [Hono on AWS Lambda](https://github.com/witoszekdev/saleor-app-hono-aws-lambda-template) -- [Next.js Edge Runtime](https://github.com/saleor/saleor-app-template/pull/267) diff --git a/.changeset/serious-lamps-rhyme.md b/.changeset/serious-lamps-rhyme.md deleted file mode 100644 index de19adfe..00000000 --- a/.changeset/serious-lamps-rhyme.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -"@saleor/app-sdk": patch ---- - -Added AWS Lambda platform handlers - -Check [this example on how to use it](https://github.com/witoszekdev/saleor-app-lambda-template). diff --git a/.changeset/sixty-taxis-glow.md b/.changeset/sixty-taxis-glow.md deleted file mode 100644 index 5b1fe5ce..00000000 --- a/.changeset/sixty-taxis-glow.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -"@saleor/app-sdk": minor ---- - -Added abstract `PlatformAdapterInterface` and `ActionHandlerInterface` to enable cross-framework handler implementations. - -Next.js handlers were rewritten to use the new interface. diff --git a/.changeset/smooth-wolves-smell.md b/.changeset/smooth-wolves-smell.md deleted file mode 100644 index ad40d35a..00000000 --- a/.changeset/smooth-wolves-smell.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@saleor/app-sdk": major ---- - -Saleor version that was previously represented as a floating number (eg Saleor 3.20 was represented as 3.2) is now a `SaleorSchemaVersion` which is a tuple `major: number, minor: number`. This format is now passed to Manifest handler and webhooks handler diff --git a/.changeset/tough-socks-tease.md b/.changeset/tough-socks-tease.md deleted file mode 100644 index 7e846506..00000000 --- a/.changeset/tough-socks-tease.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@saleor/app-sdk": major ---- - -Breaking change: SDK will no longer check `saleor-domain` header when validating Saleor requests, instead it will check `saleor-api-url` header. diff --git a/.changeset/twelve-cases-nail.md b/.changeset/twelve-cases-nail.md deleted file mode 100644 index 6ce152ce..00000000 --- a/.changeset/twelve-cases-nail.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@saleor/app-sdk": minor ---- - -Add new exported path "util" with helper methods like parseSchemaVersion diff --git a/CHANGELOG.md b/CHANGELOG.md index 8076d792..6003463e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,131 @@ # @saleor/app-sdk +## 1.0.0 + +### Major Changes + +- 3dfb91c: `requiredEnvVars` param was removed trom SaleorApp. Field was not used internally. Apps should validate it's envs. +- 51caa77: Removed `/middlewares`, you should use `/handlers` instead. +- 51caa77: Removed deprecated fields fields and methods in `/handlers`: + + - `SaleorAsyncWebhook` and `SaleorSyncWebhook` - removed deprecated `asyncEvent` and `subscriptionQueryAst` + - Removed `processSaleorWebhook` and `processProtectedHandler` methods in favor of `SaleorSyncWebhook`, `SaleorAsyncWebhook` classes and `createProtectedHandler` handler + - Some types were moved from `/next` to `/shared` + +- a915771: ### APL + + - `isReady` and `isConfigured` methods are now optional in the `APL` interface + - All APL implementations are now exported from dedicated paths `@saleor/app-sdk/APL/*` where `*` is one of the implementations. Now tree shaking is available + +- 126493d: Generating AppBridge action now uses native web API Crypto. + + - Some older browser may not be working + - Only localhost and https is supported now + +- 5b0f7a8: Removed `ctx.buildResponse` parameter from SyncWebhookHandler ctx and replace with standalone `buildSyncWebhookResponsePayload` function + + Before + + ```typescript + + new SaleorSyncWebhook(...).createHandler( + req, res, ctx + ) { + + const typeSafePayload = ctx.buildResponse({ + // this must be valid response + }) + } + ``` + + After + + ```typescript + import { buildSyncWebhookResponsePayload } from "@saleor/app-sdk/handlers/shared"; + + new SaleorSyncWebhook(...).createHandler( + req, res, ctx + ) + { + + const typeSafePayload = buildSyncWebhookResponsePayload<"ORDER_CALCULATE_TAXES">({ + // this must be valid shape + }) + } + ``` + + This change reduces complexity of TypeScript generics and make it easier to build abstractions on top of built-in handlers + +- 3dfb91c: Saleor version that was previously represented as a floating number (eg Saleor 3.20 was represented as 3.2) is now a `SaleorSchemaVersion` which is a tuple `major: number, minor: number`. This format is now passed to Manifest handler and webhooks handler +- c956220: Breaking change: SDK will no longer check `saleor-domain` header when validating Saleor requests, instead it will check `saleor-api-url` header. + +### Minor Changes + +- 4fa8271: Added handlers for Web API: Request and Response + + ## Example + + This example uses Next.js app router + + ```ts + /* /app/api/manifest/route.ts */ + import { createManifestHandler } from "@saleor/app-sdk/handlers/fetch-api"; + // or + import { createManifestHandler } from "@saleor/app-sdk/handlers/next-app-router"; + + export const GET = createManifestHandler({ + manifestFactory({ appBaseUrl, request }) { + return { + name: "Saleor App Template", + tokenTargetUrl: `${appBaseUrl}/api/register`, + appUrl: appBaseUrl, + permissions: ["MANAGE_ORDERS"], + id: "saleor.app", + version: "0.0.1", + webhooks: [orderCreatedWebhook.getWebhookManifest(apiBaseURL)], + author: "Saleor Commerce", + }; + }, + }); + ``` + + ```ts + /* /app/api/register/route.ts */ + import { createAppRegisterHandler } from "@saleor/app-sdk/handlers/fetch-api"; + + export const POST = createAppRegisterHandler({ + apl: saleorApp.apl, + }); + ``` + + To see more details check these examples: + + - [Hono on Deno Deploy](https://github.com/witoszekdev/saleor-app-hono-deno-template) + - [Hono on Cloudflare Pages](https://github.com/witoszekdev/saleor-app-hono-cf-pages-template) + - [Hono on AWS Lambda](https://github.com/witoszekdev/saleor-app-hono-aws-lambda-template) + - [Next.js Edge Runtime](https://github.com/saleor/saleor-app-template/pull/267) + +- 51caa77: Added abstract `PlatformAdapterInterface` and `ActionHandlerInterface` to enable cross-framework handler implementations. + + Next.js handlers were rewritten to use the new interface. + +- 5e4eb20: Add new exported path "util" with helper methods like parseSchemaVersion + +### Patch Changes + +- 003b1ca: Added `author` and `license` fields to `pacakge.json` +- 003b1ca: Updated project license: it previously used BSD 3-Clause for code and Creative Commons Attribution 4.0 International License for artwork. + Since this project doesn't include any artwork, Creative Commons license was removed. + + Updated `license` field in `package.json`: It incorrectly stated `ISC` license instead of `BSD-3-Clause`. + +- 8f6b437: Updated Typescript +- 0a917ac: Updated packages: vite, vitest, raw-body, prettier, tsup, jose +- 5fb68e6: Schema version passed to manifest handler will be string, not float +- 853abaa: Added AWS Lambda platform handlers + + Check [this example on how to use it](https://github.com/witoszekdev/saleor-app-lambda-template). + ## 0.52.0 ### Minor Changes diff --git a/package.json b/package.json index 820bcc05..ebff2ee5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@saleor/app-sdk", - "version": "0.52.0", + "version": "1.0.0", "description": "SDK for building great Saleor Apps", "scripts": { "prepublishOnly": "pnpm build",