diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index d2a657f..45adb94 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -25,7 +25,7 @@ jobs: echo "release-version=${NEW_VERSION}" >> $GITHUB_OUTPUT - name: Create GH release - uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 + uses: softprops/action-gh-release@9d7c94cfd0a1f3ed45544c887983e9fa900f0564 with: token: ${{ secrets.GITHUB_TOKEN }} tag_name: ${{ steps.version.outputs.release-version }} diff --git a/event/package-lock.json b/event/package-lock.json index 08941b5..8bd8007 100644 --- a/event/package-lock.json +++ b/event/package-lock.json @@ -12,11 +12,11 @@ "@commercetools-backend/loggers": "22.19.0", "@commercetools/platform-sdk": "7.4.0", "@commercetools/sdk-client-v2": "2.3.0", - "@fulfillmenttools/fulfillmenttools-sdk-typescript": "0.1.10", + "@fulfillmenttools/fulfillmenttools-sdk-typescript": "0.1.12", "body-parser": "1.20.2", "date-fns": "2.30.0", "dotenv": "16.4.5", - "express": "4.18.3", + "express": "4.19.2", "jsonwebtoken": "9.0.2", "msw": "1.3.2", "shared": "file:../shared", @@ -64,11 +64,11 @@ "@commercetools-backend/loggers": "22.19.0", "@commercetools/platform-sdk": "7.4.0", "@commercetools/sdk-client-v2": "2.3.0", - "@fulfillmenttools/fulfillmenttools-sdk-typescript": "0.1.10", + "@fulfillmenttools/fulfillmenttools-sdk-typescript": "0.1.12", "body-parser": "1.20.2", "date-fns": "2.30.0", "dotenv": "16.4.5", - "express": "4.18.3", + "express": "4.19.2", "jsonwebtoken": "9.0.2", "msw": "1.3.2", "superagent": "8.1.2", @@ -8284,13 +8284,13 @@ } }, "node_modules/@fulfillmenttools/fulfillmenttools-sdk-typescript": { - "version": "0.1.10", - "resolved": "https://registry.npmjs.org/@fulfillmenttools/fulfillmenttools-sdk-typescript/-/fulfillmenttools-sdk-typescript-0.1.10.tgz", - "integrity": "sha512-S4D67TsdwqOmZMTYOybHxgI4Xwh9pNq2/vqfJ400dpZ/Ru7yn24xoNhECw0bJVxQ0cA2sixNJE3oSB4ghQzKTA==", + "version": "0.1.12", + "resolved": "https://registry.npmjs.org/@fulfillmenttools/fulfillmenttools-sdk-typescript/-/fulfillmenttools-sdk-typescript-0.1.12.tgz", + "integrity": "sha512-ELPYf9CNqeWWoRBwKf9m1Vpp9NshMCw6lCaM8gUT8qZJggS0v6NBMC+AW59JrIoD1h8H56RYKsAuJN1KIThSwQ==", "dependencies": { "date-fns": "2.30.0", "dotenv": "16.4.5", - "express": "4.18.3", + "express": "4.19.2", "http-status-enum": "1.0.2", "superagent": "8.1.2", "timers": "0.1.1", @@ -10899,16 +10899,16 @@ } }, "node_modules/express": { - "version": "4.18.3", - "resolved": "https://registry.npmjs.org/express/-/express-4.18.3.tgz", - "integrity": "sha512-6VyCijWQ+9O7WuVMTRBTl+cjNNIzD5cY5mQ1WM8r/LEkI2u8EYpOotESNwzNlyCn3g+dmjKYI6BmNneSr/FSRw==", + "version": "4.19.2", + "resolved": "https://registry.npmjs.org/express/-/express-4.19.2.tgz", + "integrity": "sha512-5T6nhjsT+EOMzuck8JjBHARTHfMht0POzlA60WV2pMD3gyXw2LZnZ+ueGdNxG+0calOJcWKbpFcuzLZ91YWq9Q==", "dependencies": { "accepts": "~1.3.8", "array-flatten": "1.1.1", "body-parser": "1.20.2", "content-disposition": "0.5.4", "content-type": "~1.0.4", - "cookie": "0.5.0", + "cookie": "0.6.0", "cookie-signature": "1.0.6", "debug": "2.6.9", "depd": "2.0.0", @@ -11011,8 +11011,9 @@ } }, "node_modules/express/node_modules/cookie": { - "version": "0.5.0", - "license": "MIT", + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.6.0.tgz", + "integrity": "sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==", "engines": { "node": ">= 0.6" } diff --git a/event/package.json b/event/package.json index f84c940..44e9403 100644 --- a/event/package.json +++ b/event/package.json @@ -63,11 +63,11 @@ "@commercetools-backend/loggers": "22.19.0", "@commercetools/platform-sdk": "7.4.0", "@commercetools/sdk-client-v2": "2.3.0", - "@fulfillmenttools/fulfillmenttools-sdk-typescript": "0.1.10", + "@fulfillmenttools/fulfillmenttools-sdk-typescript": "0.1.12", "body-parser": "1.20.2", "date-fns": "2.30.0", "dotenv": "16.4.5", - "express": "4.18.3", + "express": "4.19.2", "jsonwebtoken": "9.0.2", "msw": "1.3.2", "shared": "file:../shared", diff --git a/event/src/connector/actions.ts b/event/src/connector/actions.ts index f6db63f..517b573 100644 --- a/event/src/connector/actions.ts +++ b/event/src/connector/actions.ts @@ -27,7 +27,7 @@ export async function createOrderStateChangedSubscription( .withKey({ key: ORDER_STATE_CHANGED_SUBSCRIPTION_KEY }) .delete({ queryArgs: { - version: subscription.version, + version: subscription?.version || 0, }, }) .execute(); @@ -74,7 +74,7 @@ export async function deleteOrderStateChangedSubscription(apiRoot: ByProjectKeyR .withKey({ key: ORDER_STATE_CHANGED_SUBSCRIPTION_KEY }) .delete({ queryArgs: { - version: subscription.version, + version: subscription?.version || 0, }, }) .execute(); @@ -105,7 +105,7 @@ export async function createChannelResourceSubscription( .withKey({ key: CHANNEL_RESOURCE_SUBSCRIPTION_KEY }) .delete({ queryArgs: { - version: subscription.version, + version: subscription?.version || 0, }, }) .execute(); @@ -151,7 +151,7 @@ export async function deleteChannelResourceSubscription(apiRoot: ByProjectKeyReq .withKey({ key: CHANNEL_RESOURCE_SUBSCRIPTION_KEY }) .delete({ queryArgs: { - version: subscription.version, + version: subscription?.version || 0, }, }) .execute(); diff --git a/event/src/services/channelService.ts b/event/src/services/channelService.ts index bd45849..21efc45 100644 --- a/event/src/services/channelService.ts +++ b/event/src/services/channelService.ts @@ -95,7 +95,7 @@ export class ChannelService { defaultName: string, countries: string[] ): FacilityAddressForCreation { - const defaultCountry = countries && countries.length > 0 ? countries[0] : 'DE'; + const defaultCountry = countries?.[0] || 'DE'; if (address) { return { street: address.streetName?.trim() || 'not set', diff --git a/event/tests/orderMapper.test.ts b/event/tests/orderMapper.test.ts index 8001f2e..7a2e8fc 100644 --- a/event/tests/orderMapper.test.ts +++ b/event/tests/orderMapper.test.ts @@ -32,6 +32,7 @@ describe('OrderMapper', () => { expect(fulfillmenttoolsOrder.consumer.email).toEqual('max.mustermann@fulfillmenttools.com'); expect(fulfillmenttoolsOrder.consumer.addresses).toHaveLength(1); const consumerAddress = fulfillmenttoolsOrder.consumer.addresses[0]; + expect(consumerAddress).toBeDefined(); expect(consumerAddress.city).toEqual('Köln'); expect(consumerAddress.street).toEqual('Schanzenstraße'); expect(consumerAddress.houseNumber).toEqual('30'); @@ -43,6 +44,7 @@ describe('OrderMapper', () => { expect(fulfillmenttoolsOrder.orderLineItems).toHaveLength(1); const orderLineItem = fulfillmenttoolsOrder.orderLineItems[0]; + expect(orderLineItem).toBeDefined(); expect(orderLineItem.quantity).toEqual(1); expect(orderLineItem.article).toBeDefined(); const article = orderLineItem.article; diff --git a/event/tsconfig.json b/event/tsconfig.json index 597af9f..c64b812 100644 --- a/event/tsconfig.json +++ b/event/tsconfig.json @@ -1,12 +1,22 @@ { "extends": "@tsconfig/recommended/tsconfig.json", - "exclude": ["node_modules", "tmp", "**/*.spec.ts", "**/*.test.ts"], + "exclude": [ + "node_modules", + "tmp", + "**/*.spec.ts", + "**/*.test.ts" + ], "compilerOptions": { - "lib": ["es2021"], - "target": "es2021", - "resolveJsonModule": true, + "allowSyntheticDefaultImports": true, + "lib": [ + "es2021" + ], + "noFallthroughCasesInSwitch": true, + "noImplicitReturns": true, + // "noUncheckedIndexedAccess": true, "outDir": "./build", + "resolveJsonModule": true, "rootDir": "./src", - "inlineSourceMap": true + "target": "es2021", } } diff --git a/service/package-lock.json b/service/package-lock.json index e51b7bd..341c5cc 100644 --- a/service/package-lock.json +++ b/service/package-lock.json @@ -12,11 +12,11 @@ "@commercetools-backend/loggers": "22.19.0", "@commercetools/platform-sdk": "7.4.0", "@commercetools/sdk-client-v2": "2.3.0", - "@fulfillmenttools/fulfillmenttools-sdk-typescript": "0.1.10", + "@fulfillmenttools/fulfillmenttools-sdk-typescript": "0.1.12", "body-parser": "1.20.2", "date-fns": "2.30.0", "dotenv": "16.4.5", - "express": "4.18.3", + "express": "4.19.2", "jsonwebtoken": "9.0.2", "msw": "1.3.2", "shared": "file:../shared", @@ -64,11 +64,11 @@ "@commercetools-backend/loggers": "22.19.0", "@commercetools/platform-sdk": "7.4.0", "@commercetools/sdk-client-v2": "2.3.0", - "@fulfillmenttools/fulfillmenttools-sdk-typescript": "0.1.10", + "@fulfillmenttools/fulfillmenttools-sdk-typescript": "0.1.12", "body-parser": "1.20.2", "date-fns": "2.30.0", "dotenv": "16.4.5", - "express": "4.18.3", + "express": "4.19.2", "jsonwebtoken": "9.0.2", "msw": "1.3.2", "superagent": "8.1.2", @@ -8284,13 +8284,13 @@ } }, "node_modules/@fulfillmenttools/fulfillmenttools-sdk-typescript": { - "version": "0.1.10", - "resolved": "https://registry.npmjs.org/@fulfillmenttools/fulfillmenttools-sdk-typescript/-/fulfillmenttools-sdk-typescript-0.1.10.tgz", - "integrity": "sha512-S4D67TsdwqOmZMTYOybHxgI4Xwh9pNq2/vqfJ400dpZ/Ru7yn24xoNhECw0bJVxQ0cA2sixNJE3oSB4ghQzKTA==", + "version": "0.1.12", + "resolved": "https://registry.npmjs.org/@fulfillmenttools/fulfillmenttools-sdk-typescript/-/fulfillmenttools-sdk-typescript-0.1.12.tgz", + "integrity": "sha512-ELPYf9CNqeWWoRBwKf9m1Vpp9NshMCw6lCaM8gUT8qZJggS0v6NBMC+AW59JrIoD1h8H56RYKsAuJN1KIThSwQ==", "dependencies": { "date-fns": "2.30.0", "dotenv": "16.4.5", - "express": "4.18.3", + "express": "4.19.2", "http-status-enum": "1.0.2", "superagent": "8.1.2", "timers": "0.1.1", @@ -10894,16 +10894,16 @@ } }, "node_modules/express": { - "version": "4.18.3", - "resolved": "https://registry.npmjs.org/express/-/express-4.18.3.tgz", - "integrity": "sha512-6VyCijWQ+9O7WuVMTRBTl+cjNNIzD5cY5mQ1WM8r/LEkI2u8EYpOotESNwzNlyCn3g+dmjKYI6BmNneSr/FSRw==", + "version": "4.19.2", + "resolved": "https://registry.npmjs.org/express/-/express-4.19.2.tgz", + "integrity": "sha512-5T6nhjsT+EOMzuck8JjBHARTHfMht0POzlA60WV2pMD3gyXw2LZnZ+ueGdNxG+0calOJcWKbpFcuzLZ91YWq9Q==", "dependencies": { "accepts": "~1.3.8", "array-flatten": "1.1.1", "body-parser": "1.20.2", "content-disposition": "0.5.4", "content-type": "~1.0.4", - "cookie": "0.5.0", + "cookie": "0.6.0", "cookie-signature": "1.0.6", "debug": "2.6.9", "depd": "2.0.0", @@ -11006,8 +11006,9 @@ } }, "node_modules/express/node_modules/cookie": { - "version": "0.5.0", - "license": "MIT", + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.6.0.tgz", + "integrity": "sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==", "engines": { "node": ">= 0.6" } diff --git a/service/package.json b/service/package.json index 7d5f601..f68f146 100644 --- a/service/package.json +++ b/service/package.json @@ -63,11 +63,11 @@ "@commercetools-backend/loggers": "22.19.0", "@commercetools/platform-sdk": "7.4.0", "@commercetools/sdk-client-v2": "2.3.0", - "@fulfillmenttools/fulfillmenttools-sdk-typescript": "0.1.10", + "@fulfillmenttools/fulfillmenttools-sdk-typescript": "0.1.12", "body-parser": "1.20.2", "date-fns": "2.30.0", "dotenv": "16.4.5", - "express": "4.18.3", + "express": "4.19.2", "jsonwebtoken": "9.0.2", "msw": "1.3.2", "shared": "file:../shared", diff --git a/service/src/routes/serviceRouter.ts b/service/src/routes/serviceRouter.ts index 2c7f131..82e6e4c 100644 --- a/service/src/routes/serviceRouter.ts +++ b/service/src/routes/serviceRouter.ts @@ -49,25 +49,33 @@ export class ServiceRouter { middleware.push(checkJwt); } - this.serviceRouter.post(fftEvents.ORDER_CREATED, middleware, asyncHandler(orderController.orderCreated)); - - this.serviceRouter.post(fftEvents.PICK_JOB_CREATED, middleware, asyncHandler(pickJobController.pickJobCreated)); - this.serviceRouter.post( - fftEvents.PICK_JOB_PICKING_FINISHED, - middleware, - asyncHandler(pickJobController.pickJobFinished) - ); - - this.serviceRouter.post( - fftEvents.HANDOVERJOB_CREATED, - middleware, - asyncHandler(handoverJobController.handoverJobCreated) - ); - this.serviceRouter.post( - fftEvents.HANDOVERJOB_HANDED_OVER, - middleware, - asyncHandler(handoverJobController.handoverJobHandedOver) - ); + if (fftEvents.ORDER_CREATED) { + this.serviceRouter.post(fftEvents.ORDER_CREATED, middleware, asyncHandler(orderController.orderCreated)); + } + if (fftEvents.PICK_JOB_CREATED) { + this.serviceRouter.post(fftEvents.PICK_JOB_CREATED, middleware, asyncHandler(pickJobController.pickJobCreated)); + } + if (fftEvents.PICK_JOB_PICKING_FINISHED) { + this.serviceRouter.post( + fftEvents.PICK_JOB_PICKING_FINISHED, + middleware, + asyncHandler(pickJobController.pickJobFinished) + ); + } + if (fftEvents.HANDOVERJOB_CREATED) { + this.serviceRouter.post( + fftEvents.HANDOVERJOB_CREATED, + middleware, + asyncHandler(handoverJobController.handoverJobCreated) + ); + } + if (fftEvents.HANDOVERJOB_HANDED_OVER) { + this.serviceRouter.post( + fftEvents.HANDOVERJOB_HANDED_OVER, + middleware, + asyncHandler(handoverJobController.handoverJobHandedOver) + ); + } } public getRouter(): Router { diff --git a/service/tsconfig.json b/service/tsconfig.json index 597af9f..0a9dba9 100644 --- a/service/tsconfig.json +++ b/service/tsconfig.json @@ -1,12 +1,22 @@ { "extends": "@tsconfig/recommended/tsconfig.json", - "exclude": ["node_modules", "tmp", "**/*.spec.ts", "**/*.test.ts"], + "exclude": [ + "node_modules", + "tmp", + "**/*.spec.ts", + "**/*.test.ts" + ], "compilerOptions": { - "lib": ["es2021"], - "target": "es2021", - "resolveJsonModule": true, + "allowSyntheticDefaultImports": true, + "lib": [ + "es2021" + ], + "noFallthroughCasesInSwitch": true, + "noImplicitReturns": true, + "noUncheckedIndexedAccess": true, "outDir": "./build", + "resolveJsonModule": true, "rootDir": "./src", - "inlineSourceMap": true + "target": "es2021", } } diff --git a/shared/package-lock.json b/shared/package-lock.json index 3be86d8..4d33abd 100644 --- a/shared/package-lock.json +++ b/shared/package-lock.json @@ -12,7 +12,7 @@ "@commercetools-backend/loggers": "22.19.0", "@commercetools/platform-sdk": "7.4.0", "@commercetools/sdk-client-v2": "2.3.0", - "@fulfillmenttools/fulfillmenttools-sdk-typescript": "0.1.10", + "@fulfillmenttools/fulfillmenttools-sdk-typescript": "0.1.12", "body-parser": "1.20.2", "date-fns": "2.30.0", "dotenv": "16.4.5", @@ -946,13 +946,13 @@ } }, "node_modules/@fulfillmenttools/fulfillmenttools-sdk-typescript": { - "version": "0.1.10", - "resolved": "https://registry.npmjs.org/@fulfillmenttools/fulfillmenttools-sdk-typescript/-/fulfillmenttools-sdk-typescript-0.1.10.tgz", - "integrity": "sha512-S4D67TsdwqOmZMTYOybHxgI4Xwh9pNq2/vqfJ400dpZ/Ru7yn24xoNhECw0bJVxQ0cA2sixNJE3oSB4ghQzKTA==", + "version": "0.1.12", + "resolved": "https://registry.npmjs.org/@fulfillmenttools/fulfillmenttools-sdk-typescript/-/fulfillmenttools-sdk-typescript-0.1.12.tgz", + "integrity": "sha512-ELPYf9CNqeWWoRBwKf9m1Vpp9NshMCw6lCaM8gUT8qZJggS0v6NBMC+AW59JrIoD1h8H56RYKsAuJN1KIThSwQ==", "dependencies": { "date-fns": "2.30.0", "dotenv": "16.4.5", - "express": "4.18.3", + "express": "4.19.2", "http-status-enum": "1.0.2", "superagent": "8.1.2", "timers": "0.1.1", diff --git a/shared/package.json b/shared/package.json index 78dc8c1..4f69239 100644 --- a/shared/package.json +++ b/shared/package.json @@ -53,7 +53,7 @@ "@commercetools-backend/loggers": "22.19.0", "@commercetools/platform-sdk": "7.4.0", "@commercetools/sdk-client-v2": "2.3.0", - "@fulfillmenttools/fulfillmenttools-sdk-typescript": "0.1.10", + "@fulfillmenttools/fulfillmenttools-sdk-typescript": "0.1.12", "body-parser": "1.20.2", "date-fns": "2.30.0", "dotenv": "16.4.5", diff --git a/shared/src/commercetools/customTypeService.ts b/shared/src/commercetools/customTypeService.ts index d74484c..584ebe5 100644 --- a/shared/src/commercetools/customTypeService.ts +++ b/shared/src/commercetools/customTypeService.ts @@ -35,6 +35,7 @@ export async function getCustomOrderType(): Promise { logger.error(JSON.stringify(error)); throw new CustomError(status, `Cannot read CT custom type`); } + return undefined; } async function getCustomTypeById(id: string): Promise { @@ -87,6 +88,7 @@ export async function createCustomOrderType(): Promise { logger.error(JSON.stringify(error)); throw new CustomError(statusCode(error), `Cannot create CT custom type`); } + return undefined; } export async function updateCustomOrderType(id: string): Promise { @@ -116,6 +118,7 @@ export async function updateCustomOrderType(id: string): Promise { diff --git a/shared/src/jwt/tokenUtils.ts b/shared/src/jwt/tokenUtils.ts index 5f9d08e..f039871 100644 --- a/shared/src/jwt/tokenUtils.ts +++ b/shared/src/jwt/tokenUtils.ts @@ -1,4 +1,4 @@ -import { JwtPayload, sign, verify } from 'jsonwebtoken'; +import { JwtPayload, JsonWebTokenError, sign, verify } from 'jsonwebtoken'; import { readConfiguration } from '../utils'; import { randomUUID } from 'crypto'; @@ -12,7 +12,10 @@ export function generateToken(validityDays: number): string | undefined { }); } -export function validateToken(token: string): JwtPayload { +export function validateToken(token: string | undefined): JwtPayload { + if (!token) { + throw new JsonWebTokenError('JWT must be provided'); + } return verify(token, readConfiguration().jwtSecret, { complete: true, audience: readConfiguration().jwtAudience, diff --git a/shared/tsconfig.json b/shared/tsconfig.json index a7af799..35beb2f 100644 --- a/shared/tsconfig.json +++ b/shared/tsconfig.json @@ -1,12 +1,23 @@ { "extends": "@tsconfig/recommended/tsconfig.json", - "exclude": ["node_modules", "tmp", "lib", "**/*.spec.ts", "**/*.test.ts"], + "exclude": [ + "node_modules", + "tmp", + "lib", + "**/*.spec.ts", + "**/*.test.ts" + ], "compilerOptions": { - "lib": ["es2021"], - "target": "es2021", - "resolveJsonModule": true, + "allowSyntheticDefaultImports": true, + "lib": [ + "es2021" + ], + "noFallthroughCasesInSwitch": true, + "noImplicitReturns": true, + "noUncheckedIndexedAccess": true, "outDir": "./lib", + "resolveJsonModule": true, "rootDir": "./src", - "inlineSourceMap": true + "target": "es2021", } }