Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .changeset/hip-queens-roll.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
"@saleor/app-sdk": patch
"@saleor/app-sdk": major
---

Removed `/middlewares`, you should use `/handlers` instead.
4 changes: 2 additions & 2 deletions .changeset/kind-zoos-raise.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

Removed deprecated fields fields and methods in `/handlers`:

- `SaleorAsyncWebhook` and `SaleorSyncWebhook` - removed `asyncEvent` and `subscriptionQueryAst`
- Removed `processSaleorWebhook` and `processProtectedHandler` methods
- `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`
42 changes: 42 additions & 0 deletions .changeset/rare-tools-change.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,45 @@
---

Added handlers for Web API: Request and Response

## Example

This example uses Next.js app router

```ts
/* /app/api/manifest/route.ts */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: can you add imports as well for createManifestHandler and createAppRegisterHandler

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)
2 changes: 2 additions & 0 deletions .changeset/serious-lamps-rhyme.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
---

Added AWS Lambda platform handlers

Check [this example on how to use it](https://github.com/witoszekdev/saleor-app-lambda-template).
92 changes: 92 additions & 0 deletions .changeset/silent-walls-heal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
---
"@saleor/app-sdk": major
---

`createManifestHandler` will now require `saleor-schema-version` header, sent by Saleor when fetching manifest.
`schemaVersion` parameter passed to factory method will be always defined

### Previously:

```ts
const handler = createManifestHandler({
manifestFactory({ schemaVersion }) {
schemaVersion -> null or number
return {
// ...
}
}
})
```

Example request:

```http
GET /api/manifest
host: my-app.com
```

```http
GET /api/manifest
host: my-app.com
saleor-schema-version: 3.20
```

Example response:

```http
Content-Type: application/json

{
"name": "Example Saleor App"
...
}
```

### Now:

```ts
const handler = createManifestHandler({
manifestFactory({ schemaVersion }) {
schemaVersion -> number
return {
// ...
}
}
})
```

### Invalid request

```http
GET /api/manifest
host: my-app.com
```

Response:

```http
HTTP 400
Content-Type: text/plain

Missing schema version header
```

### Valid request

```http
GET /api/manifest
host: my-app.com
saleor-schema-version: 3.20
```

Response:

```http
HTTP 200
Content-Type: application/json

{
"name": "Example Saleor App"
...
}
```
2 changes: 1 addition & 1 deletion .changeset/sixty-taxis-glow.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
"@saleor/app-sdk": patch
"@saleor/app-sdk": minor
---

Added abstract `PlatformAdapterInterface` and `ActionHandlerInterface` to enable cross-framework handler implementations.
Expand Down