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

Release to npm #394

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
5 changes: 0 additions & 5 deletions .changeset/famous-eggs-decide.md

This file was deleted.

8 changes: 0 additions & 8 deletions .changeset/fresh-onions-pretend.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/hip-queens-roll.md

This file was deleted.

9 changes: 0 additions & 9 deletions .changeset/kind-zoos-raise.md

This file was deleted.

47 changes: 0 additions & 47 deletions .changeset/rare-tools-change.md

This file was deleted.

7 changes: 0 additions & 7 deletions .changeset/serious-lamps-rhyme.md

This file was deleted.

92 changes: 0 additions & 92 deletions .changeset/silent-walls-heal.md

This file was deleted.

7 changes: 0 additions & 7 deletions .changeset/sixty-taxis-glow.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/tough-socks-tease.md

This file was deleted.

164 changes: 164 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,169 @@
# @saleor/app-sdk

## 1.0.0

### Major Changes

- 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`

- 9bbaac2: `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"
...
}
```

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

### 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`.

- 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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down