From 3c68c4c71a05ceb67860062134e7fa9ac0d75258 Mon Sep 17 00:00:00 2001 From: Lukasz Ostrowski Date: Wed, 29 Nov 2023 18:26:36 +0100 Subject: [PATCH] Add missing permissions to typings (#302) --- .changeset/happy-seahorses-check.md | 5 ++ .changeset/proud-llamas-push.md | 5 ++ .changeset/thirty-doors-kneel.md | 5 ++ package.json | 2 +- pnpm-lock.yaml | 6 +- .../sync-webhook-response-builder.ts | 71 +++++++++++++++++++ src/types.ts | 8 ++- 7 files changed, 99 insertions(+), 3 deletions(-) create mode 100644 .changeset/happy-seahorses-check.md create mode 100644 .changeset/proud-llamas-push.md create mode 100644 .changeset/thirty-doors-kneel.md diff --git a/.changeset/happy-seahorses-check.md b/.changeset/happy-seahorses-check.md new file mode 100644 index 00000000..30211400 --- /dev/null +++ b/.changeset/happy-seahorses-check.md @@ -0,0 +1,5 @@ +--- +"@saleor/app-sdk": minor +--- + +Added definition for payment and transaction events. From now on, sync webhook factory will autocomplete response expected by Saleor diff --git a/.changeset/proud-llamas-push.md b/.changeset/proud-llamas-push.md new file mode 100644 index 00000000..97465c26 --- /dev/null +++ b/.changeset/proud-llamas-push.md @@ -0,0 +1,5 @@ +--- +"@saleor/app-sdk": minor +--- + +Added new permission - MANAGE_ORDERS_IMPORT - to Permission type diff --git a/.changeset/thirty-doors-kneel.md b/.changeset/thirty-doors-kneel.md new file mode 100644 index 00000000..4ee7d3ea --- /dev/null +++ b/.changeset/thirty-doors-kneel.md @@ -0,0 +1,5 @@ +--- +"@saleor/app-sdk": minor +--- + +Added missing payment transactions sync events diff --git a/package.json b/package.json index 87a9e6ab..6e74b3c8 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ "react-dom": "18.2.0", "tsm": "^2.2.2", "tsup": "^6.2.3", - "typescript": "^4.9.5", + "typescript": "4.9.5", "vi-fetch": "^0.8.0", "vite": "^4.0.4", "vitest": "^0.28.1" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8a68407d..50f57444 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,5 +1,9 @@ lockfileVersion: '6.0' +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false + dependencies: debug: specifier: 4.3.4 @@ -118,7 +122,7 @@ devDependencies: specifier: ^6.2.3 version: 6.2.3(typescript@4.9.5) typescript: - specifier: ^4.9.5 + specifier: 4.9.5 version: 4.9.5 vi-fetch: specifier: ^0.8.0 diff --git a/src/handlers/next/saleor-webhooks/sync-webhook-response-builder.ts b/src/handlers/next/saleor-webhooks/sync-webhook-response-builder.ts index 38d29691..952e0cb7 100644 --- a/src/handlers/next/saleor-webhooks/sync-webhook-response-builder.ts +++ b/src/handlers/next/saleor-webhooks/sync-webhook-response-builder.ts @@ -90,6 +90,77 @@ export type SyncWebhookResponsesMap = { externalUrl?: string; message?: string; }; + PAYMENT_METHOD_PROCESS_TOKENIZATION_SESSION: + | { + result: "SUCCESSFULLY_TOKENIZED"; + id: string; + data: unknown; + } + | { + result: "ADDITIONAL_ACTION_REQUIRED"; + id: string; + data: unknown; + } + | { + result: "PENDING"; + data: unknown; + } + | { + result: "FAILED_TO_TOKENIZE"; + error: string; + }; + PAYMENT_METHOD_INITIALIZE_TOKENIZATION_SESSION: + | { + result: "SUCCESSFULLY_TOKENIZED"; + id: string; + data: unknown; + } + | { + result: "ADDITIONAL_ACTION_REQUIRED"; + id: string; + data: unknown; + } + | { + result: "PENDING"; + data: unknown; + } + | { + result: "FAILED_TO_TOKENIZE"; + error: string; + }; + PAYMENT_GATEWAY_INITIALIZE_TOKENIZATION_SESSION: + | { + result: "SUCCESSFULLY_INITIALIZED"; + data: unknown; + } + | { + result: "FAILED_TO_INITIALIZE"; + error: string; + }; + STORED_PAYMENT_METHOD_DELETE_REQUESTED: + | { + result: "SUCCESSFULLY_DELETED"; + } + | { + result: "FAILED_TO_DELETE"; + error: string; + }; + LIST_STORED_PAYMENT_METHODS: { + paymentMethods: Array<{ + id: string; + supportedPaymentFlows: Array<"INTERACTIVE">; + type: string; + creditCardInfo?: { + brand: string; + lastDigits: string; + expMonth: string; + expYear: string; + firstDigits?: string; + }; + name?: string; + data?: unknown; + }>; + }; }; /** diff --git a/src/types.ts b/src/types.ts index 927d108d..a93c7c2e 100644 --- a/src/types.ts +++ b/src/types.ts @@ -32,6 +32,7 @@ export type Permission = | "MANAGE_GIFT_CARD" | "MANAGE_MENUS" | "MANAGE_ORDERS" + | "MANAGE_ORDERS_IMPORT" | "MANAGE_PAGES" | "MANAGE_PAGE_TYPES_AND_ATTRIBUTES" | "HANDLE_PAYMENTS" @@ -187,7 +188,12 @@ export type SyncWebhookEventType = | "TRANSACTION_CANCELATION_REQUESTED" | "PAYMENT_GATEWAY_INITIALIZE_SESSION" | "TRANSACTION_INITIALIZE_SESSION" - | "TRANSACTION_PROCESS_SESSION"; + | "TRANSACTION_PROCESS_SESSION" + | "LIST_STORED_PAYMENT_METHODS" + | "STORED_PAYMENT_METHOD_DELETE_REQUESTED" + | "PAYMENT_GATEWAY_INITIALIZE_TOKENIZATION_SESSION" + | "PAYMENT_METHOD_INITIALIZE_TOKENIZATION_SESSION" + | "PAYMENT_METHOD_PROCESS_TOKENIZATION_SESSION"; export interface AppExtension { /** Name which will be displayed in the dashboard */