From d4d092ee54f84784c04ad7a397b251ba3bd14a5f Mon Sep 17 00:00:00 2001 From: Lukasz Ostrowski Date: Fri, 17 Nov 2023 09:55:25 +0100 Subject: [PATCH 1/5] Add MANAGE_ORDERS_IMPORT permission to types --- .changeset/proud-llamas-push.md | 5 +++++ src/types.ts | 1 + 2 files changed, 6 insertions(+) create mode 100644 .changeset/proud-llamas-push.md 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/src/types.ts b/src/types.ts index 927d108d..516eb5a5 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" From 8a2f414f208055a1a15f0d156c5956e94093fb94 Mon Sep 17 00:00:00 2001 From: Lukasz Ostrowski Date: Fri, 17 Nov 2023 10:10:29 +0100 Subject: [PATCH 2/5] add transactions events --- .changeset/thirty-doors-kneel.md | 5 +++++ src/types.ts | 14 +++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 .changeset/thirty-doors-kneel.md 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/src/types.ts b/src/types.ts index 516eb5a5..6c91dfee 100644 --- a/src/types.ts +++ b/src/types.ts @@ -188,7 +188,19 @@ export type SyncWebhookEventType = | "TRANSACTION_CANCELATION_REQUESTED" | "PAYMENT_GATEWAY_INITIALIZE_SESSION" | "TRANSACTION_INITIALIZE_SESSION" - | "TRANSACTION_PROCESS_SESSION"; + | "TRANSACTION_PROCESS_SESSION" + | "PAYMENT_AUTHORIZE" + | "PAYMENT_CAPTURE" + | "PAYMENT_CONFIRM" + | "PAYMENT_LIST_GATEWAYS" + | "PAYMENT_PROCESS" + | "PAYMENT_REFUND" + | "PAYMENT_VOID" + | "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 */ From f60df04819fe6c16cdf81dc0e1d858aa632a8877 Mon Sep 17 00:00:00 2001 From: Lukasz Ostrowski Date: Fri, 17 Nov 2023 10:23:28 +0100 Subject: [PATCH 3/5] fixing types --- package.json | 2 +- pnpm-lock.yaml | 70 ++++++++++--------- .../sync-webhook-response-builder.ts | 3 +- 3 files changed, 40 insertions(+), 35 deletions(-) diff --git a/package.json b/package.json index 87a9e6ab..9654847f 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": "5.2.2", "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..0c2aae54 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 @@ -44,10 +48,10 @@ devDependencies: version: 8.3.4 '@typescript-eslint/eslint-plugin': specifier: ^5.36.1 - version: 5.36.1(@typescript-eslint/parser@5.36.1)(eslint@8.23.0)(typescript@4.9.5) + version: 5.36.1(@typescript-eslint/parser@5.36.1)(eslint@8.23.0)(typescript@5.2.2) '@typescript-eslint/parser': specifier: ^5.36.1 - version: 5.36.1(eslint@8.23.0)(typescript@4.9.5) + version: 5.36.1(eslint@8.23.0)(typescript@5.2.2) '@vitejs/plugin-react': specifier: ^3.0.1 version: 3.0.1(vite@4.0.5) @@ -116,10 +120,10 @@ devDependencies: version: 2.2.2 tsup: specifier: ^6.2.3 - version: 6.2.3(typescript@4.9.5) + version: 6.2.3(typescript@5.2.2) typescript: - specifier: ^4.9.5 - version: 4.9.5 + specifier: 5.2.2 + version: 5.2.2 vi-fetch: specifier: ^0.8.0 version: 0.8.0 @@ -1180,7 +1184,7 @@ packages: resolution: {integrity: sha512-c/I8ZRb51j+pYGAu5CrFMRxqZ2ke4y2grEBO5AUjgSkSk+qT2Ea+OdWElz/OiMf5MNpn2b17kuVBwZLQJXzihw==} dev: true - /@typescript-eslint/eslint-plugin@5.36.1(@typescript-eslint/parser@5.36.1)(eslint@8.23.0)(typescript@4.9.5): + /@typescript-eslint/eslint-plugin@5.36.1(@typescript-eslint/parser@5.36.1)(eslint@8.23.0)(typescript@5.2.2): resolution: {integrity: sha512-iC40UK8q1tMepSDwiLbTbMXKDxzNy+4TfPWgIL661Ym0sD42vRcQU93IsZIrmi+x292DBr60UI/gSwfdVYexCA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -1191,23 +1195,23 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/parser': 5.36.1(eslint@8.23.0)(typescript@4.9.5) + '@typescript-eslint/parser': 5.36.1(eslint@8.23.0)(typescript@5.2.2) '@typescript-eslint/scope-manager': 5.36.1 - '@typescript-eslint/type-utils': 5.36.1(eslint@8.23.0)(typescript@4.9.5) - '@typescript-eslint/utils': 5.36.1(eslint@8.23.0)(typescript@4.9.5) + '@typescript-eslint/type-utils': 5.36.1(eslint@8.23.0)(typescript@5.2.2) + '@typescript-eslint/utils': 5.36.1(eslint@8.23.0)(typescript@5.2.2) debug: 4.3.4 eslint: 8.23.0 functional-red-black-tree: 1.0.1 ignore: 5.2.0 regexpp: 3.2.0 semver: 7.5.4 - tsutils: 3.21.0(typescript@4.9.5) - typescript: 4.9.5 + tsutils: 3.21.0(typescript@5.2.2) + typescript: 5.2.2 transitivePeerDependencies: - supports-color dev: true - /@typescript-eslint/parser@5.36.1(eslint@8.23.0)(typescript@4.9.5): + /@typescript-eslint/parser@5.36.1(eslint@8.23.0)(typescript@5.2.2): resolution: {integrity: sha512-/IsgNGOkBi7CuDfUbwt1eOqUXF9WGVBW9dwEe1pi+L32XrTsZIgmDFIi2RxjzsvB/8i+MIf5JIoTEH8LOZ368A==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -1219,10 +1223,10 @@ packages: dependencies: '@typescript-eslint/scope-manager': 5.36.1 '@typescript-eslint/types': 5.36.1 - '@typescript-eslint/typescript-estree': 5.36.1(typescript@4.9.5) + '@typescript-eslint/typescript-estree': 5.36.1(typescript@5.2.2) debug: 4.3.4 eslint: 8.23.0 - typescript: 4.9.5 + typescript: 5.2.2 transitivePeerDependencies: - supports-color dev: true @@ -1235,7 +1239,7 @@ packages: '@typescript-eslint/visitor-keys': 5.36.1 dev: true - /@typescript-eslint/type-utils@5.36.1(eslint@8.23.0)(typescript@4.9.5): + /@typescript-eslint/type-utils@5.36.1(eslint@8.23.0)(typescript@5.2.2): resolution: {integrity: sha512-xfZhfmoQT6m3lmlqDvDzv9TiCYdw22cdj06xY0obSznBsT///GK5IEZQdGliXpAOaRL34o8phEvXzEo/VJx13Q==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -1245,12 +1249,12 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/typescript-estree': 5.36.1(typescript@4.9.5) - '@typescript-eslint/utils': 5.36.1(eslint@8.23.0)(typescript@4.9.5) + '@typescript-eslint/typescript-estree': 5.36.1(typescript@5.2.2) + '@typescript-eslint/utils': 5.36.1(eslint@8.23.0)(typescript@5.2.2) debug: 4.3.4 eslint: 8.23.0 - tsutils: 3.21.0(typescript@4.9.5) - typescript: 4.9.5 + tsutils: 3.21.0(typescript@5.2.2) + typescript: 5.2.2 transitivePeerDependencies: - supports-color dev: true @@ -1260,7 +1264,7 @@ packages: engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: true - /@typescript-eslint/typescript-estree@5.36.1(typescript@4.9.5): + /@typescript-eslint/typescript-estree@5.36.1(typescript@5.2.2): resolution: {integrity: sha512-ih7V52zvHdiX6WcPjsOdmADhYMDN15SylWRZrT2OMy80wzKbc79n8wFW0xpWpU0x3VpBz/oDgTm2xwDAnFTl+g==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -1275,13 +1279,13 @@ packages: globby: 11.1.0 is-glob: 4.0.3 semver: 7.5.4 - tsutils: 3.21.0(typescript@4.9.5) - typescript: 4.9.5 + tsutils: 3.21.0(typescript@5.2.2) + typescript: 5.2.2 transitivePeerDependencies: - supports-color dev: true - /@typescript-eslint/utils@5.36.1(eslint@8.23.0)(typescript@4.9.5): + /@typescript-eslint/utils@5.36.1(eslint@8.23.0)(typescript@5.2.2): resolution: {integrity: sha512-lNj4FtTiXm5c+u0pUehozaUWhh7UYKnwryku0nxJlYUEWetyG92uw2pr+2Iy4M/u0ONMKzfrx7AsGBTCzORmIg==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -1290,7 +1294,7 @@ packages: '@types/json-schema': 7.0.11 '@typescript-eslint/scope-manager': 5.36.1 '@typescript-eslint/types': 5.36.1 - '@typescript-eslint/typescript-estree': 5.36.1(typescript@4.9.5) + '@typescript-eslint/typescript-estree': 5.36.1(typescript@5.2.2) eslint: 8.23.0 eslint-scope: 5.1.1 eslint-utils: 3.0.0(eslint@8.23.0) @@ -2776,7 +2780,7 @@ packages: eslint-import-resolver-webpack: optional: true dependencies: - '@typescript-eslint/parser': 5.36.1(eslint@8.23.0)(typescript@4.9.5) + '@typescript-eslint/parser': 5.36.1(eslint@8.23.0)(typescript@5.2.2) debug: 3.2.7 eslint: 8.23.0 eslint-import-resolver-node: 0.3.6 @@ -2795,7 +2799,7 @@ packages: '@typescript-eslint/parser': optional: true dependencies: - '@typescript-eslint/parser': 5.36.1(eslint@8.23.0)(typescript@4.9.5) + '@typescript-eslint/parser': 5.36.1(eslint@8.23.0)(typescript@5.2.2) array-includes: 3.1.5 array.prototype.flat: 1.3.0 debug: 2.6.9 @@ -5429,7 +5433,7 @@ packages: esbuild: 0.14.54 dev: true - /tsup@6.2.3(typescript@4.9.5): + /tsup@6.2.3(typescript@5.2.2): resolution: {integrity: sha512-J5Pu2Dx0E1wlpIEsVFv9ryzP1pZ1OYsJ2cBHZ7GrKteytNdzaSz5hmLX7/nAxtypq+jVkVvA79d7S83ETgHQ5w==} engines: {node: '>=14'} hasBin: true @@ -5459,20 +5463,20 @@ packages: source-map: 0.8.0-beta.0 sucrase: 3.25.0 tree-kill: 1.2.2 - typescript: 4.9.5 + typescript: 5.2.2 transitivePeerDependencies: - supports-color - ts-node dev: true - /tsutils@3.21.0(typescript@4.9.5): + /tsutils@3.21.0(typescript@5.2.2): resolution: {integrity: sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==} engines: {node: '>= 6'} peerDependencies: typescript: '>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta' dependencies: tslib: 1.14.1 - typescript: 4.9.5 + typescript: 5.2.2 dev: true /tty-table@4.1.6: @@ -5541,9 +5545,9 @@ packages: mime-types: 2.1.35 dev: true - /typescript@4.9.5: - resolution: {integrity: sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==} - engines: {node: '>=4.2.0'} + /typescript@5.2.2: + resolution: {integrity: sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==} + engines: {node: '>=14.17'} hasBin: true dev: true 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..496f91a9 100644 --- a/src/handlers/next/saleor-webhooks/sync-webhook-response-builder.ts +++ b/src/handlers/next/saleor-webhooks/sync-webhook-response-builder.ts @@ -90,7 +90,8 @@ export type SyncWebhookResponsesMap = { externalUrl?: string; message?: string; }; -}; + +} satisfies Record /** * Identity function, but it works on Typescript level to pick right payload based on first param From ee54e20cf4558abef85e0d67a43700e09f49ed36 Mon Sep 17 00:00:00 2001 From: Lukasz Ostrowski Date: Sat, 18 Nov 2023 10:44:31 +0100 Subject: [PATCH 4/5] Add missing sync events payload definitions --- .changeset/happy-seahorses-check.md | 5 + package.json | 2 +- pnpm-lock.yaml | 66 +++++----- .../sync-webhook-response-builder.ts | 122 +++++++++++++++++- 4 files changed, 159 insertions(+), 36 deletions(-) create mode 100644 .changeset/happy-seahorses-check.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/package.json b/package.json index 9654847f..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": "5.2.2", + "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 0c2aae54..50f57444 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -48,10 +48,10 @@ devDependencies: version: 8.3.4 '@typescript-eslint/eslint-plugin': specifier: ^5.36.1 - version: 5.36.1(@typescript-eslint/parser@5.36.1)(eslint@8.23.0)(typescript@5.2.2) + version: 5.36.1(@typescript-eslint/parser@5.36.1)(eslint@8.23.0)(typescript@4.9.5) '@typescript-eslint/parser': specifier: ^5.36.1 - version: 5.36.1(eslint@8.23.0)(typescript@5.2.2) + version: 5.36.1(eslint@8.23.0)(typescript@4.9.5) '@vitejs/plugin-react': specifier: ^3.0.1 version: 3.0.1(vite@4.0.5) @@ -120,10 +120,10 @@ devDependencies: version: 2.2.2 tsup: specifier: ^6.2.3 - version: 6.2.3(typescript@5.2.2) + version: 6.2.3(typescript@4.9.5) typescript: - specifier: 5.2.2 - version: 5.2.2 + specifier: 4.9.5 + version: 4.9.5 vi-fetch: specifier: ^0.8.0 version: 0.8.0 @@ -1184,7 +1184,7 @@ packages: resolution: {integrity: sha512-c/I8ZRb51j+pYGAu5CrFMRxqZ2ke4y2grEBO5AUjgSkSk+qT2Ea+OdWElz/OiMf5MNpn2b17kuVBwZLQJXzihw==} dev: true - /@typescript-eslint/eslint-plugin@5.36.1(@typescript-eslint/parser@5.36.1)(eslint@8.23.0)(typescript@5.2.2): + /@typescript-eslint/eslint-plugin@5.36.1(@typescript-eslint/parser@5.36.1)(eslint@8.23.0)(typescript@4.9.5): resolution: {integrity: sha512-iC40UK8q1tMepSDwiLbTbMXKDxzNy+4TfPWgIL661Ym0sD42vRcQU93IsZIrmi+x292DBr60UI/gSwfdVYexCA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -1195,23 +1195,23 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/parser': 5.36.1(eslint@8.23.0)(typescript@5.2.2) + '@typescript-eslint/parser': 5.36.1(eslint@8.23.0)(typescript@4.9.5) '@typescript-eslint/scope-manager': 5.36.1 - '@typescript-eslint/type-utils': 5.36.1(eslint@8.23.0)(typescript@5.2.2) - '@typescript-eslint/utils': 5.36.1(eslint@8.23.0)(typescript@5.2.2) + '@typescript-eslint/type-utils': 5.36.1(eslint@8.23.0)(typescript@4.9.5) + '@typescript-eslint/utils': 5.36.1(eslint@8.23.0)(typescript@4.9.5) debug: 4.3.4 eslint: 8.23.0 functional-red-black-tree: 1.0.1 ignore: 5.2.0 regexpp: 3.2.0 semver: 7.5.4 - tsutils: 3.21.0(typescript@5.2.2) - typescript: 5.2.2 + tsutils: 3.21.0(typescript@4.9.5) + typescript: 4.9.5 transitivePeerDependencies: - supports-color dev: true - /@typescript-eslint/parser@5.36.1(eslint@8.23.0)(typescript@5.2.2): + /@typescript-eslint/parser@5.36.1(eslint@8.23.0)(typescript@4.9.5): resolution: {integrity: sha512-/IsgNGOkBi7CuDfUbwt1eOqUXF9WGVBW9dwEe1pi+L32XrTsZIgmDFIi2RxjzsvB/8i+MIf5JIoTEH8LOZ368A==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -1223,10 +1223,10 @@ packages: dependencies: '@typescript-eslint/scope-manager': 5.36.1 '@typescript-eslint/types': 5.36.1 - '@typescript-eslint/typescript-estree': 5.36.1(typescript@5.2.2) + '@typescript-eslint/typescript-estree': 5.36.1(typescript@4.9.5) debug: 4.3.4 eslint: 8.23.0 - typescript: 5.2.2 + typescript: 4.9.5 transitivePeerDependencies: - supports-color dev: true @@ -1239,7 +1239,7 @@ packages: '@typescript-eslint/visitor-keys': 5.36.1 dev: true - /@typescript-eslint/type-utils@5.36.1(eslint@8.23.0)(typescript@5.2.2): + /@typescript-eslint/type-utils@5.36.1(eslint@8.23.0)(typescript@4.9.5): resolution: {integrity: sha512-xfZhfmoQT6m3lmlqDvDzv9TiCYdw22cdj06xY0obSznBsT///GK5IEZQdGliXpAOaRL34o8phEvXzEo/VJx13Q==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -1249,12 +1249,12 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/typescript-estree': 5.36.1(typescript@5.2.2) - '@typescript-eslint/utils': 5.36.1(eslint@8.23.0)(typescript@5.2.2) + '@typescript-eslint/typescript-estree': 5.36.1(typescript@4.9.5) + '@typescript-eslint/utils': 5.36.1(eslint@8.23.0)(typescript@4.9.5) debug: 4.3.4 eslint: 8.23.0 - tsutils: 3.21.0(typescript@5.2.2) - typescript: 5.2.2 + tsutils: 3.21.0(typescript@4.9.5) + typescript: 4.9.5 transitivePeerDependencies: - supports-color dev: true @@ -1264,7 +1264,7 @@ packages: engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: true - /@typescript-eslint/typescript-estree@5.36.1(typescript@5.2.2): + /@typescript-eslint/typescript-estree@5.36.1(typescript@4.9.5): resolution: {integrity: sha512-ih7V52zvHdiX6WcPjsOdmADhYMDN15SylWRZrT2OMy80wzKbc79n8wFW0xpWpU0x3VpBz/oDgTm2xwDAnFTl+g==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -1279,13 +1279,13 @@ packages: globby: 11.1.0 is-glob: 4.0.3 semver: 7.5.4 - tsutils: 3.21.0(typescript@5.2.2) - typescript: 5.2.2 + tsutils: 3.21.0(typescript@4.9.5) + typescript: 4.9.5 transitivePeerDependencies: - supports-color dev: true - /@typescript-eslint/utils@5.36.1(eslint@8.23.0)(typescript@5.2.2): + /@typescript-eslint/utils@5.36.1(eslint@8.23.0)(typescript@4.9.5): resolution: {integrity: sha512-lNj4FtTiXm5c+u0pUehozaUWhh7UYKnwryku0nxJlYUEWetyG92uw2pr+2Iy4M/u0ONMKzfrx7AsGBTCzORmIg==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -1294,7 +1294,7 @@ packages: '@types/json-schema': 7.0.11 '@typescript-eslint/scope-manager': 5.36.1 '@typescript-eslint/types': 5.36.1 - '@typescript-eslint/typescript-estree': 5.36.1(typescript@5.2.2) + '@typescript-eslint/typescript-estree': 5.36.1(typescript@4.9.5) eslint: 8.23.0 eslint-scope: 5.1.1 eslint-utils: 3.0.0(eslint@8.23.0) @@ -2780,7 +2780,7 @@ packages: eslint-import-resolver-webpack: optional: true dependencies: - '@typescript-eslint/parser': 5.36.1(eslint@8.23.0)(typescript@5.2.2) + '@typescript-eslint/parser': 5.36.1(eslint@8.23.0)(typescript@4.9.5) debug: 3.2.7 eslint: 8.23.0 eslint-import-resolver-node: 0.3.6 @@ -2799,7 +2799,7 @@ packages: '@typescript-eslint/parser': optional: true dependencies: - '@typescript-eslint/parser': 5.36.1(eslint@8.23.0)(typescript@5.2.2) + '@typescript-eslint/parser': 5.36.1(eslint@8.23.0)(typescript@4.9.5) array-includes: 3.1.5 array.prototype.flat: 1.3.0 debug: 2.6.9 @@ -5433,7 +5433,7 @@ packages: esbuild: 0.14.54 dev: true - /tsup@6.2.3(typescript@5.2.2): + /tsup@6.2.3(typescript@4.9.5): resolution: {integrity: sha512-J5Pu2Dx0E1wlpIEsVFv9ryzP1pZ1OYsJ2cBHZ7GrKteytNdzaSz5hmLX7/nAxtypq+jVkVvA79d7S83ETgHQ5w==} engines: {node: '>=14'} hasBin: true @@ -5463,20 +5463,20 @@ packages: source-map: 0.8.0-beta.0 sucrase: 3.25.0 tree-kill: 1.2.2 - typescript: 5.2.2 + typescript: 4.9.5 transitivePeerDependencies: - supports-color - ts-node dev: true - /tsutils@3.21.0(typescript@5.2.2): + /tsutils@3.21.0(typescript@4.9.5): resolution: {integrity: sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==} engines: {node: '>= 6'} peerDependencies: typescript: '>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta' dependencies: tslib: 1.14.1 - typescript: 5.2.2 + typescript: 4.9.5 dev: true /tty-table@4.1.6: @@ -5545,9 +5545,9 @@ packages: mime-types: 2.1.35 dev: true - /typescript@5.2.2: - resolution: {integrity: sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==} - engines: {node: '>=14.17'} + /typescript@4.9.5: + resolution: {integrity: sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==} + engines: {node: '>=4.2.0'} hasBin: true dev: true 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 496f91a9..b8dd6246 100644 --- a/src/handlers/next/saleor-webhooks/sync-webhook-response-builder.ts +++ b/src/handlers/next/saleor-webhooks/sync-webhook-response-builder.ts @@ -90,8 +90,126 @@ export type SyncWebhookResponsesMap = { externalUrl?: string; message?: string; }; - -} satisfies Record + 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">; // todo confirm + type: string; + // todo confirm which are optional, also numbers vs strings + creditCardInfo?: { + brand: string; + lastDigits: string; + expMonth: string; + expYear: string; + firstDigits?: string; + }; + name?: string; + data?: unknown; + }>; + }; + // todo + PAYMENT_VOID: {}; + // todo + PAYMENT_REFUND: {}; + PAYMENT_PROCESS: + | { + action_required: true; + // todo verify + action_required_data: { + confirmation_url: "https://www.example.com/3ds-confirmation/"; + }; + customer_id: string; + // todo - confirm if all required + payment_method: { + brand: string; + exp_month: string; + exp_year: string; + last_4: string; + name: string; + type: string; // enum? + }; + transaction_id: string; + } + | { + action_required: false; + kind: "auth"; // todo enum? + customer_id: string; + // todo - check if required all fields + payment_method: { + brand: string; + exp_month: string; + exp_year: string; + last_4: string; + name: string; + type: string; // enum? + }; + transaction_id: string; + }; + PAYMENT_LIST_GATEWAYS: Array<{ + id: string; + name: string; + currencies: string[]; + config: unknown; + }>; + PAYMENT_CONFIRM: unknown; // todo + PAYMENT_CAPTURE: unknown; // todo + PAYMENT_AUTHORIZE: unknown; // todo +}; /** * Identity function, but it works on Typescript level to pick right payload based on first param From d79a9a6f06b87e1744df717b9431f41193d7828a Mon Sep 17 00:00:00 2001 From: Lukasz Ostrowski Date: Wed, 29 Nov 2023 15:08:30 +0100 Subject: [PATCH 5/5] remove lgacy events --- .../sync-webhook-response-builder.ts | 50 +------------------ src/types.ts | 7 --- 2 files changed, 1 insertion(+), 56 deletions(-) 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 b8dd6246..952e0cb7 100644 --- a/src/handlers/next/saleor-webhooks/sync-webhook-response-builder.ts +++ b/src/handlers/next/saleor-webhooks/sync-webhook-response-builder.ts @@ -148,9 +148,8 @@ export type SyncWebhookResponsesMap = { LIST_STORED_PAYMENT_METHODS: { paymentMethods: Array<{ id: string; - supportedPaymentFlows: Array<"INTERACTIVE">; // todo confirm + supportedPaymentFlows: Array<"INTERACTIVE">; type: string; - // todo confirm which are optional, also numbers vs strings creditCardInfo?: { brand: string; lastDigits: string; @@ -162,53 +161,6 @@ export type SyncWebhookResponsesMap = { data?: unknown; }>; }; - // todo - PAYMENT_VOID: {}; - // todo - PAYMENT_REFUND: {}; - PAYMENT_PROCESS: - | { - action_required: true; - // todo verify - action_required_data: { - confirmation_url: "https://www.example.com/3ds-confirmation/"; - }; - customer_id: string; - // todo - confirm if all required - payment_method: { - brand: string; - exp_month: string; - exp_year: string; - last_4: string; - name: string; - type: string; // enum? - }; - transaction_id: string; - } - | { - action_required: false; - kind: "auth"; // todo enum? - customer_id: string; - // todo - check if required all fields - payment_method: { - brand: string; - exp_month: string; - exp_year: string; - last_4: string; - name: string; - type: string; // enum? - }; - transaction_id: string; - }; - PAYMENT_LIST_GATEWAYS: Array<{ - id: string; - name: string; - currencies: string[]; - config: unknown; - }>; - PAYMENT_CONFIRM: unknown; // todo - PAYMENT_CAPTURE: unknown; // todo - PAYMENT_AUTHORIZE: unknown; // todo }; /** diff --git a/src/types.ts b/src/types.ts index 6c91dfee..a93c7c2e 100644 --- a/src/types.ts +++ b/src/types.ts @@ -189,13 +189,6 @@ export type SyncWebhookEventType = | "PAYMENT_GATEWAY_INITIALIZE_SESSION" | "TRANSACTION_INITIALIZE_SESSION" | "TRANSACTION_PROCESS_SESSION" - | "PAYMENT_AUTHORIZE" - | "PAYMENT_CAPTURE" - | "PAYMENT_CONFIRM" - | "PAYMENT_LIST_GATEWAYS" - | "PAYMENT_PROCESS" - | "PAYMENT_REFUND" - | "PAYMENT_VOID" | "LIST_STORED_PAYMENT_METHODS" | "STORED_PAYMENT_METHOD_DELETE_REQUESTED" | "PAYMENT_GATEWAY_INITIALIZE_TOKENIZATION_SESSION"