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.

5 changes: 0 additions & 5 deletions .changeset/fluffy-ties-stop.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/great-nails-grab.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/grumpy-snakes-itch.md

This file was deleted.

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

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/hot-pens-attend.md

This file was deleted.

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

This file was deleted.

8 changes: 0 additions & 8 deletions .changeset/long-mirrors-leave.md

This file was deleted.

8 changes: 0 additions & 8 deletions .changeset/many-ghosts-shop.md

This file was deleted.

37 changes: 0 additions & 37 deletions .changeset/new-paws-win.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.

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

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/smooth-wolves-smell.md

This file was deleted.

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

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/twelve-cases-nail.md

This file was deleted.

126 changes: 126 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
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