From dd9ac03bdd4a24980426b83340f8dac941d7fd7f Mon Sep 17 00:00:00 2001 From: Pascal Kaufmann Date: Wed, 10 Jun 2020 10:06:07 +0200 Subject: [PATCH 1/4] Stripe v2 --- .eslintrc | 41 +-- examples/minimal/.eslintrc | 27 +- examples/minimal/boot.js | 3 +- package-lock.json | 18 ++ package.json | 7 +- packages/core-orders/db/orders/helpers.js | 45 ++- packages/core-payment/plugins/stripe.js | 237 ++++++++++++--- tests/jest-global-setup.js | 3 +- tests/plugins-stripe.test.js | 351 ++++++++++++++++++++++ 9 files changed, 636 insertions(+), 96 deletions(-) create mode 100644 tests/plugins-stripe.test.js diff --git a/.eslintrc b/.eslintrc index fa379a453a..bd49aaf148 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,26 +1,33 @@ { "parser": "babel-eslint", - "plugins": [ - "prettier" - ], - "extends": [ - "airbnb-base", - "plugin:prettier/recommended" - ], + "plugins": ["prettier"], + "extends": ["airbnb-base", "plugin:prettier/recommended"], "env": { "node": true, "jest": true }, "rules": { - "prettier/prettier": [ "error", { - "singleQuote": true - }], - "no-underscore-dangle": [ "error", { "allow": [ - "_id", - "__MONGO_URI__", - "__MONGO_DB_NAME__", - "__SUBPROCESS_METEOR__", - "__MONGOD__" - ] } ] + "prettier/prettier": [ + "error", + { + "printWidth": 80, + "semi": true, + "trailingComma": "all", + "singleQuote": true, + "proseWrap": "always" + } + ], + "no-underscore-dangle": [ + "error", + { + "allow": [ + "_id", + "__MONGO_URI__", + "__MONGO_DB_NAME__", + "__SUBPROCESS_METEOR__", + "__MONGOD__" + ] + } + ] } } diff --git a/examples/minimal/.eslintrc b/examples/minimal/.eslintrc index f9276ae7d3..7d6498e57e 100755 --- a/examples/minimal/.eslintrc +++ b/examples/minimal/.eslintrc @@ -1,9 +1,6 @@ { "parser": "babel-eslint", - "plugins": [ - "meteor", - "prettier" - ], + "plugins": ["meteor", "prettier"], "extends": [ "airbnb-base", "plugin:meteor/recommended", @@ -18,18 +15,22 @@ "import/core-modules": ["meteor"], "import/resolver": { "meteor": { - "extensions": [ - ".jsx", - ".js" - ] + "extensions": [".jsx", ".js"] } } }, "rules": { - "prettier/prettier": [ "error", { - "singleQuote": true - }], - "no-underscore-dangle": [ "error", { "allow": [ "_id" ] } ], - "import/no-unresolved": [ "error", { ignore: ['meteor/'] } ] + "prettier/prettier": [ + "error", + { + "printWidth": 80, + "semi": true, + "trailingComma": "all", + "singleQuote": true, + "proseWrap": "always" + } + ], + "no-underscore-dangle": ["error", { "allow": ["_id"] }], + "import/no-unresolved": ["error", { "ignore": ["meteor/"] }] } } diff --git a/examples/minimal/boot.js b/examples/minimal/boot.js index 8a70c340e6..5f4dee68f6 100755 --- a/examples/minimal/boot.js +++ b/examples/minimal/boot.js @@ -16,6 +16,7 @@ import 'meteor/unchained:core-documents/plugins/smallinvoice'; import 'meteor/unchained:core-payment/plugins/invoice'; import 'meteor/unchained:core-payment/plugins/invoice-prepaid'; import 'meteor/unchained:core-payment/plugins/datatrans'; +import 'meteor/unchained:core-payment/plugins/stripe'; import 'meteor/unchained:core-payment/plugins/apple-iap'; import 'meteor/unchained:core-pricing/plugins/order-items'; import 'meteor/unchained:core-pricing/plugins/order-discount'; @@ -84,7 +85,7 @@ const initializeDatabase = () => { \nlanguages: ${languages.join(',')} \nuser: admin@localhost / password`); } catch (e) { - console.log("ERROR: ", e) + console.log('ERROR: ', e); logger.log('database was already initialized'); } }; diff --git a/package-lock.json b/package-lock.json index 5e0ff8e522..dd9b28c552 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8580,6 +8580,24 @@ "integrity": "sha512-e6/d0eBu7gHtdCqFt0xJr642LdToM5/cN4Qb9DbHjVx1CP5RyeM+zH7pbecEmDv/lBqb0QH+6Uqq75rxFPkM0w==", "dev": true }, + "stripe": { + "version": "8.60.0", + "resolved": "https://registry.npmjs.org/stripe/-/stripe-8.60.0.tgz", + "integrity": "sha512-FmM0Cy1YLW8Nk3dzWg83tDKROPAJwS2f+Xeezyq15JRUSOUqaSoj1FguBY460GWpzzQcqSXUXkQozYcLU1UtAg==", + "dev": true, + "requires": { + "@types/node": ">=8.1.0", + "qs": "^6.6.0" + }, + "dependencies": { + "qs": { + "version": "6.9.4", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.9.4.tgz", + "integrity": "sha512-A1kFqHekCTM7cz0udomYUoYNWjBebHm/5wzU/XqrBRBNWectVH0QIiN+NEcZ0Dte5hvzHwbr8+XQmguPhJ6WdQ==", + "dev": true + } + } + }, "supports-color": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", diff --git a/package.json b/package.json index 25587685fa..c93395ac66 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "Marco Wettstein ", "Simon Emanuel Schmid (https://unchained.shop)" ], - "bugs": { + "bugs": { "url": "https://github.com/unchainedshop/unchained/issues" }, "scripts": { @@ -58,10 +58,11 @@ "jest": "^26.0.1", "mongodb": "^3.5.7", "npm-run-all": "^4.1.5", - "prettier": "^2.0.5" + "prettier": "^2.0.5", + "stripe": "^8.60.0" }, "eslintConfig": { "extends": "@meteorjs/eslint-config-meteor" }, "dependencies": {} -} \ No newline at end of file +} diff --git a/packages/core-orders/db/orders/helpers.js b/packages/core-orders/db/orders/helpers.js index 471065db67..c432645c86 100644 --- a/packages/core-orders/db/orders/helpers.js +++ b/packages/core-orders/db/orders/helpers.js @@ -48,14 +48,14 @@ Subscriptions.generateFromCheckout = async ({ items, order, ...context }) => { items.map(async (item) => { const subscriptionData = await SubscriptionDirector.transformOrderItemToSubscription( item, - { ...template, ...context } + { ...template, ...context }, ); await Subscriptions.createSubscription({ ...subscriptionData, orderIdForFirstPeriod: order._id, }); - }) + }), ); }; @@ -169,13 +169,13 @@ Orders.helpers({ payment?.pricing().discountSum(orderDiscountId), delivery?.pricing().discountSum(orderDiscountId), ...this.items().flatMap((item) => - item.pricing().discountSum(orderDiscountId) + item.pricing().discountSum(orderDiscountId), ), this.pricing().discountSum(orderDiscountId), ]; const amount = prices.reduce( (oldValue, price) => oldValue + (price || 0), - 0 + 0, ); return { amount, @@ -189,9 +189,8 @@ Orders.helpers({ }); }, async initProviders() { - return this.initPreferredDeliveryProvider().then((order) => - order.initPreferredPaymentProvider() - ); + const order = await this.initPreferredDeliveryProvider(); + return order.initPreferredPaymentProvider(); }, async initPreferredPaymentProvider() { const supportedPaymentProviders = PaymentProviders.findSupported({ @@ -205,7 +204,7 @@ Orders.helpers({ const isAlreadyInitializedWithSupportedProvider = supportedPaymentProviders.some( (provider) => { return provider._id === paymentProviderId; - } + }, ); if ( supportedPaymentProviders.length > 0 && @@ -220,7 +219,7 @@ Orders.helpers({ paymentCredential.paymentProviderId ); }); - } + }, ); if (foundSupportedPreferredProvider) { return this.setPaymentProvider({ @@ -243,7 +242,7 @@ Orders.helpers({ const isAlreadyInitializedWithSupportedProvider = supportedDeliveryProviders.some( (provider) => { return provider._id === deliveryProviderId; - } + }, ); if ( @@ -277,7 +276,7 @@ Orders.helpers({ }, addQuotationItem({ quotation, ...quotationItemConfiguration }) { const { quantity, configuration } = quotation.transformItemConfiguration( - quotationItemConfiguration + quotationItemConfiguration, ); const product = quotation.product(); return this.addProductItem({ @@ -376,7 +375,7 @@ Orders.helpers({ order: this, items, ...context, - }) + }), ); } }, @@ -441,7 +440,7 @@ Orders.helpers({ // documents and numbers that are needed for delivery const newConfirmedOrder = this.setStatus( OrderStatus.CONFIRMED, - 'before delivery' + 'before delivery', ); this.delivery().send(deliveryContext, newConfirmedOrder); newConfirmedOrder.generateSubscriptions({ @@ -520,7 +519,7 @@ Orders.helpers({ orderId: this._id, ...meta, }, - }) + }), ); } const { rawFile, userId } = objOrString; @@ -533,7 +532,7 @@ Orders.helpers({ orderId: this._id, ...meta, }, - }) + }), ); }, documents(options) { @@ -586,7 +585,7 @@ Orders.setDeliveryProvider = ({ orderId, deliveryProviderId }) => { log(`Set Delivery Provider ${deliveryProviderId}`, { orderId }); Orders.update( { _id: orderId }, - { $set: { deliveryId, updated: new Date() } } + { $set: { deliveryId, updated: new Date() } }, ); Orders.updateCalculation({ orderId }); return Orders.findOne({ _id: orderId }); @@ -642,7 +641,7 @@ Orders.updateBillingAddress = ({ billingAddress, orderId }) => { billingAddress, updated: new Date(), }, - } + }, ); Orders.updateCalculation({ orderId }); return Orders.findOne({ _id: orderId }); @@ -657,7 +656,7 @@ Orders.updateContact = ({ contact, orderId }) => { contact, updated: new Date(), }, - } + }, ); Orders.updateCalculation({ orderId }); return Orders.findOne({ _id: orderId }); @@ -672,7 +671,7 @@ Orders.updateContext = ({ context, orderId }) => { context, updated: new Date(), }, - } + }, ); Orders.updateCalculation({ orderId }); return Orders.findOne({ _id: orderId }); @@ -683,7 +682,7 @@ Orders.getUniqueOrderNumber = () => { const hashids = new Hashids( 'unchained', 6, - 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890' + 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890', ); while (!orderNumber) { const randomNumber = Math.floor(Math.random() * (999999999 - 1)) + 1; @@ -775,7 +774,7 @@ Orders.updateCalculation = ({ orderId }) => { calculation, updated: new Date(), }, - } + }, ); }; @@ -804,7 +803,7 @@ Orders.migrateCart = async ({ $set: { userId: toUserId, }, - } + }, ); Orders.updateCalculation({ orderId: fromCart._id, @@ -821,7 +820,7 @@ Orders.migrateCart = async ({ }, { multi: true, - } + }, ); Orders.updateCalculation({ orderId: fromCart._id, diff --git a/packages/core-payment/plugins/stripe.js b/packages/core-payment/plugins/stripe.js index ed8ed6c3f2..ba56adea6b 100644 --- a/packages/core-payment/plugins/stripe.js +++ b/packages/core-payment/plugins/stripe.js @@ -2,69 +2,230 @@ import { PaymentDirector, PaymentAdapter, PaymentError, + PaymentCredentials, } from 'meteor/unchained:core-payment'; +import { createLogger } from 'meteor/unchained:core-logger'; +import { WebApp } from 'meteor/webapp'; +import bodyParser from 'body-parser'; +import { OrderPayments } from 'meteor/unchained:core-orders'; +import { Users } from 'meteor/unchained:core-users'; -const { STRIPE_SECRET, EMAIL_WEBSITE_NAME } = process.env; +const { + STRIPE_SECRET, + STRIPE_ENDPOINT_SECRET, + EMAIL_WEBSITE_NAME, + STRIPE_WEBHOOK_PATH = '/graphql/stripe', +} = process.env; -class Stripe extends PaymentAdapter { - static key = 'com.stripe'; +const logger = createLogger('unchained:core-payment:stripe-webhook'); - static label = 'Stripe'; +const stripe = require('stripe')(STRIPE_SECRET); - static version = '1.0'; +/* - static initialConfiguration = [ - { - key: 'publishableAPIKey', - value: null, - }, - ]; +brew install stripe/stripe-cli/stripe +stripe login --api-key sk_.... +stripe listen --forward-to http://localhost:3000/graphql/stripe +stripe trigger payment_intent.succeeded +*/ - static typeSupported(type) { - return type === 'CARD'; +WebApp.connectHandlers.use( + STRIPE_WEBHOOK_PATH, + bodyParser.raw({ type: 'application/json' }), +); + +WebApp.connectHandlers.use(STRIPE_WEBHOOK_PATH, (request, response) => { + const sig = request.headers['stripe-signature']; + let event; + + try { + event = stripe.webhooks.constructEvent( + request.body, + sig, + STRIPE_ENDPOINT_SECRET, + ); + } catch (err) { + response.writeHead(400); + return response.end(`Webhook Error: ${err.message}`); } - getPublishableApiKey() { - return this.config.reduce((current, item) => { - if (item.key === 'publishableAPIKey') return item.value; - return current; - }, null); + if (event.type === 'payment_intent.succeeded') { + const paymentIntent = event.data.object; + const orderPaymentId = paymentIntent.metadata?.orderPaymentId; + const orderPayment = OrderPayments.findOne({ _id: orderPaymentId }); + const order = orderPayment.order().checkout({ + paymentContext: { + paymentIntentId: paymentIntent.id, + }, + }); + logger.info( + `Stripe Webhook: Unchained confirmed checkout for order ${order.orderNumber}`, + { orderId: order._id }, + ); + } else if (event.type === 'setup_intent.succeeded') { + const setupIntent = event.data.object; + const { paymentProviderId, userId } = setupIntent.metadata; + PaymentCredentials.registerPaymentCredentials({ + paymentProviderId, + paymentContext: { + setupIntentId: setupIntent.id, + }, + userId, + }); + logger.info( + `Datatrans Webhook: Unchained registered payment credentials for ${userId}`, + { userId }, + ); + } else { + response.writeHead(400); + return response.end(); + } + + // Return a 200 response to acknowledge receipt of the event + return response.end(JSON.stringify({ received: true })); +}); + +class Stripe extends PaymentAdapter { + static key = 'shop.unchained.payment.stripe'; + + static label = 'Stripe'; + + static version = '2.0'; + + static typeSupported(type) { + return type === 'GENERIC'; } - configurationError() { // eslint-disable-line - if (!this.getPublishableApiKey() || !STRIPE_SECRET) { + // eslint-disable-next-line + configurationError() { + // eslint-disable-line + if (!STRIPE_SECRET || !STRIPE_ENDPOINT_SECRET) { return PaymentError.INCOMPLETE_CONFIGURATION; } - if (this.wrongCredentials) { - return PaymentError.WRONG_CREDENTIALS; - } return null; } - isActive() { // eslint-disable-line + isActive() { if (this.configurationError() === null) return true; return false; } - isPayLaterAllowed() { // eslint-disable-line + // eslint-disable-next-line + isPayLaterAllowed() { return false; } - async charge({ stripeToken, stripeCustomerId } = {}) { - if (!stripeToken) - throw new Error('You have to provide stripeToken in paymentContext'); - const StripeAPI = require('stripe'); // eslint-disable-line - const stripe = StripeAPI(STRIPE_SECRET); - const pricing = this.context.order.pricing(); - const stripeChargeReceipt = await stripe.charges.create({ + // eslint-disable-next-line + async validate(token) { + const paymentMethod = await stripe.paymentMethods.retrieve(token); + // TODO: Add further checks like expiration of cards + return !!paymentMethod; + } + + async register({ setupIntentId }) { + if (!setupIntentId) { + throw new Error('You have to provide a setup intent id'); + } + + const setupIntent = await stripe.setupIntents.retrieve(setupIntentId); + + if (setupIntent.status === 'succeeded') { + return { + token: setupIntent.payment_method, + customer: setupIntent.customer, + payment_method_options: setupIntent.payment_method_options, + payment_method_types: setupIntent.payment_method_types, + usage: setupIntent.usage, + }; + } + + this.log('Stripe -> Registration declined', setupIntentId); + return null; + } + + static async createRegistrationIntent( + { userId, paymentProviderId }, + options = {}, + ) { + const user = Users.findOne({ _id: userId }); + const customer = await stripe.customers.create({ + metadata: { + userId, + }, + name: user.name(), + email: user.primaryEmail()?.address, + }); + const setupIntent = await stripe.setupIntents.create({ + customer: customer.id, + metadata: { + userId, + paymentProviderId, + }, + ...options, + }); + return setupIntent; + } + + static async createOrderPaymentIntent(orderPayment, options = {}) { + const order = orderPayment.order(); + const pricing = order.pricing(); + const reference = EMAIL_WEBSITE_NAME || order._id; + const paymentIntent = await stripe.paymentIntents.create({ amount: Math.round(pricing.total().amount), - currency: this.context.order.currency.toLowerCase(), - description: `${EMAIL_WEBSITE_NAME} Order #${this.context.order._id}`, - source: stripeToken.id, - customer: stripeCustomerId, + currency: order.currency.toLowerCase(), + description: `${reference} #${order.orderNumber}`, + statement_descriptor: order.orderNumber, + statement_descriptor_suffix: reference, + receipt_email: order.contact?.emailAddress, + setup_future_usage: 'off_session', // Verify your integration in this guide by including this parameter + metadata: { + orderPaymentId: orderPayment._id, + }, + ...options, }); - this.log('Stripe -> ', stripeToken, stripeChargeReceipt); - return stripeChargeReceipt; + return paymentIntent; + } + + async sign({ transactionContext = {} } = {}) { + // eslint-disable-line + const { orderPayment, userId, paymentProviderId } = this.context; + const paymentIntent = orderPayment + ? await this.constructor.createOrderPaymentIntent( + orderPayment, + transactionContext, + ) + : await this.constructor.createRegistrationIntent( + { userId, paymentProviderId }, + transactionContext, + ); + return paymentIntent.client_secret; + } + + async charge({ paymentIntentId, paymentCredentials }) { + if (!paymentIntentId && !paymentCredentials) { + throw new Error( + 'You have to provide an existing intent or a payment method', + ); + } + + const { order } = this.context; + const orderPayment = order.payment(); + const paymentIntentObject = paymentIntentId + ? await stripe.paymentIntents.retrieve(paymentIntentId) + : await this.constructor.createOrderPaymentIntent(orderPayment); + + if (paymentIntentObject.metadata?.orderPaymentId !== orderPayment?._id) { + throw new Error( + 'The order payment is different from the initiating intent!', + ); + } + + console.log(paymentIntentObject); + if (paymentIntentObject.status === 'succeeded') { + return paymentIntentObject; + } + + return false; } } diff --git a/tests/jest-global-setup.js b/tests/jest-global-setup.js index 6495a43923..d8b7ddc482 100644 --- a/tests/jest-global-setup.js +++ b/tests/jest-global-setup.js @@ -21,6 +21,7 @@ const startAndWaitForMeteor = async () => { detached: true, cwd: `${process.cwd()}/examples/minimal`, env: { + STRIPE_SECRET: 'secret', // the test key should be kept secret also, that's why this could be overwritten ...process.env, NODE_ENV: 'development', METEOR_PACKAGE_DIRS: '../../packages', @@ -29,7 +30,7 @@ const startAndWaitForMeteor = async () => { DATATRANS_SIGN_KEY: '1337', APPLE_IAP_SHARED_SECRET: '73b61776e7304f8ab1c2404df9192078', }, - } + }, ); meteorProcess = global.__SUBPROCESS_METEOR__; global.__SUBPROCESS_METEOR__.stdout.on('data', (data) => { diff --git a/tests/plugins-stripe.test.js b/tests/plugins-stripe.test.js new file mode 100644 index 0000000000..b6e4d6764a --- /dev/null +++ b/tests/plugins-stripe.test.js @@ -0,0 +1,351 @@ +import Stripe from 'stripe'; +import { createLoggedInGraphqlFetch, setupDatabase } from './helpers'; +import { USER_TOKEN } from './seeds/users'; +import { SimplePaymentProvider } from './seeds/payments'; +import { SimpleOrder, SimplePosition, SimplePayment } from './seeds/orders'; + +const { STRIPE_SECRET } = process.env; + +let connection; +let db; +let graphqlFetch; + +describe('Plugins: Stripe Payments', () => { + beforeAll(async () => { + [db, connection] = await setupDatabase(); + graphqlFetch = await createLoggedInGraphqlFetch(USER_TOKEN); + + // Add a stripe provider + await db.collection('payment-providers').findOrInsertOne({ + ...SimplePaymentProvider, + _id: 'stripe-payment-provider', + adapterKey: 'shop.unchained.payment.stripe', + type: 'GENERIC', + }); + + // Add a demo order ready to checkout + await db.collection('order_payments').findOrInsertOne({ + ...SimplePayment, + _id: 'stripe-payment', + paymentProviderId: 'stripe-payment-provider', + orderId: 'stripe-order', + }); + + await db.collection('order_positions').findOrInsertOne({ + ...SimplePosition, + _id: 'stripe-order-position', + orderId: 'stripe-order', + }); + + await db.collection('orders').findOrInsertOne({ + ...SimpleOrder, + _id: 'stripe-order', + orderNumber: 'stripe', + paymentId: 'stripe-payment', + }); + + // Add a second demo order ready to checkout + await db.collection('order_payments').findOrInsertOne({ + ...SimplePayment, + _id: 'stripe-payment2', + paymentProviderId: 'stripe-payment-provider', + orderId: 'stripe-order2', + }); + + await db.collection('order_positions').findOrInsertOne({ + ...SimplePosition, + _id: 'stripe-order-position2', + orderId: 'stripe-order2', + }); + + await db.collection('orders').findOrInsertOne({ + ...SimpleOrder, + _id: 'stripe-order2', + orderNumber: 'stripe2', + paymentId: 'stripe-payment2', + }); + }); + + afterAll(async () => { + await connection.close(); + }); + + describe('Query.signPaymentProviderForCredentialRegistration (Stripe)', () => { + let idAndSecret; + it('Request a new client secret for the purpose of registration', async () => { + const { + data: { signPaymentProviderForCredentialRegistration } = {}, + } = await graphqlFetch({ + query: /* GraphQL */ ` + query signPaymentProviderForCredentialRegistration( + $paymentProviderId: ID! + ) { + signPaymentProviderForCredentialRegistration( + paymentProviderId: $paymentProviderId + ) + } + `, + variables: { + paymentProviderId: 'stripe-payment-provider', + }, + }); + + expect(signPaymentProviderForCredentialRegistration).not.toBe(''); + expect(signPaymentProviderForCredentialRegistration).not.toBe(null); + expect(signPaymentProviderForCredentialRegistration).not.toBe(undefined); + idAndSecret = signPaymentProviderForCredentialRegistration.split( + '_secret_', + ); + }); + it('Confirm the setup intent', async () => { + const stripe = Stripe(STRIPE_SECRET); + const method = await stripe.paymentMethods.create({ + type: 'card', + card: { + number: '4242424242424242', + exp_month: 6, + exp_year: 2021, + cvc: '314', + }, + }); + const confirmedIntent = await stripe.setupIntents.confirm( + idAndSecret[0], + { + payment_method: method.id, + }, + ); + expect(confirmedIntent).toMatchObject({ + status: 'succeeded', + }); + + const { data: { registerPaymentCredentials } = {} } = await graphqlFetch({ + query: /* GraphQL */ ` + mutation register($paymentProviderId: ID!, $paymentContext: JSON!) { + registerPaymentCredentials( + paymentProviderId: $paymentProviderId + paymentContext: $paymentContext + ) { + _id + token + isValid + isPreferred + } + } + `, + variables: { + paymentProviderId: confirmedIntent.metadata.paymentProviderId, + paymentContext: { + setupIntentId: confirmedIntent.id, + }, + }, + }); + expect(registerPaymentCredentials).toMatchObject({ + isValid: true, + isPreferred: true, + }); + }); + }); + + describe('OrderPaymentGeneric.sign (Stripe)', () => { + let idAndSecret; + it('Request a new client secret', async () => { + const { data: { me } = {} } = await graphqlFetch({ + query: /* GraphQL */ ` + query sign($transactionContext: JSON, $orderNumber: String) { + me { + cart(orderNumber: $orderNumber) { + _id + payment { + _id + ... on OrderPaymentGeneric { + sign(transactionContext: $transactionContext) + } + } + } + } + } + `, + variables: { + orderNumber: 'stripe', + transactionContext: {}, + }, + }); + + expect(me.cart.payment.sign).not.toBe(''); + expect(me.cart.payment.sign).not.toBe(null); + expect(me.cart.payment.sign).not.toBe(undefined); + idAndSecret = me.cart.payment.sign.split('_secret_'); + }); + it('Confirm the payment and checkout the order', async () => { + const stripe = Stripe(STRIPE_SECRET); + const method = await stripe.paymentMethods.create({ + type: 'card', + card: { + number: '4242424242424242', + exp_month: 6, + exp_year: 2021, + cvc: '314', + }, + }); + const confirmedIntent = await stripe.paymentIntents.confirm( + idAndSecret[0], + { + payment_method: method.id, + }, + ); + expect(confirmedIntent).toMatchObject({ + status: 'succeeded', + }); + + const { data: { checkoutCart } = {} } = await graphqlFetch({ + query: /* GraphQL */ ` + mutation checkout($orderId: ID, $paymentContext: JSON) { + checkoutCart(orderId: $orderId, paymentContext: $paymentContext) { + _id + status + } + } + `, + variables: { + orderId: 'stripe-order', + paymentContext: { + paymentIntentId: confirmedIntent.id, + }, + }, + }); + expect(checkoutCart).toMatchObject({ + status: 'CONFIRMED', + }); + }); + }); + + // describe('Stripe Hooks', () => { + // it('mocks ingress declined payment webhook call', async () => { + // }); + // + // it('mocks ingress successful payment webhook call', async () => { + // }); + // + // it('mocks ingress successful payment webhook call with alias', async () => { + // }); + // + // it('mocks ingress successful payment webhook call with register', async () => { + // }); + + describe('Checkout', () => { + it('checkout with stored alias', async () => { + const { data: { me } = {} } = await graphqlFetch({ + query: /* GraphQL */ ` + query { + me { + paymentCredentials { + _id + user { + _id + } + paymentProvider { + _id + } + meta + token + isValid + isPreferred + } + } + } + `, + }); + const credentials = me?.paymentCredentials?.[0]; + expect(credentials).toMatchObject({ + isPreferred: true, + isValid: true, + meta: { + customer: expect.anything(), + usage: 'off_session', + }, + token: expect.anything(), + paymentProvider: { _id: 'stripe-payment-provider' }, + user: { _id: 'user' }, + }); + + const { + data: { addCartProduct, updateCart, checkoutCart } = {}, + } = await graphqlFetch({ + query: /* GraphQL */ ` + mutation addAndCheckout( + $productId: ID! + $paymentContext: JSON + $paymentProviderId: ID + ) { + addCartProduct(productId: $productId) { + _id + } + updateCart(paymentProviderId: $paymentProviderId) { + _id + status + payment { + provider { + _id + } + } + } + checkoutCart(paymentContext: $paymentContext) { + _id + status + } + } + `, + variables: { + productId: 'simpleproduct', + paymentProviderId: 'stripe-payment-provider', + paymentContext: { + paymentCredentials: credentials, + }, + }, + }); + expect(addCartProduct).toMatchObject(expect.anything()); + expect(updateCart).toMatchObject({ + status: 'OPEN', + payment: { + provider: { + _id: 'stripe-payment-provider', + }, + }, + }); + expect(checkoutCart).toMatchObject({ + status: 'CONFIRMED', + }); + }); + // it('checkout with preferred alias', async () => { + // const { + // data: { addCartProduct, updateCart, checkoutCart } = {}, + // } = await graphqlFetch({ + // query: /* GraphQL */ ` + // mutation addAndCheckout($productId: ID!) { + // addCartProduct(productId: $productId) { + // _id + // } + // updateCart(paymentProviderId: "stripe-payment-provider") { + // _id + // status + // } + // checkoutCart { + // _id + // status + // } + // } + // `, + // variables: { + // productId: 'simpleproduct', + // }, + // }); + // expect(addCartProduct).toMatchObject(expect.anything()); + // expect(updateCart).toMatchObject({ + // status: 'OPEN', + // }); + // expect(checkoutCart).toMatchObject({ + // status: 'CONFIRMED', + // }); + // }); + }); +}); From 582fd7e9364bd4419faa311683d43f4ec1aff93f Mon Sep 17 00:00:00 2001 From: Pascal Kaufmann Date: Wed, 10 Jun 2020 10:07:38 +0200 Subject: [PATCH 2/4] Lint --- packages/api/acl.js | 2 +- packages/api/callMethod.js | 2 +- packages/api/errors.js | 66 ++++++------- .../mutations/accounts/changePassword.js | 4 +- .../mutations/accounts/loginWithPassword.js | 4 +- .../mutations/accounts/resetPassword.js | 2 +- .../resolvers/mutations/addAssortmentLink.js | 4 +- .../resolvers/mutations/addCartDiscount.js | 2 +- .../api/resolvers/mutations/addCartProduct.js | 4 +- .../resolvers/mutations/addCartQuotation.js | 4 +- packages/api/resolvers/mutations/addEmail.js | 2 +- .../mutations/addMultipleCartProducts.js | 4 +- .../api/resolvers/mutations/checkoutCart.js | 2 +- .../api/resolvers/mutations/confirmOrder.js | 2 +- .../api/resolvers/mutations/createBookmark.js | 2 +- .../api/resolvers/mutations/createCart.js | 2 +- .../resolvers/mutations/createFilterOption.js | 4 +- .../mutations/createProductVariation.js | 2 +- .../mutations/createProductVariationOption.js | 4 +- .../resolvers/mutations/createSubscription.js | 2 +- packages/api/resolvers/mutations/emptyCart.js | 2 +- .../api/resolvers/mutations/finishWork.js | 2 +- packages/api/resolvers/mutations/heartbeat.js | 2 +- packages/api/resolvers/mutations/index.js | 52 +++++----- .../mutations/makeQuotationProposal.js | 2 +- .../resolvers/mutations/rejectQuotation.js | 2 +- .../api/resolvers/mutations/removeEmail.js | 2 +- .../resolvers/mutations/removeFilterOption.js | 2 +- .../api/resolvers/mutations/removeProduct.js | 2 +- .../mutations/removeProductVariationOption.js | 4 +- .../resolvers/mutations/requestQuotation.js | 6 +- .../resolvers/mutations/setBaseAssortment.js | 4 +- .../api/resolvers/mutations/setBaseCountry.js | 4 +- .../resolvers/mutations/setBaseLanguage.js | 4 +- .../api/resolvers/mutations/setPassword.js | 2 +- .../api/resolvers/mutations/setUserTags.js | 2 +- .../api/resolvers/mutations/setUsername.js | 2 +- .../resolvers/mutations/updateAssortment.js | 2 +- .../mutations/updateAssortmentTexts.js | 2 +- .../api/resolvers/mutations/updateCart.js | 2 +- .../api/resolvers/mutations/updateCartItem.js | 10 +- .../api/resolvers/mutations/updateCountry.js | 2 +- .../api/resolvers/mutations/updateCurrency.js | 4 +- .../mutations/updateDeliveryProvider.js | 2 +- .../api/resolvers/mutations/updateEmail.js | 2 +- .../resolvers/mutations/updateFilterTexts.js | 4 +- .../api/resolvers/mutations/updateLanguage.js | 2 +- .../mutations/updateProductMediaTexts.js | 2 +- .../resolvers/mutations/updateProductTexts.js | 2 +- .../mutations/updateProductVariationTexts.js | 4 +- .../resolvers/mutations/updateSubscription.js | 2 +- .../resolvers/mutations/updateUserAvatar.js | 6 +- .../resolvers/mutations/updateUserProfile.js | 2 +- .../mutations/updateWarehousingProvider.js | 2 +- .../resolvers/mutations/verifyQuotation.js | 2 +- packages/api/resolvers/queries/assortments.js | 4 +- packages/api/resolvers/queries/countries.js | 2 +- packages/api/resolvers/queries/currencies.js | 2 +- .../resolvers/queries/deliveryInterfaces.js | 2 +- packages/api/resolvers/queries/index.js | 14 +-- packages/api/resolvers/queries/languages.js | 2 +- .../resolvers/queries/paymentInterfaces.js | 2 +- .../resolvers/queries/productCatalogPrices.js | 2 +- packages/api/resolvers/queries/products.js | 4 +- ...aymentProviderForCredentialRegistration.js | 2 +- .../translatedProductVariationTexts.js | 4 +- packages/api/resolvers/queries/users.js | 2 +- .../queries/warehousingInterfaces.js | 2 +- .../resolvers/queries/warehousingProvider.js | 2 +- packages/api/resolvers/queries/workQueue.js | 2 +- .../resolvers/types/assortment-path-link.js | 4 +- .../api/resolvers/types/delivery-provider.js | 2 +- packages/api/resolvers/types/dispatch.js | 2 +- packages/api/resolvers/types/filter-option.js | 2 +- .../resolvers/types/order-delivery-pickup.js | 2 +- packages/api/resolvers/types/plan-product.js | 4 +- .../types/product-variation-option.js | 2 +- packages/api/resolvers/types/search-result.js | 6 +- .../api/resolvers/types/simple-product.js | 8 +- packages/api/resolvers/types/stock.js | 2 +- packages/api/resolvers/types/user.js | 10 +- packages/api/roles/all.js | 6 +- packages/api/roles/loggedIn.js | 4 +- .../breadcrumbs/build-paths.js | 8 +- packages/core-assortments/db/helpers.js | 94 +++++++++---------- packages/core-assortments/db/schema.js | 20 ++-- .../tree-zipper/zipTreeByDeepness.js | 2 +- packages/core-bookmarks/db/helpers.js | 2 +- packages/core-bookmarks/db/schema.js | 4 +- packages/core-countries/db/schema.js | 4 +- packages/core-currencies/db/schema.js | 4 +- packages/core-delivery/db/helpers.js | 24 ++--- packages/core-delivery/db/schema.js | 8 +- packages/core-delivery/director.js | 2 +- packages/core-delivery/plugins/pick-mup.js | 2 +- packages/core-delivery/settings.js | 2 +- packages/core-discounting/director.js | 12 +-- packages/core-documents/director.js | 8 +- .../core-documents/plugins/smallinvoice.js | 6 +- .../createFilesCollection/FilesCollection.js | 6 +- .../core-files/createFilesCollection/index.js | 2 +- .../createFilesCollection/types/gridfs.js | 10 +- packages/core-filters/db/helpers.js | 34 +++---- packages/core-filters/db/schema.js | 8 +- packages/core-filters/director.js | 6 +- packages/core-filters/search/index.js | 4 +- .../core-filters/search/parse-query-array.js | 2 +- packages/core-languages/db/schema.js | 4 +- packages/core-logger/createLogger.js | 4 +- packages/core-logger/db/schema.js | 10 +- packages/core-messaging/director.js | 2 +- packages/core-messaging/worker/message.js | 2 +- .../db/order-deliveries/helpers.js | 6 +- .../core-orders/db/order-deliveries/schema.js | 4 +- .../core-orders/db/order-discounts/helpers.js | 12 +-- .../core-orders/db/order-discounts/schema.js | 4 +- .../core-orders/db/order-documents/helpers.js | 8 +- .../core-orders/db/order-payments/helpers.js | 8 +- .../core-orders/db/order-payments/schema.js | 4 +- .../core-orders/db/order-positions/helpers.js | 28 +++--- .../core-orders/db/order-positions/schema.js | 4 +- packages/core-orders/db/orders/schema.js | 4 +- packages/core-payment/db/helpers.js | 24 ++--- packages/core-payment/db/schema.js | 12 +-- packages/core-payment/director.js | 4 +- packages/core-payment/plugins/apple-iap.js | 24 ++--- packages/core-payment/plugins/coinbase.js | 2 +- packages/core-payment/plugins/datatrans.js | 38 ++++---- .../core-payment/plugins/paypal-checkout.js | 2 +- packages/core-payment/plugins/paypal.js | 2 +- packages/core-payment/settings.js | 2 +- .../core-pricing/delivery-pricing/director.js | 10 +- .../core-pricing/delivery-pricing/sheet.js | 2 +- .../core-pricing/order-pricing/director.js | 8 +- packages/core-pricing/order-pricing/sheet.js | 6 +- .../core-pricing/payment-pricing/director.js | 8 +- .../core-pricing/payment-pricing/sheet.js | 2 +- .../core-pricing/plugins/order-discount.js | 18 ++-- packages/core-pricing/plugins/order-items.js | 2 +- packages/core-pricing/pricing-sheet.js | 6 +- .../core-pricing/product-pricing/director.js | 8 +- .../core-pricing/product-pricing/sheet.js | 2 +- .../core-products/db/product-media/helpers.js | 6 +- .../core-products/db/product-media/schema.js | 8 +- .../db/product-reviews/helpers.js | 10 +- .../db/product-reviews/schema.js | 4 +- .../db/product-variations/collections.js | 2 +- .../db/product-variations/helpers.js | 10 +- .../db/product-variations/schema.js | 8 +- packages/core-products/db/products/helpers.js | 42 ++++----- packages/core-products/db/products/schema.js | 18 ++-- .../db/quotation-documents/helpers.js | 2 +- .../core-quotations/db/quotations/helpers.js | 18 ++-- .../core-quotations/db/quotations/schema.js | 8 +- packages/core-quotations/director.js | 4 +- .../db/subscriptions/helpers.js | 30 +++--- .../db/subscriptions/schema.js | 4 +- packages/core-subscriptions/director.js | 18 ++-- .../worker/generate-orders.js | 2 +- packages/core-users/db/helpers.js | 14 +-- packages/core-users/db/schema.js | 16 ++-- packages/core-users/patch-accounts.js | 4 +- packages/core-warehousing/db/collections.js | 2 +- packages/core-warehousing/db/helpers.js | 12 +-- packages/core-warehousing/db/schema.js | 4 +- packages/core-warehousing/director.js | 4 +- .../core-warehousing/plugins/google-sheets.js | 6 +- packages/core-worker/db/schema.js | 10 +- packages/core-worker/director.js | 18 ++-- .../schedulers/failedRescheduler.js | 8 +- packages/core-worker/workers/base.js | 6 +- packages/core-worker/workers/interval.js | 4 +- packages/core/find-localized-text.js | 4 +- packages/core/locale-context.js | 12 +-- packages/platform/fixtures.js | 22 ++--- packages/platform/intercept-emails.js | 4 +- packages/platform/setup-accounts.js | 6 +- packages/platform/setup-templates.js | 10 +- packages/platform/setup-workqueue.js | 4 +- packages/platform/templates/account-action.js | 2 +- .../platform/templates/forward-delivery.js | 2 +- .../platform/templates/order-confirmation.js | 2 +- packages/utils/address-schema.js | 2 +- packages/utils/contact-schema.js | 2 +- packages/utils/find-preserving-ids.js | 2 +- tests/auth-admin.test.js | 2 +- tests/filter-option.test.js | 2 +- tests/helpers.js | 2 +- tests/order-deliveries.test.js | 2 +- tests/product-variation.test.js | 2 +- tests/public-queries.test.js | 8 +- tests/setup-basic.test.js | 2 +- tests/worker.test.js | 24 ++--- 193 files changed, 676 insertions(+), 676 deletions(-) diff --git a/packages/api/acl.js b/packages/api/acl.js index 2885a600aa..07afe88115 100644 --- a/packages/api/acl.js +++ b/packages/api/acl.js @@ -28,7 +28,7 @@ const checkAction = ( action, userId, args = emptyArray, - options = emptyObject + options = emptyObject, ) => { const { key } = options || emptyObject; const hasPermission = checkPermission(userId, action, ...args); diff --git a/packages/api/callMethod.js b/packages/api/callMethod.js index 86ee81e47e..61ea011234 100755 --- a/packages/api/callMethod.js +++ b/packages/api/callMethod.js @@ -6,7 +6,7 @@ const filterContext = (graphqlContext) => { Object.entries(graphqlContext).filter(([key]) => { if (key.substr(0, 1) === '_') return false; return true; - }) + }), ); }; diff --git a/packages/api/errors.js b/packages/api/errors.js index 8b383010f4..5a85445459 100644 --- a/packages/api/errors.js +++ b/packages/api/errors.js @@ -9,137 +9,137 @@ export const createError = (code, message) => export const PermissionSystemError = createError( 'PermissionSystemError', - 'Permission System Error' + 'Permission System Error', ); export const NoPermissionError = createError( 'NoPermissionError', - 'Not authorized' + 'Not authorized', ); export const ProductNotFoundError = createError( 'ProductNotFoundError', - 'Product not found' + 'Product not found', ); export const ProductVariationNotFoundError = createError( 'ProductVariationNotFoundError', - 'Product variation not found' + 'Product variation not found', ); export const ProductMediaNotFoundError = createError( 'ProductMediaNotFoundError', - 'Product media not found' + 'Product media not found', ); export const ProductReviewNotFoundError = createError( 'ProductReviewNotFoundError', - 'ProductReview not found' + 'ProductReview not found', ); export const ProductWrongStatusError = createError( 'ProductWrongStatusError', - 'The current status of the product does not allow this operation' + 'The current status of the product does not allow this operation', ); export const AssortmentNotFoundError = createError( 'AssortmentNotFoundError', - 'Assortment not found' + 'Assortment not found', ); export const FilterNotFoundError = createError( 'FilterNotFoundError', - 'Filter not found' + 'Filter not found', ); export const UserNotFoundError = createError( 'UserNotFoundError', - 'Product not found' + 'Product not found', ); export const UserNoCartError = createError( 'UserNoCartError', - 'No open cart available to checkout' + 'No open cart available to checkout', ); export const OrderItemNotFoundError = createError( 'OrderItemNotFoundError', - 'Order Item not found' + 'Order Item not found', ); export const OrderNotFoundError = createError( 'OrderNotFoundError', - 'Order not found' + 'Order not found', ); export const OrderNumberAlreadyExistsError = createError( 'OrderNumberAlreadyExistsError', - 'This orderNumber has already been used by another order' + 'This orderNumber has already been used by another order', ); export const OrderDiscountNotFoundError = createError( 'OrderDiscountNotFoundError', - 'Order discount not found' + 'Order discount not found', ); export const OrderDeliveryNotFoundError = createError( 'OrderDeliveryNotFoundError', - 'Order delivery not found' + 'Order delivery not found', ); export const OrderPaymentNotFoundError = createError( 'OrderDeliveryNotFoundError', - 'Order delivery not found' + 'Order delivery not found', ); export const OrderQuantityTooLowError = createError( 'OrderQuantityTooLowError', - 'Quantity cannot be lower than 1' + 'Quantity cannot be lower than 1', ); export const OrderWrongPaymentStatusError = createError( 'OrderWrongPaymentStatus', - 'The current status of the payment does not allow this operation' + 'The current status of the payment does not allow this operation', ); export const OrderWrongDeliveryStatusError = createError( 'OrderWrongDeliveryStatus', - 'The current status of the delivery does not allow this operation' + 'The current status of the delivery does not allow this operation', ); export const OrderWrongStatusError = createError( 'OrderWrongStatusError', - 'The current status of the order does not allow this operation' + 'The current status of the order does not allow this operation', ); export const OrderCheckoutError = createError( 'OrderCheckoutError', - 'A problem occured while processing the order' + 'A problem occured while processing the order', ); export const OrderPaymentConfigurationError = createError( 'OrderPaymentConfigurationError', - 'Payment configuration invalid' + 'Payment configuration invalid', ); export const QuotationWrongStatusError = createError( 'QuotationWrongStatusError', - 'The current status of the quotation does not allow this operation' + 'The current status of the quotation does not allow this operation', ); export const QuotationNotFoundError = createError( 'QuotationNotFoundError', - 'Quotation not found' + 'Quotation not found', ); export const BookmarkAlreadyExistsError = createError( 'BookmarkAlreadyExistsError', - 'Bookmark already exists' + 'Bookmark already exists', ); export const BookmarkNotFoundError = createError( 'BookmarkNotFoundError', - 'Bookmark not found' + 'Bookmark not found', ); export const QueryStringRequiredError = createError( 'QueryStringRequiredError', - 'Query string is required if no assortmentId is provided' + 'Query string is required if no assortmentId is provided', ); export const PaymentProviderNotFoundError = createError( 'PaymentProviderNotFoundError', - 'Payment provider not found' + 'Payment provider not found', ); export const WorkNotFoundOrWrongStatus = createError( 'WorkNotFoundOrWrongStatus', - 'Could not find work or no work with the correct status' + 'Could not find work or no work with the correct status', ); export const PaymentCredentialsNotFoundError = createError( 'PaymentCredentialsNotFoundError', - 'Payment credentials not found' + 'Payment credentials not found', ); export const SubscriptionWrongStatusError = createError( 'SubscriptionWrongStatusError', - 'The current status of the subscription does not allow this operation' + 'The current status of the subscription does not allow this operation', ); export const SubscriptionNotFoundError = createError( 'SubscriptionNotFoundError', - 'Subscription not found' + 'Subscription not found', ); diff --git a/packages/api/resolvers/mutations/accounts/changePassword.js b/packages/api/resolvers/mutations/accounts/changePassword.js index 19aa7c4602..2f9d9d8910 100755 --- a/packages/api/resolvers/mutations/accounts/changePassword.js +++ b/packages/api/resolvers/mutations/accounts/changePassword.js @@ -9,7 +9,7 @@ export default async function ( newPassword: newHashedPassword, newPlainPassword, }, - context + context, ) { if (!newHashedPassword && !newPlainPassword) { throw new Error('New password is required'); @@ -24,7 +24,7 @@ export default async function ( context, 'changePassword', oldPassword, - newPassword + newPassword, ); return { success: passwordChanged, diff --git a/packages/api/resolvers/mutations/accounts/loginWithPassword.js b/packages/api/resolvers/mutations/accounts/loginWithPassword.js index d0be2f0fca..36d7dad6d0 100755 --- a/packages/api/resolvers/mutations/accounts/loginWithPassword.js +++ b/packages/api/resolvers/mutations/accounts/loginWithPassword.js @@ -6,7 +6,7 @@ import getUserLoginMethod from './getUserLoginMethod'; export default async function ( root, { username, email, password: hashedPassword, plainPassword }, - context + context, ) { if (!hashedPassword && !plainPassword) { throw new Error('Password is required'); @@ -26,7 +26,7 @@ export default async function ( if (method === 'no-password') { throw new Meteor.Error( 'no-password', - 'User has no password set, go to forgot password' + 'User has no password set, go to forgot password', ); } else if (method) { throw new Error(`User is registered with ${method}.`); diff --git a/packages/api/resolvers/mutations/accounts/resetPassword.js b/packages/api/resolvers/mutations/accounts/resetPassword.js index ef86ada001..394bd6923c 100755 --- a/packages/api/resolvers/mutations/accounts/resetPassword.js +++ b/packages/api/resolvers/mutations/accounts/resetPassword.js @@ -4,7 +4,7 @@ import hashPassword from '../../../hashPassword'; export default async function ( root, { token, newPlainPassword, newPassword: newHashedPassword }, - context + context, ) { if (!newHashedPassword && !newPlainPassword) { throw new Error('Password is required'); diff --git a/packages/api/resolvers/mutations/addAssortmentLink.js b/packages/api/resolvers/mutations/addAssortmentLink.js index 2264abff42..c65213e4e5 100644 --- a/packages/api/resolvers/mutations/addAssortmentLink.js +++ b/packages/api/resolvers/mutations/addAssortmentLink.js @@ -5,11 +5,11 @@ import { AssortmentNotFoundError } from '../../errors'; export default function ( root, { parentAssortmentId, childAssortmentId, tags }, - { userId } + { userId }, ) { log( `mutation addAssortmentLink ${parentAssortmentId} -> ${childAssortmentId}`, - { userId } + { userId }, ); const parent = Assortments.findOne({ _id: parentAssortmentId }); const child = Assortments.findOne({ _id: childAssortmentId }); diff --git a/packages/api/resolvers/mutations/addCartDiscount.js b/packages/api/resolvers/mutations/addCartDiscount.js index eb84d6bcc9..fa53c1146a 100644 --- a/packages/api/resolvers/mutations/addCartDiscount.js +++ b/packages/api/resolvers/mutations/addCartDiscount.js @@ -4,7 +4,7 @@ import getCart from '../../getCart'; export default async function ( root, { orderId, code }, - { userId, user, countryContext } + { userId, user, countryContext }, ) { log(`mutation addCartDiscount ${code} ${orderId}`, { userId, orderId }); const cart = await getCart({ orderId, user, countryContext }); diff --git a/packages/api/resolvers/mutations/addCartProduct.js b/packages/api/resolvers/mutations/addCartProduct.js index 669ab4efbe..cc13fe0331 100644 --- a/packages/api/resolvers/mutations/addCartProduct.js +++ b/packages/api/resolvers/mutations/addCartProduct.js @@ -6,13 +6,13 @@ import getCart from '../../getCart'; export default async function ( root, { orderId, productId, quantity, configuration }, - { user, userId, countryContext } + { user, userId, countryContext }, ) { log( `mutation addCartProduct ${productId} ${quantity} ${ configuration ? JSON.stringify(configuration) : '' }`, - { userId, orderId } + { userId, orderId }, ); if (quantity < 1) throw new OrderQuantityTooLowError({ quantity }); const product = Products.findOne({ _id: productId }); diff --git a/packages/api/resolvers/mutations/addCartQuotation.js b/packages/api/resolvers/mutations/addCartQuotation.js index 1504edcce5..475d3c5381 100644 --- a/packages/api/resolvers/mutations/addCartQuotation.js +++ b/packages/api/resolvers/mutations/addCartQuotation.js @@ -10,13 +10,13 @@ import getCart from '../../getCart'; export default async function ( root, { orderId, quotationId, quantity, configuration }, - { user, userId, countryContext } + { user, userId, countryContext }, ) { log( `mutation addCartQuotation ${quotationId} ${quantity} ${ configuration ? JSON.stringify(configuration) : '' }`, - { userId, orderId } + { userId, orderId }, ); if (quantity < 1) throw new OrderQuantityTooLowError({ quantity }); const quotation = Quotations.findOne({ _id: quotationId }); diff --git a/packages/api/resolvers/mutations/addEmail.js b/packages/api/resolvers/mutations/addEmail.js index 9b874beff9..8f536396ff 100644 --- a/packages/api/resolvers/mutations/addEmail.js +++ b/packages/api/resolvers/mutations/addEmail.js @@ -5,7 +5,7 @@ import { UserNotFoundError } from '../../errors'; export default function ( root, { email, userId: foreignUserId }, - { userId: ownUserId } + { userId: ownUserId }, ) { log(`mutation addEmail ${email} ${foreignUserId}`, { userId: ownUserId }); const userId = foreignUserId || ownUserId; diff --git a/packages/api/resolvers/mutations/addMultipleCartProducts.js b/packages/api/resolvers/mutations/addMultipleCartProducts.js index 9929c85515..2c9ac096e9 100644 --- a/packages/api/resolvers/mutations/addMultipleCartProducts.js +++ b/packages/api/resolvers/mutations/addMultipleCartProducts.js @@ -6,7 +6,7 @@ import getCart from '../../getCart'; export default async function ( root, { orderId, items }, - { user, userId, countryContext } + { user, userId, countryContext }, ) { /* verify existence of products */ const itemsWithProducts = items.map(({ productId, ...item }) => { @@ -29,7 +29,7 @@ export default async function ( `mutation addCartProduct ${product._id} ${quantity} ${ configuration ? JSON.stringify(configuration) : '' }`, - { userId, orderId } + { userId, orderId }, ); return cart.addProductItem({ product, quantity, configuration }); }); diff --git a/packages/api/resolvers/mutations/checkoutCart.js b/packages/api/resolvers/mutations/checkoutCart.js index c5be0af6e6..7dbd6adbf1 100644 --- a/packages/api/resolvers/mutations/checkoutCart.js +++ b/packages/api/resolvers/mutations/checkoutCart.js @@ -5,7 +5,7 @@ import getCart from '../../getCart'; export default async function ( root, { orderId, ...transactionContext }, - { user, userId, countryContext, localeContext } + { user, userId, countryContext, localeContext }, ) { log('mutation checkoutCart', { orderId, userId }); const cart = await getCart({ orderId, user, countryContext }); diff --git a/packages/api/resolvers/mutations/confirmOrder.js b/packages/api/resolvers/mutations/confirmOrder.js index 3345fbada6..560b7c9800 100644 --- a/packages/api/resolvers/mutations/confirmOrder.js +++ b/packages/api/resolvers/mutations/confirmOrder.js @@ -5,7 +5,7 @@ import { OrderNotFoundError, OrderWrongStatusError } from '../../errors'; export default function ( root, { orderId, ...transactionContext }, - { userId, localeContext } + { userId, localeContext }, ) { log('mutation confirmOrder', { orderId, userId }); const order = Orders.findOne({ _id: orderId }); diff --git a/packages/api/resolvers/mutations/createBookmark.js b/packages/api/resolvers/mutations/createBookmark.js index c1799fa048..cae2f52c5d 100644 --- a/packages/api/resolvers/mutations/createBookmark.js +++ b/packages/api/resolvers/mutations/createBookmark.js @@ -5,7 +5,7 @@ import { BookmarkAlreadyExistsError } from '../../errors'; export default function ( root, { productId, userId: foreignUserId }, - { userId } + { userId }, ) { log(`mutation createBookmark for ${foreignUserId}`, { productId, userId }); const foundBookmark = Bookmarks.findBookmarks({ diff --git a/packages/api/resolvers/mutations/createCart.js b/packages/api/resolvers/mutations/createCart.js index 1ac86c309b..15d9a5f52f 100644 --- a/packages/api/resolvers/mutations/createCart.js +++ b/packages/api/resolvers/mutations/createCart.js @@ -6,7 +6,7 @@ import { OrderNumberAlreadyExistsError, UserNotFoundError } from '../../errors'; export default async function ( root, { orderNumber }, - { countryContext, userId, user } + { countryContext, userId, user }, ) { log('mutation createCart', { userId }); const order = Orders.findOne({ orderNumber }); diff --git a/packages/api/resolvers/mutations/createFilterOption.js b/packages/api/resolvers/mutations/createFilterOption.js index f9416ef861..5fd758a178 100644 --- a/packages/api/resolvers/mutations/createFilterOption.js +++ b/packages/api/resolvers/mutations/createFilterOption.js @@ -4,7 +4,7 @@ import { Filters } from 'meteor/unchained:core-filters'; export default function ( root, { option: inputData, filterId }, - { localeContext, userId } + { localeContext, userId }, ) { log(`mutation createFilterOption ${filterId}`, { userId }); const { value, title } = inputData; @@ -17,7 +17,7 @@ export default function ( $addToSet: { options: value, }, - } + }, ); const filter = Filters.findOne({ _id: filterId }); filter.upsertLocalizedText(localeContext.language, { diff --git a/packages/api/resolvers/mutations/createProductVariation.js b/packages/api/resolvers/mutations/createProductVariation.js index efd5470d02..4bf156f404 100644 --- a/packages/api/resolvers/mutations/createProductVariation.js +++ b/packages/api/resolvers/mutations/createProductVariation.js @@ -9,7 +9,7 @@ import { ProductNotFoundError } from '../../errors'; export default function ( root, { variation: inputData, productId }, - { localeContext, userId } + { localeContext, userId }, ) { log(`mutation createProductVariation ${productId}`, { userId }); const { key, type, title } = inputData; diff --git a/packages/api/resolvers/mutations/createProductVariationOption.js b/packages/api/resolvers/mutations/createProductVariationOption.js index e270f3f279..2a2d2edb58 100644 --- a/packages/api/resolvers/mutations/createProductVariationOption.js +++ b/packages/api/resolvers/mutations/createProductVariationOption.js @@ -5,7 +5,7 @@ import { ProductVariationNotFoundError } from '../../errors'; export default function ( root, { option: inputData, productVariationId }, - { localeContext, userId } + { localeContext, userId }, ) { log(`mutation createProductVariationOption ${productVariationId}`, { userId, @@ -25,7 +25,7 @@ export default function ( $addToSet: { options: value, }, - } + }, ); variation.upsertLocalizedText(localeContext.language, { diff --git a/packages/api/resolvers/mutations/createSubscription.js b/packages/api/resolvers/mutations/createSubscription.js index 1eb3910628..f4a9170317 100644 --- a/packages/api/resolvers/mutations/createSubscription.js +++ b/packages/api/resolvers/mutations/createSubscription.js @@ -10,7 +10,7 @@ import { export default async function ( root, { contact, plan, billingAddress, payment, delivery, meta }, - { countryContext, userId, user } + { countryContext, userId, user }, ) { log('mutation createSubscription', { userId }); if (!user) throw new UserNotFoundError({ userId }); diff --git a/packages/api/resolvers/mutations/emptyCart.js b/packages/api/resolvers/mutations/emptyCart.js index 5f69d862b4..fc587b0c9e 100644 --- a/packages/api/resolvers/mutations/emptyCart.js +++ b/packages/api/resolvers/mutations/emptyCart.js @@ -5,7 +5,7 @@ import getCart from '../../getCart'; export default async function ( root, { orderId }, - { user, userId, countryContext } + { user, userId, countryContext }, ) { log('mutation emptyCart', { userId, orderId }); const cart = await getCart({ orderId, user, countryContext }); diff --git a/packages/api/resolvers/mutations/finishWork.js b/packages/api/resolvers/mutations/finishWork.js index 6448f65e3d..044edd633d 100644 --- a/packages/api/resolvers/mutations/finishWork.js +++ b/packages/api/resolvers/mutations/finishWork.js @@ -5,7 +5,7 @@ import { WorkNotFoundOrWrongStatus } from '../../errors'; export default async function ( root, { workId, result, error, success, worker, started, finished }, - { userId } + { userId }, ) { log(`mutation finishWork ${workId} ${success} ${worker}`, { userId, diff --git a/packages/api/resolvers/mutations/heartbeat.js b/packages/api/resolvers/mutations/heartbeat.js index ce298584fb..906438dbea 100644 --- a/packages/api/resolvers/mutations/heartbeat.js +++ b/packages/api/resolvers/mutations/heartbeat.js @@ -4,7 +4,7 @@ import { Users } from 'meteor/unchained:core-users'; export default function ( root, params, - { userId, remoteAddress, localeContext, countryContext } + { userId, remoteAddress, localeContext, countryContext }, ) { log(`mutation updateHeartbeat ${remoteAddress}`, { userId }); Users.updateHeartbeat({ diff --git a/packages/api/resolvers/mutations/index.js b/packages/api/resolvers/mutations/index.js index 21e00cefbb..f0640304ad 100755 --- a/packages/api/resolvers/mutations/index.js +++ b/packages/api/resolvers/mutations/index.js @@ -134,13 +134,13 @@ export default { setRoles: acl(actions.manageUsers)(setRoles), enrollUser: acl(actions.manageUsers)(enrollUser), registerPaymentCredentials: acl(actions.registerPaymentCredentials)( - registerPaymentCredentials + registerPaymentCredentials, ), markPaymentCredentialsPreferred: acl(actions.managePaymentCredentials)( - markPaymentCredentialsPreferred + markPaymentCredentialsPreferred, ), removePaymentCredentials: acl(actions.managePaymentCredentials)( - removePaymentCredentials + removePaymentCredentials, ), createLanguage: acl(actions.manageLanguages)(createLanguage), @@ -165,22 +165,22 @@ export default { removeProductMedia: acl(actions.manageProducts)(removeProductMedia), updateProductCommerce: acl(actions.manageProducts)(updateProductCommerce), updateProductWarehousing: acl(actions.manageProducts)( - updateProductWarehousing + updateProductWarehousing, ), updateProductSupply: acl(actions.manageProducts)(updateProductSupply), updateProductPlan: acl(actions.manageProducts)(updateProductPlan), removeProductVariation: acl(actions.manageProducts)(removeProductVariation), updateProductVariationTexts: acl(actions.manageProducts)( - updateProductVariationTexts + updateProductVariationTexts, ), removeProductVariationOption: acl(actions.manageProducts)( - removeProductVariationOption + removeProductVariationOption, ), createProductVariation: acl(actions.manageProducts)(createProductVariation), createProductBundleItem: acl(actions.manageProducts)(createProductBundleItem), removeBundleItem: acl(actions.manageProducts)(removeBundleItem), createProductVariationOption: acl(actions.manageProducts)( - createProductVariationOption + createProductVariationOption, ), addProductAssignment: acl(actions.manageProducts)(addProductAssignment), removeProductAssignment: acl(actions.manageProducts)(removeProductAssignment), @@ -203,17 +203,17 @@ export default { setOrderPaymentProvider: acl(actions.updateOrder)(setOrderPaymentProvider), setOrderDeliveryProvider: acl(actions.updateOrder)(setOrderDeliveryProvider), updateOrderDeliveryShipping: acl(actions.updateOrderDelivery)( - updateOrderDelivery + updateOrderDelivery, ), updateOrderDeliveryPickUp: acl(actions.updateOrderDelivery)( - updateOrderDelivery + updateOrderDelivery, ), updateOrderPaymentGeneric: acl(actions.updateOrderPayment)( - updateOrderPayment + updateOrderPayment, ), updateOrderPaymentCard: acl(actions.updateOrderPayment)(updateOrderPayment), updateOrderPaymentInvoice: acl(actions.updateOrderPayment)( - updateOrderPayment + updateOrderPayment, ), removeOrder: acl(actions.updateOrder)(removeOrder), confirmOrder: acl(actions.markOrderConfirmed)(confirmOrder), @@ -226,33 +226,33 @@ export default { updateSubscription: acl(actions.updateSubscription)(updateSubscription), createPaymentProvider: acl(actions.managePaymentProviders)( - createPaymentProvider + createPaymentProvider, ), updatePaymentProvider: acl(actions.managePaymentProviders)( - updatePaymentProvider + updatePaymentProvider, ), removePaymentProvider: acl(actions.managePaymentProviders)( - removePaymentProvider + removePaymentProvider, ), createDeliveryProvider: acl(actions.manageDeliveryProviders)( - createDeliveryProvider + createDeliveryProvider, ), updateDeliveryProvider: acl(actions.manageDeliveryProviders)( - updateDeliveryProvider + updateDeliveryProvider, ), removeDeliveryProvider: acl(actions.manageDeliveryProviders)( - removeDeliveryProvider + removeDeliveryProvider, ), createWarehousingProvider: acl(actions.manageWarehousingProviders)( - createWarehousingProvider + createWarehousingProvider, ), updateWarehousingProvider: acl(actions.manageWarehousingProviders)( - updateWarehousingProvider + updateWarehousingProvider, ), removeWarehousingProvider: acl(actions.manageWarehousingProviders)( - removeWarehousingProvider + removeWarehousingProvider, ), createFilter: acl(actions.manageFilters)(createFilter), @@ -269,22 +269,22 @@ export default { updateAssortmentTexts: acl(actions.manageAssortments)(updateAssortmentTexts), addAssortmentProduct: acl(actions.manageAssortments)(addAssortmentProduct), removeAssortmentProduct: acl(actions.manageAssortments)( - removeAssortmentProduct + removeAssortmentProduct, ), reorderAssortmentProducts: acl(actions.manageAssortments)( - reorderAssortmentProducts + reorderAssortmentProducts, ), addAssortmentLink: acl(actions.manageAssortments)(addAssortmentLink), removeAssortmentLink: acl(actions.manageAssortments)(removeAssortmentLink), reorderAssortmentLinks: acl(actions.manageAssortments)( - reorderAssortmentLinks + reorderAssortmentLinks, ), addAssortmentFilter: acl(actions.manageAssortments)(addAssortmentFilter), removeAssortmentFilter: acl(actions.manageAssortments)( - removeAssortmentFilter + removeAssortmentFilter, ), reorderAssortmentFilters: acl(actions.manageAssortments)( - reorderAssortmentFilters + reorderAssortmentFilters, ), createProductReview: acl(actions.reviewProduct)(createProductReview), @@ -292,7 +292,7 @@ export default { removeProductReview: acl(actions.updateProductReview)(removeProductReview), addProductReviewVote: acl(actions.voteProductReview)(addProductReviewVote), removeProductReviewVote: acl(actions.voteProductReview)( - removeProductReviewVote + removeProductReviewVote, ), requestQuotation: acl(actions.requestQuotation)(requestQuotation), diff --git a/packages/api/resolvers/mutations/makeQuotationProposal.js b/packages/api/resolvers/mutations/makeQuotationProposal.js index cbbe60aa45..7e2d36b2a6 100644 --- a/packages/api/resolvers/mutations/makeQuotationProposal.js +++ b/packages/api/resolvers/mutations/makeQuotationProposal.js @@ -8,7 +8,7 @@ import { export default function ( root, { quotationId, ...transactionContext }, - { userId } + { userId }, ) { log('mutation makeQuotationProposal', { quotationId, userId }); const quotation = Quotations.findOne({ _id: quotationId }); diff --git a/packages/api/resolvers/mutations/rejectQuotation.js b/packages/api/resolvers/mutations/rejectQuotation.js index 3863aa904d..9634d85d72 100644 --- a/packages/api/resolvers/mutations/rejectQuotation.js +++ b/packages/api/resolvers/mutations/rejectQuotation.js @@ -8,7 +8,7 @@ import { export default function ( root, { quotationId, ...transactionContext }, - { userId } + { userId }, ) { log('mutation rejectQuotation', { quotationId, userId }); const quotation = Quotations.findOne({ _id: quotationId }); diff --git a/packages/api/resolvers/mutations/removeEmail.js b/packages/api/resolvers/mutations/removeEmail.js index 4e10708c82..573d9eee2b 100644 --- a/packages/api/resolvers/mutations/removeEmail.js +++ b/packages/api/resolvers/mutations/removeEmail.js @@ -5,7 +5,7 @@ import { UserNotFoundError } from '../../errors'; export default function ( root, { email, userId: foreignUserId }, - { userId: ownUserId } + { userId: ownUserId }, ) { log(`mutation removeEmail ${email} ${foreignUserId}`, { userId: ownUserId }); const userId = foreignUserId || ownUserId; diff --git a/packages/api/resolvers/mutations/removeFilterOption.js b/packages/api/resolvers/mutations/removeFilterOption.js index 750a172c75..4dfd0a48cd 100644 --- a/packages/api/resolvers/mutations/removeFilterOption.js +++ b/packages/api/resolvers/mutations/removeFilterOption.js @@ -12,7 +12,7 @@ export default function (root, { filterId, filterOptionValue }, { userId }) { $pull: { options: filterOptionValue, }, - } + }, ); const filter = Filters.findOne({ _id: filterId }); return filter; diff --git a/packages/api/resolvers/mutations/removeProduct.js b/packages/api/resolvers/mutations/removeProduct.js index d254386b9c..32c54ff7dd 100644 --- a/packages/api/resolvers/mutations/removeProduct.js +++ b/packages/api/resolvers/mutations/removeProduct.js @@ -15,7 +15,7 @@ export default function (root, { productId }, { userId }) { status: ProductStatus.DELETED, updated: new Date(), }, - } + }, ); break; default: diff --git a/packages/api/resolvers/mutations/removeProductVariationOption.js b/packages/api/resolvers/mutations/removeProductVariationOption.js index cb0ec27236..39e726976b 100644 --- a/packages/api/resolvers/mutations/removeProductVariationOption.js +++ b/packages/api/resolvers/mutations/removeProductVariationOption.js @@ -4,7 +4,7 @@ import { ProductVariations } from 'meteor/unchained:core-products'; export default function ( root, { productVariationId, productVariationOptionValue }, - { userId } + { userId }, ) { log(`mutation removeProductVariation ${productVariationId}`, { userId }); ProductVariations.update( @@ -16,7 +16,7 @@ export default function ( $pull: { options: productVariationOptionValue, }, - } + }, ); const productVariation = ProductVariations.findOne({ _id: productVariationId, diff --git a/packages/api/resolvers/mutations/requestQuotation.js b/packages/api/resolvers/mutations/requestQuotation.js index d640edb1b4..a9cfb6c9c7 100644 --- a/packages/api/resolvers/mutations/requestQuotation.js +++ b/packages/api/resolvers/mutations/requestQuotation.js @@ -6,13 +6,13 @@ import { ProductNotFoundError } from '../../errors'; export default function ( root, { productId, configuration }, - { userId, countryContext, localeContext } + { userId, countryContext, localeContext }, ) { log( `mutation requestQuotation ${productId} ${ configuration ? JSON.stringify(configuration) : '' }`, - { userId } + { userId }, ); const product = Products.findOne({ _id: productId }); if (!product) throw new ProductNotFoundError({ productId }); @@ -23,7 +23,7 @@ export default function ( countryCode: countryContext, configuration, }, - { localeContext } + { localeContext }, ); return quotation; } diff --git a/packages/api/resolvers/mutations/setBaseAssortment.js b/packages/api/resolvers/mutations/setBaseAssortment.js index 8477889a0e..f6431544eb 100644 --- a/packages/api/resolvers/mutations/setBaseAssortment.js +++ b/packages/api/resolvers/mutations/setBaseAssortment.js @@ -11,7 +11,7 @@ export default function setBaseAssortment(root, { assortmentId }, { userId }) { updated: new Date(), }, }, - { multi: true } + { multi: true }, ); Assortments.update( { _id: assortmentId }, @@ -20,7 +20,7 @@ export default function setBaseAssortment(root, { assortmentId }, { userId }) { isBase: true, updated: new Date(), }, - } + }, ); return Assortments.findOne({ _id: assortmentId }); } diff --git a/packages/api/resolvers/mutations/setBaseCountry.js b/packages/api/resolvers/mutations/setBaseCountry.js index 9e03c1eaa1..5462ce4aa5 100644 --- a/packages/api/resolvers/mutations/setBaseCountry.js +++ b/packages/api/resolvers/mutations/setBaseCountry.js @@ -11,7 +11,7 @@ export default function setBaseCountry(root, { countryId }, { userId }) { updated: new Date(), }, }, - { multi: true } + { multi: true }, ); Countries.update( { _id: countryId }, @@ -20,7 +20,7 @@ export default function setBaseCountry(root, { countryId }, { userId }) { isBase: true, updated: new Date(), }, - } + }, ); return Countries.findOne({ _id: countryId }); } diff --git a/packages/api/resolvers/mutations/setBaseLanguage.js b/packages/api/resolvers/mutations/setBaseLanguage.js index 37174f1aaa..b8d9f26577 100644 --- a/packages/api/resolvers/mutations/setBaseLanguage.js +++ b/packages/api/resolvers/mutations/setBaseLanguage.js @@ -11,7 +11,7 @@ export default function setBaseLanguage(root, { languageId }, { userId }) { updated: new Date(), }, }, - { multi: true } + { multi: true }, ); Languages.update( { _id: languageId }, @@ -20,7 +20,7 @@ export default function setBaseLanguage(root, { languageId }, { userId }) { isBase: true, updated: new Date(), }, - } + }, ); return Languages.findOne({ _id: languageId }); } diff --git a/packages/api/resolvers/mutations/setPassword.js b/packages/api/resolvers/mutations/setPassword.js index 7928c38511..9852c3fe5b 100644 --- a/packages/api/resolvers/mutations/setPassword.js +++ b/packages/api/resolvers/mutations/setPassword.js @@ -5,7 +5,7 @@ import { UserNotFoundError } from '../../errors'; export default function ( root, { newPassword, userId: foreignUserId }, - { userId: ownUserId } + { userId: ownUserId }, ) { log(`mutation setPassword ${foreignUserId}`, { userId: ownUserId }); const userId = foreignUserId || ownUserId; diff --git a/packages/api/resolvers/mutations/setUserTags.js b/packages/api/resolvers/mutations/setUserTags.js index 0ca94e7229..32d1902b8c 100644 --- a/packages/api/resolvers/mutations/setUserTags.js +++ b/packages/api/resolvers/mutations/setUserTags.js @@ -11,7 +11,7 @@ export default function (root, { tags, userId: normalizedUserId }, { userId }) { updated: new Date(), tags, }, - } + }, ); return Users.findOne({ _id: normalizedUserId }); } diff --git a/packages/api/resolvers/mutations/setUsername.js b/packages/api/resolvers/mutations/setUsername.js index 1c91efa3d7..0d4e54d66e 100644 --- a/packages/api/resolvers/mutations/setUsername.js +++ b/packages/api/resolvers/mutations/setUsername.js @@ -5,7 +5,7 @@ import { UserNotFoundError } from '../../errors'; export default function ( root, { username, userId: foreignUserId }, - { userId } + { userId }, ) { log(`mutation setUsername ${foreignUserId}`, { userId }); const user = Users.findOne({ _id: foreignUserId }); diff --git a/packages/api/resolvers/mutations/updateAssortment.js b/packages/api/resolvers/mutations/updateAssortment.js index 9d3f5f5b7b..d45b542cdf 100644 --- a/packages/api/resolvers/mutations/updateAssortment.js +++ b/packages/api/resolvers/mutations/updateAssortment.js @@ -10,7 +10,7 @@ export default function (root, { assortment, assortmentId }, { userId }) { ...assortment, updated: new Date(), }, - } + }, ); return Assortments.findOne({ _id: assortmentId }); } diff --git a/packages/api/resolvers/mutations/updateAssortmentTexts.js b/packages/api/resolvers/mutations/updateAssortmentTexts.js index 6acac0928e..6fcbc2c3af 100644 --- a/packages/api/resolvers/mutations/updateAssortmentTexts.js +++ b/packages/api/resolvers/mutations/updateAssortmentTexts.js @@ -5,7 +5,7 @@ export default function (root, { texts, assortmentId }, { userId }) { log(`mutation updateAssortmentTexts ${assortmentId}`, { userId }); const assortmentObject = Assortments.findOne({ _id: assortmentId }); const changedLocalizations = texts.map(({ locale, ...localizations }) => - assortmentObject.upsertLocalizedText(locale, localizations) + assortmentObject.upsertLocalizedText(locale, localizations), ); return changedLocalizations; } diff --git a/packages/api/resolvers/mutations/updateCart.js b/packages/api/resolvers/mutations/updateCart.js index 729ade8504..8ec037a1ab 100644 --- a/packages/api/resolvers/mutations/updateCart.js +++ b/packages/api/resolvers/mutations/updateCart.js @@ -11,7 +11,7 @@ export default async function ( deliveryProviderId, meta, }, - { user, countryContext, userId } + { user, countryContext, userId }, ) { log('mutation updateCart', { userId }); let order = await getCart({ orderId, user, countryContext }); diff --git a/packages/api/resolvers/mutations/updateCartItem.js b/packages/api/resolvers/mutations/updateCartItem.js index dfec8508c1..547cfa9510 100644 --- a/packages/api/resolvers/mutations/updateCartItem.js +++ b/packages/api/resolvers/mutations/updateCartItem.js @@ -9,13 +9,13 @@ import { export default function ( root, { itemId, quantity = null, configuration = null }, - { userId } + { userId }, ) { log( `mutation updateCartItem ${itemId} ${quantity} ${JSON.stringify( - configuration + configuration, )}`, - { userId } + { userId }, ); const item = OrderPositions.findOne({ _id: itemId }); if (!item) throw new OrderItemNotFoundError({ itemId }); @@ -32,7 +32,7 @@ export default function ( orderId: item.orderId, positionId: itemId, }, - { quantity } + { quantity }, ); } @@ -42,7 +42,7 @@ export default function ( orderId: item.orderId, positionId: itemId, }, - { configuration } + { configuration }, ); } diff --git a/packages/api/resolvers/mutations/updateCountry.js b/packages/api/resolvers/mutations/updateCountry.js index 5b89595612..e7cff0c8d3 100644 --- a/packages/api/resolvers/mutations/updateCountry.js +++ b/packages/api/resolvers/mutations/updateCountry.js @@ -10,7 +10,7 @@ export default function (root, { country, countryId }, { userId }) { ...country, updated: new Date(), }, - } + }, ); return Countries.findOne({ _id: countryId }); } diff --git a/packages/api/resolvers/mutations/updateCurrency.js b/packages/api/resolvers/mutations/updateCurrency.js index 1f9d0c4362..cda1da5406 100644 --- a/packages/api/resolvers/mutations/updateCurrency.js +++ b/packages/api/resolvers/mutations/updateCurrency.js @@ -4,7 +4,7 @@ import { Currencies } from 'meteor/unchained:core-currencies'; export default function ( root, { currency: { isoCode, ...currency }, currencyId }, - { userId } + { userId }, ) { log(`mutation updateCurrency ${currencyId}`, { userId }); Currencies.update( @@ -15,7 +15,7 @@ export default function ( ...currency, updated: new Date(), }, - } + }, ); return Currencies.findOne({ _id: currencyId }); } diff --git a/packages/api/resolvers/mutations/updateDeliveryProvider.js b/packages/api/resolvers/mutations/updateDeliveryProvider.js index d43084597e..6066d6c70d 100644 --- a/packages/api/resolvers/mutations/updateDeliveryProvider.js +++ b/packages/api/resolvers/mutations/updateDeliveryProvider.js @@ -4,7 +4,7 @@ import { DeliveryProviders } from 'meteor/unchained:core-delivery'; export default function ( root, { deliveryProvider, deliveryProviderId }, - { userId } + { userId }, ) { log(`mutation updateDeliveryProvider ${deliveryProviderId}`, { userId }); const provider = DeliveryProviders.updateProvider({ diff --git a/packages/api/resolvers/mutations/updateEmail.js b/packages/api/resolvers/mutations/updateEmail.js index f6a8212e32..cff293c2d4 100755 --- a/packages/api/resolvers/mutations/updateEmail.js +++ b/packages/api/resolvers/mutations/updateEmail.js @@ -5,7 +5,7 @@ import { UserNotFoundError } from '../../errors'; export default function ( root, { email, userId: foreignUserId }, - { userId: ownUserId } + { userId: ownUserId }, ) { log(`mutation updateEmail ${email} ${foreignUserId}`, { userId: ownUserId }); const userId = foreignUserId || ownUserId; diff --git a/packages/api/resolvers/mutations/updateFilterTexts.js b/packages/api/resolvers/mutations/updateFilterTexts.js index 7362f5d8df..084a4380c1 100644 --- a/packages/api/resolvers/mutations/updateFilterTexts.js +++ b/packages/api/resolvers/mutations/updateFilterTexts.js @@ -4,14 +4,14 @@ import { Filters } from 'meteor/unchained:core-filters'; export default function ( root, { texts, filterId, filterOptionValue }, - { userId } + { userId }, ) { log(`mutation updateFilterTexts ${filterId} ${filterOptionValue}`, { userId, }); const filter = Filters.findOne({ _id: filterId }); const changedLocalizations = texts.map(({ locale, ...fields }) => - filter.upsertLocalizedText(locale, { filterOptionValue, ...fields }) + filter.upsertLocalizedText(locale, { filterOptionValue, ...fields }), ); return changedLocalizations; } diff --git a/packages/api/resolvers/mutations/updateLanguage.js b/packages/api/resolvers/mutations/updateLanguage.js index c1bc8f6701..d779ce7e62 100644 --- a/packages/api/resolvers/mutations/updateLanguage.js +++ b/packages/api/resolvers/mutations/updateLanguage.js @@ -8,7 +8,7 @@ export default function (root, { language, languageId }, { userId }) { { updated: new Date(), $set: language, - } + }, ); return Languages.findOne({ _id: languageId }); } diff --git a/packages/api/resolvers/mutations/updateProductMediaTexts.js b/packages/api/resolvers/mutations/updateProductMediaTexts.js index bd808adc5c..5c7a2707f1 100644 --- a/packages/api/resolvers/mutations/updateProductMediaTexts.js +++ b/packages/api/resolvers/mutations/updateProductMediaTexts.js @@ -8,7 +8,7 @@ export default function (root, { texts, productMediaId }, { userId }) { if (!productMediaObject) throw new ProductMediaNotFoundError({ productMediaId }); const changedLocalizations = texts.map(({ locale, ...localizations }) => - productMediaObject.upsertLocalizedText(locale, localizations) + productMediaObject.upsertLocalizedText(locale, localizations), ); return changedLocalizations; } diff --git a/packages/api/resolvers/mutations/updateProductTexts.js b/packages/api/resolvers/mutations/updateProductTexts.js index 97e74f3484..9ed8662b38 100644 --- a/packages/api/resolvers/mutations/updateProductTexts.js +++ b/packages/api/resolvers/mutations/updateProductTexts.js @@ -5,7 +5,7 @@ export default function (root, { texts, productId }, { userId }) { log(`mutation updateProductTexts ${productId}`, { userId }); const productObject = Products.findOne({ _id: productId }); const changedLocalizations = texts.map(({ locale, ...localizations }) => - productObject.upsertLocalizedText(locale, localizations) + productObject.upsertLocalizedText(locale, localizations), ); return changedLocalizations; } diff --git a/packages/api/resolvers/mutations/updateProductVariationTexts.js b/packages/api/resolvers/mutations/updateProductVariationTexts.js index c1823e116f..78ab09fad6 100644 --- a/packages/api/resolvers/mutations/updateProductVariationTexts.js +++ b/packages/api/resolvers/mutations/updateProductVariationTexts.js @@ -4,7 +4,7 @@ import { ProductVariations } from 'meteor/unchained:core-products'; export default function ( root, { texts, productVariationId, productVariationOptionValue }, - { userId } + { userId }, ) { log(`mutation updateProductVariationTexts ${productVariationId}`, { userId }); const productVariation = ProductVariations.findOne({ @@ -14,7 +14,7 @@ export default function ( productVariation.upsertLocalizedText(locale, { productVariationOptionValue, ...rest, - }) + }), ); return changedLocalizations; } diff --git a/packages/api/resolvers/mutations/updateSubscription.js b/packages/api/resolvers/mutations/updateSubscription.js index 65d8d276f6..6624e60b16 100644 --- a/packages/api/resolvers/mutations/updateSubscription.js +++ b/packages/api/resolvers/mutations/updateSubscription.js @@ -11,7 +11,7 @@ import { export default async function ( root, { subscriptionId, contact, plan, billingAddress, payment, delivery, meta }, - { userId } + { userId }, ) { log('mutation updateSubscription', { userId }); let subscription = Subscriptions.findOne({ diff --git a/packages/api/resolvers/mutations/updateUserAvatar.js b/packages/api/resolvers/mutations/updateUserAvatar.js index 2faca12f88..13551812be 100755 --- a/packages/api/resolvers/mutations/updateUserAvatar.js +++ b/packages/api/resolvers/mutations/updateUserAvatar.js @@ -11,7 +11,7 @@ export default function (root, { avatar, userId: foreignUserId }, { userId }) { Avatars.insertWithRemoteFile({ file: avatar, userId: normalizedUserId, - }) + }), ) : Promise.await( Avatars.insertWithRemoteBuffer({ @@ -20,7 +20,7 @@ export default function (root, { avatar, userId: foreignUserId }, { userId }) { buffer: Buffer.from(avatar.buffer, 'base64'), }, userId: normalizedUserId, - }) + }), ); Users.update( { _id: normalizedUserId }, @@ -29,7 +29,7 @@ export default function (root, { avatar, userId: foreignUserId }, { userId }) { updated: new Date(), avatarId: avatarRef._id, }, - } + }, ); return Users.findOne({ _id: normalizedUserId }); } diff --git a/packages/api/resolvers/mutations/updateUserProfile.js b/packages/api/resolvers/mutations/updateUserProfile.js index 4a38219b77..045aec7904 100755 --- a/packages/api/resolvers/mutations/updateUserProfile.js +++ b/packages/api/resolvers/mutations/updateUserProfile.js @@ -19,7 +19,7 @@ export default function (root, { profile, userId: foreignUserId }, { userId }) { updated: new Date(), ...transformedProfile, }, - } + }, ); return Users.findOne({ _id: normalizedUserId }); } diff --git a/packages/api/resolvers/mutations/updateWarehousingProvider.js b/packages/api/resolvers/mutations/updateWarehousingProvider.js index d8a4a6e177..ac0c263619 100644 --- a/packages/api/resolvers/mutations/updateWarehousingProvider.js +++ b/packages/api/resolvers/mutations/updateWarehousingProvider.js @@ -4,7 +4,7 @@ import { WarehousingProviders } from 'meteor/unchained:core-warehousing'; export default ( root, { warehousingProvider, warehousingProviderId }, - { userId } + { userId }, ) => { log(`mutation updateWarehousingProvider ${warehousingProviderId}`, { userId, diff --git a/packages/api/resolvers/mutations/verifyQuotation.js b/packages/api/resolvers/mutations/verifyQuotation.js index 24705a46bf..1905353beb 100644 --- a/packages/api/resolvers/mutations/verifyQuotation.js +++ b/packages/api/resolvers/mutations/verifyQuotation.js @@ -8,7 +8,7 @@ import { export default function ( root, { quotationId, ...transactionContext }, - { userId } + { userId }, ) { log('mutation verifyQuotation', { quotationId, userId }); const quotation = Quotations.findOne({ _id: quotationId }); diff --git a/packages/api/resolvers/queries/assortments.js b/packages/api/resolvers/queries/assortments.js index 571ddd03ba..12debfc8d3 100644 --- a/packages/api/resolvers/queries/assortments.js +++ b/packages/api/resolvers/queries/assortments.js @@ -4,13 +4,13 @@ import { Assortments } from 'meteor/unchained:core-assortments'; export default function ( root, { limit, offset, includeInactive, includeLeaves }, - { userId } + { userId }, ) { log( `query assortments: ${limit} ${offset} ${ includeInactive ? 'includeInactive' : '' }`, - { userId } + { userId }, ); const selector = {}; if (!includeLeaves) { diff --git a/packages/api/resolvers/queries/countries.js b/packages/api/resolvers/queries/countries.js index 75b6c7c78c..4c83d6a9c9 100644 --- a/packages/api/resolvers/queries/countries.js +++ b/packages/api/resolvers/queries/countries.js @@ -6,7 +6,7 @@ export default function (root, { limit, offset, includeInactive }, { userId }) { `query countries: ${limit} ${offset} ${ includeInactive ? 'includeInactive' : '' }`, - { userId } + { userId }, ); const selector = {}; if (!includeInactive) { diff --git a/packages/api/resolvers/queries/currencies.js b/packages/api/resolvers/queries/currencies.js index 97a2b4878a..0d38f8db00 100644 --- a/packages/api/resolvers/queries/currencies.js +++ b/packages/api/resolvers/queries/currencies.js @@ -6,7 +6,7 @@ export default function (root, { limit, offset, includeInactive }, { userId }) { `query currencies: ${limit} ${offset} ${ includeInactive ? 'includeInactive' : '' }`, - { userId } + { userId }, ); const selector = {}; if (!includeInactive) { diff --git a/packages/api/resolvers/queries/deliveryInterfaces.js b/packages/api/resolvers/queries/deliveryInterfaces.js index 8b0ab4312d..8abbc9a96e 100644 --- a/packages/api/resolvers/queries/deliveryInterfaces.js +++ b/packages/api/resolvers/queries/deliveryInterfaces.js @@ -4,7 +4,7 @@ import { DeliveryDirector } from 'meteor/unchained:core-delivery'; export default function (root, { type }, { userId }) { log(`query delivery-interfaces ${type}`, { userId }); return DeliveryDirector.filteredAdapters((Interface) => - Interface.typeSupported(type) + Interface.typeSupported(type), ).map((Interface) => ({ _id: Interface.key, label: Interface.label, diff --git a/packages/api/resolvers/queries/index.js b/packages/api/resolvers/queries/index.js index 4aa340b5d3..0f79496e67 100755 --- a/packages/api/resolvers/queries/index.js +++ b/packages/api/resolvers/queries/index.js @@ -66,20 +66,20 @@ export default { deliveryProvider: acl(actions.viewDeliveryProvider)(deliveryProvider), deliveryInterfaces: acl(actions.viewDeliveryInterfaces)(deliveryInterfaces), warehousingProviders: acl(actions.viewWarehousingProviders)( - warehousingProviders + warehousingProviders, ), warehousingProvider: acl(actions.viewWarehousingProvider)( - warehousingProvider + warehousingProvider, ), warehousingInterfaces: acl(actions.viewWarehousingInterfaces)( - warehousingInterfaces + warehousingInterfaces, ), translatedProductTexts: acl(actions.viewTranslations)(translatedProductTexts), translatedProductMediaTexts: acl(actions.viewTranslations)( - translatedProductMediaTexts + translatedProductMediaTexts, ), translatedProductVariationTexts: acl(actions.viewTranslations)( - translatedProductVariationTexts + translatedProductVariationTexts, ), orders: acl(actions.viewOrders)(orders), order: acl(actions.viewOrder)(order), @@ -90,7 +90,7 @@ export default { shopInfo: acl(actions.viewShopInfo)(shopInfo), logs: acl(actions.viewLogs)(logs), translatedAssortmentTexts: acl(actions.manageAssortments)( - translatedAssortmentTexts + translatedAssortmentTexts, ), translatedFilterTexts: acl(actions.manageFilters)(translatedFilterTexts), productReview: acl(actions.manageProductReviews)(productReview), @@ -104,6 +104,6 @@ export default { work: acl(actions.manageWorker)(work), signPaymentProviderForCredentialRegistration: acl( - actions.registerPaymentCredentials + actions.registerPaymentCredentials, )(signPaymentProviderForCredentialRegistration), }; diff --git a/packages/api/resolvers/queries/languages.js b/packages/api/resolvers/queries/languages.js index f791ce6c9c..70a9f843f7 100644 --- a/packages/api/resolvers/queries/languages.js +++ b/packages/api/resolvers/queries/languages.js @@ -6,7 +6,7 @@ export default function (root, { limit, offset, includeInactive }, { userId }) { `query languages: ${limit} ${offset} ${ includeInactive ? 'includeInactive' : '' }`, - { userId } + { userId }, ); const selector = {}; if (!includeInactive) { diff --git a/packages/api/resolvers/queries/paymentInterfaces.js b/packages/api/resolvers/queries/paymentInterfaces.js index db7ebd69a4..6f0fe95b7f 100644 --- a/packages/api/resolvers/queries/paymentInterfaces.js +++ b/packages/api/resolvers/queries/paymentInterfaces.js @@ -4,7 +4,7 @@ import { PaymentDirector } from 'meteor/unchained:core-payment'; export default function (root, { type }, { userId }) { log(`query payment-interfaces ${type}`, { userId }); return PaymentDirector.filteredAdapters((Interface) => - Interface.typeSupported(type) + Interface.typeSupported(type), ).map((Interface) => ({ _id: Interface.key, label: Interface.label, diff --git a/packages/api/resolvers/queries/productCatalogPrices.js b/packages/api/resolvers/queries/productCatalogPrices.js index df8d8dc113..1d5b92e76b 100644 --- a/packages/api/resolvers/queries/productCatalogPrices.js +++ b/packages/api/resolvers/queries/productCatalogPrices.js @@ -16,7 +16,7 @@ export default function (root, { productId }, { userId }) { price.currencyCode, price.maxQuantity, price.amount, - ].join('') + ].join(''), ) .digest('hex'), ...price, diff --git a/packages/api/resolvers/queries/products.js b/packages/api/resolvers/queries/products.js index 8cfcd1d9e7..91bc379679 100644 --- a/packages/api/resolvers/queries/products.js +++ b/packages/api/resolvers/queries/products.js @@ -4,13 +4,13 @@ import { Products, ProductStatus } from 'meteor/unchained:core-products'; export default function ( root, { limit, offset, tags, includeDrafts, slugs = [] }, - { userId } + { userId }, ) { log( `query products: ${limit} ${offset} ${ includeDrafts ? 'includeDrafts' : '' } ${slugs.join(',')}`, - { userId } + { userId }, ); const selector = {}; const sort = { sequence: 1, published: -1 }; diff --git a/packages/api/resolvers/queries/signPaymentProviderForCredentialRegistration.js b/packages/api/resolvers/queries/signPaymentProviderForCredentialRegistration.js index fe07dc98e9..38f0a794cb 100644 --- a/packages/api/resolvers/queries/signPaymentProviderForCredentialRegistration.js +++ b/packages/api/resolvers/queries/signPaymentProviderForCredentialRegistration.js @@ -5,7 +5,7 @@ import { PaymentProviderNotFoundError } from '../../errors'; export default (root, { paymentProviderId, ...rest }, { userId }) => { log( `query signPaymentProviderForCredentialRegistration ${paymentProviderId}`, - { userId } + { userId }, ); const paymentProvider = PaymentProviders.findOne({ _id: paymentProviderId }); if (!paymentProvider) diff --git a/packages/api/resolvers/queries/translatedProductVariationTexts.js b/packages/api/resolvers/queries/translatedProductVariationTexts.js index 1fd9a47bab..a75a9164d9 100644 --- a/packages/api/resolvers/queries/translatedProductVariationTexts.js +++ b/packages/api/resolvers/queries/translatedProductVariationTexts.js @@ -4,11 +4,11 @@ import { ProductVariationTexts } from 'meteor/unchained:core-products'; export default function ( root, { productVariationId, productVariationOptionValue }, - { userId } + { userId }, ) { log( `query translatedProductVariationTexts ${productVariationId} ${productVariationOptionValue}`, - { userId } + { userId }, ); const selector = { productVariationId, diff --git a/packages/api/resolvers/queries/users.js b/packages/api/resolvers/queries/users.js index 695f8e7e22..ee9aa417cc 100644 --- a/packages/api/resolvers/queries/users.js +++ b/packages/api/resolvers/queries/users.js @@ -4,7 +4,7 @@ import { Users } from 'meteor/unchained:core-users'; export default function (root, { limit, offset, includeGuests }, { userId }) { log( `query users ${limit} ${offset} ${includeGuests ? 'includeGuests' : ''}`, - { userId } + { userId }, ); const selector = {}; if (!includeGuests) { diff --git a/packages/api/resolvers/queries/warehousingInterfaces.js b/packages/api/resolvers/queries/warehousingInterfaces.js index 1e6343e7f7..36db61e8e1 100644 --- a/packages/api/resolvers/queries/warehousingInterfaces.js +++ b/packages/api/resolvers/queries/warehousingInterfaces.js @@ -4,7 +4,7 @@ import { WarehousingDirector } from 'meteor/unchained:core-warehousing'; export default function (root, { type }, { userId }) { log(`query warehousing-interfaces ${type}`, { userId }); return WarehousingDirector.filteredAdapters((Interface) => - Interface.typeSupported(type) + Interface.typeSupported(type), ).map((Interface) => ({ _id: Interface.key, label: Interface.label, diff --git a/packages/api/resolvers/queries/warehousingProvider.js b/packages/api/resolvers/queries/warehousingProvider.js index 3d247944b8..eda5c8045b 100644 --- a/packages/api/resolvers/queries/warehousingProvider.js +++ b/packages/api/resolvers/queries/warehousingProvider.js @@ -4,7 +4,7 @@ import { WarehousingProviders } from 'meteor/unchained:core-warehousing'; export default function (root, { warehousingProviderId }, { userId }) { log(`query warehousing-provider ${warehousingProviderId}`, { userId }); const warehousingProvider = WarehousingProviders.findProviderById( - warehousingProviderId + warehousingProviderId, ); return warehousingProvider; } diff --git a/packages/api/resolvers/queries/workQueue.js b/packages/api/resolvers/queries/workQueue.js index 19f1e70f94..5356af4cee 100644 --- a/packages/api/resolvers/queries/workQueue.js +++ b/packages/api/resolvers/queries/workQueue.js @@ -4,7 +4,7 @@ import { WorkerDirector } from 'meteor/unchained:core-worker'; export default async function ( root, { limit, offset, status = [] }, - { userId } + { userId }, ) { log(`query workQueue ${limit} ${offset} [${status.join(', ')}]`, { userId }); diff --git a/packages/api/resolvers/types/assortment-path-link.js b/packages/api/resolvers/types/assortment-path-link.js index 73a9bbc8f3..85e4ac4bbb 100644 --- a/packages/api/resolvers/types/assortment-path-link.js +++ b/packages/api/resolvers/types/assortment-path-link.js @@ -15,14 +15,14 @@ export default { return findLocalizedText( AssortmentTexts, { assortmentId: obj.assortmentId }, - localeContext.normalized + localeContext.normalized, ).slug; }, async assortmentTexts(obj, { forceLocale } = {}, { localeContext }) { return findLocalizedText( AssortmentTexts, { assortmentId: obj.assortmentId }, - forceLocale || localeContext.normalized + forceLocale || localeContext.normalized, ); }, }; diff --git a/packages/api/resolvers/types/delivery-provider.js b/packages/api/resolvers/types/delivery-provider.js index 991b748477..0f8e5613f3 100644 --- a/packages/api/resolvers/types/delivery-provider.js +++ b/packages/api/resolvers/types/delivery-provider.js @@ -21,7 +21,7 @@ export default { user, providerContext: context, }, - requestContext + requestContext, ); }, }; diff --git a/packages/api/resolvers/types/dispatch.js b/packages/api/resolvers/types/dispatch.js index e3e61124bd..41faa1b14c 100644 --- a/packages/api/resolvers/types/dispatch.js +++ b/packages/api/resolvers/types/dispatch.js @@ -21,7 +21,7 @@ export default { quantity, country, userId || 'ANONYMOUS', - ].join('') + ].join(''), ) .digest('hex'), }; diff --git a/packages/api/resolvers/types/filter-option.js b/packages/api/resolvers/types/filter-option.js index 19b0b6d661..7e81ee6aa5 100644 --- a/packages/api/resolvers/types/filter-option.js +++ b/packages/api/resolvers/types/filter-option.js @@ -8,7 +8,7 @@ export default { async texts(obj, { forceLocale }, { localeContext }) { return obj.getLocalizedTexts( forceLocale || localeContext.normalized, - obj.filterOption + obj.filterOption, ); }, }; diff --git a/packages/api/resolvers/types/order-delivery-pickup.js b/packages/api/resolvers/types/order-delivery-pickup.js index 5ae56c1aff..33b0197ce7 100644 --- a/packages/api/resolvers/types/order-delivery-pickup.js +++ b/packages/api/resolvers/types/order-delivery-pickup.js @@ -6,7 +6,7 @@ export default { { orderDelivery: obj, }, - orderPickUpLocationId + orderPickUpLocationId, ); }, pickUpLocations(obj) { diff --git a/packages/api/resolvers/types/plan-product.js b/packages/api/resolvers/types/plan-product.js index 926fa7046a..c9cc351407 100644 --- a/packages/api/resolvers/types/plan-product.js +++ b/packages/api/resolvers/types/plan-product.js @@ -24,7 +24,7 @@ export default { userId, user, }, - requestContext + requestContext, ); }, async simulatedDiscounts(obj, params, requestContext) { @@ -37,7 +37,7 @@ export default { userId, user, }, - requestContext + requestContext, ); }, salesUnit(obj) { diff --git a/packages/api/resolvers/types/product-variation-option.js b/packages/api/resolvers/types/product-variation-option.js index f5bb5f66c2..9a13cd5a2b 100644 --- a/packages/api/resolvers/types/product-variation-option.js +++ b/packages/api/resolvers/types/product-variation-option.js @@ -8,7 +8,7 @@ export default { async texts(obj, { forceLocale }, { localeContext }) { return obj.getLocalizedTexts( forceLocale || localeContext.normalized, - obj.productVariationOption + obj.productVariationOption, ); }, }; diff --git a/packages/api/resolvers/types/search-result.js b/packages/api/resolvers/types/search-result.js index b6271f00c5..a37a8f514f 100644 --- a/packages/api/resolvers/types/search-result.js +++ b/packages/api/resolvers/types/search-result.js @@ -16,7 +16,7 @@ export default { }).count(), products: async ( { productSelector, filteredProductIds, sortStage }, - { offset, limit } + { offset, limit }, ) => findPreservingIds(Products)( await productSelector, @@ -25,7 +25,7 @@ export default { skip: offset, limit, sort: await sortStage, - } + }, ), filters: async ({ filterSelector, @@ -50,7 +50,7 @@ export default { }, { fields: { _id: 1 }, - } + }, ).map(({ _id }) => _id); return otherFilters.map((filter) => { diff --git a/packages/api/resolvers/types/simple-product.js b/packages/api/resolvers/types/simple-product.js index 3f654f7d4e..2efbb0a5a6 100644 --- a/packages/api/resolvers/types/simple-product.js +++ b/packages/api/resolvers/types/simple-product.js @@ -24,7 +24,7 @@ export default { userId, user, }, - requestContext + requestContext, ); }, async simulatedDiscounts(obj, params, requestContext) { @@ -37,7 +37,7 @@ export default { userId, user, }, - requestContext + requestContext, ); }, async simulatedDispatches(obj, params, requestContext) { @@ -52,7 +52,7 @@ export default { userId, user, }, - requestContext + requestContext, ); }, async simulatedStocks(obj, params, requestContext) { @@ -66,7 +66,7 @@ export default { userId, user, }, - requestContext + requestContext, ); }, salesUnit(obj) { diff --git a/packages/api/resolvers/types/stock.js b/packages/api/resolvers/types/stock.js index ba3f5fd41c..8e66675690 100644 --- a/packages/api/resolvers/types/stock.js +++ b/packages/api/resolvers/types/stock.js @@ -19,7 +19,7 @@ export default { referenceDate, country, userId || 'ANONYMOUS', - ].join('') + ].join(''), ) .digest('hex'), }; diff --git a/packages/api/resolvers/types/user.js b/packages/api/resolvers/types/user.js index f256899c7c..8469298e0e 100755 --- a/packages/api/resolvers/types/user.js +++ b/packages/api/resolvers/types/user.js @@ -11,11 +11,11 @@ export default { username: checkTypeResolver(actions.viewUserPrivateInfos, 'username'), isEmailVerified: checkTypeResolver( actions.viewUserPrivateInfos, - 'isEmailVerified' + 'isEmailVerified', ), isInitialPassword: checkTypeResolver( actions.viewUserPrivateInfos, - 'isInitialPassword' + 'isInitialPassword', ), isGuest: checkTypeResolver(actions.viewUserPrivateInfos, 'isGuest'), profile: checkTypeResolver(actions.viewUserPrivateInfos, 'profile'), @@ -23,7 +23,7 @@ export default { country: checkTypeResolver(actions.viewUserPrivateInfos, 'country'), lastBillingAddress: checkTypeResolver( actions.viewUserPrivateInfos, - 'lastBillingAddress' + 'lastBillingAddress', ), lastContact: checkTypeResolver(actions.viewUserPrivateInfos, 'lastContact'), emails: checkTypeResolver(actions.viewUserPrivateInfos, 'emails'), @@ -31,7 +31,7 @@ export default { bookmarks: checkTypeResolver(actions.viewUserPrivateInfos, 'bookmarks'), paymentCredentials: checkTypeResolver( actions.viewUserPrivateInfos, - 'paymentCredentials' + 'paymentCredentials', ), orders: checkTypeResolver(actions.viewUserOrders, 'orders'), @@ -40,7 +40,7 @@ export default { roles: checkTypeResolver(actions.viewUserRoles, 'roles'), subscriptions: checkTypeResolver( actions.viewUserSubscriptions, - 'subscriptions' + 'subscriptions', ), async cart(user, params, context = {}) { diff --git a/packages/api/roles/all.js b/packages/api/roles/all.js index a4c063a50b..21cd239ca0 100644 --- a/packages/api/roles/all.js +++ b/packages/api/roles/all.js @@ -75,7 +75,7 @@ export default (role, actions) => { Orders.find({ _id: orderId, orderNumber: otp, - }).count() > 0 + }).count() > 0, ); // only allow if otp is provided @@ -85,7 +85,7 @@ export default (role, actions) => { Quotations.find({ _id: quotationId, quotationNumber: otp, - }).count() > 0 + }).count() > 0, ); // only allow if otp is provided @@ -95,7 +95,7 @@ export default (role, actions) => { Subscriptions.find({ _id: quotationId, subscriptionNumber: otp, - }).count() > 0 + }).count() > 0, ); // only allow if query is not demanding for drafts diff --git a/packages/api/roles/loggedIn.js b/packages/api/roles/loggedIn.js index 61f38ec552..0bed2eb322 100644 --- a/packages/api/roles/loggedIn.js +++ b/packages/api/roles/loggedIn.js @@ -15,7 +15,7 @@ export default (role, actions) => { const isMyself = ( root, { userId: foreignUserId } = {}, - { userId: ownUserId } = {} + { userId: ownUserId } = {}, ) => { if ( root && @@ -93,7 +93,7 @@ export default (role, actions) => { const isOwnedPaymentCredential = ( root, { paymentCredentialsId }, - { userId } + { userId }, ) => PaymentCredentials.find({ _id: paymentCredentialsId, diff --git a/packages/core-assortments/breadcrumbs/build-paths.js b/packages/core-assortments/breadcrumbs/build-paths.js index 089aba5ff5..586eb352b3 100644 --- a/packages/core-assortments/breadcrumbs/build-paths.js +++ b/packages/core-assortments/breadcrumbs/build-paths.js @@ -1,17 +1,17 @@ const walkAssortmentLinks = (resolveAssortmentLink) => async ( - rootAssortmentId + rootAssortmentId, ) => { const walk = async (assortmentId, initialPaths = [], childAssortmentId) => { const assortmentLink = await resolveAssortmentLink( assortmentId, - childAssortmentId + childAssortmentId, ); if (!assortmentLink) return initialPaths; const subAsssortmentLinks = await Promise.all( assortmentLink.parentIds.map(async (parentAssortmentId) => { return walk(parentAssortmentId, initialPaths, assortmentId); - }) + }), ); if (subAsssortmentLinks.length > 0) { @@ -41,7 +41,7 @@ export const walkUpFromProduct = async ({ ...assortmentProduct, links, })); - }) + }), ) ).flat(); }; diff --git a/packages/core-assortments/db/helpers.js b/packages/core-assortments/db/helpers.js index a928de96ca..2ac7833a03 100644 --- a/packages/core-assortments/db/helpers.js +++ b/packages/core-assortments/db/helpers.js @@ -16,7 +16,7 @@ const eqSet = (as, bs) => { export const resolveAssortmentLinkFromDatabase = ({ selector = {} } = {}) => ( assortmentId, - childAssortmentId + childAssortmentId, ) => { const assortment = Collections.Assortments.findOne({ _id: assortmentId, @@ -36,7 +36,7 @@ export const resolveAssortmentProductsFromDatabase = ({ } = {}) => (productId) => { return Collections.AssortmentProducts.find( { productId, ...selector }, - { fields: { _id: true, assortmentId: true } } + { fields: { _id: true, assortmentId: true } }, ).fetch(); }; @@ -83,7 +83,7 @@ Collections.Assortments.sync = (syncFn) => { const referenceDate = Collections.Assortments.markAssortmentTreeDirty(); syncFn(referenceDate); Collections.Assortments.cleanDirtyAssortmentTreeByReferenceDate( - referenceDate + referenceDate, ); Collections.Assortments.updateCleanAssortmentActivation(); Collections.Assortments.wipeAssortments(); @@ -95,27 +95,27 @@ Collections.Assortments.markAssortmentTreeDirty = () => { const updatedAssortmentCount = Collections.Assortments.update( {}, dirtyModifier, - collectionUpdateOptions + collectionUpdateOptions, ); const updatedAssortmentTextsCount = Collections.AssortmentTexts.update( {}, dirtyModifier, - collectionUpdateOptions + collectionUpdateOptions, ); const updatedAssortmentProductsCount = Collections.AssortmentProducts.update( {}, dirtyModifier, - collectionUpdateOptions + collectionUpdateOptions, ); const updatedAssortmentLinksCount = Collections.AssortmentLinks.update( {}, dirtyModifier, - collectionUpdateOptions + collectionUpdateOptions, ); const updatedAssortmentFiltersCount = Collections.AssortmentFilters.update( {}, dirtyModifier, - collectionUpdateOptions + collectionUpdateOptions, ); const timestamp = new Date(); log( @@ -127,13 +127,13 @@ Collections.Assortments.markAssortmentTreeDirty = () => { updatedAssortmentLinksCount, updatedAssortmentFiltersCount, level: 'verbose', - } + }, ); return new Date(); }; Collections.Assortments.cleanDirtyAssortmentTreeByReferenceDate = ( - referenceDate + referenceDate, ) => { const selector = { dirty: true, @@ -151,27 +151,27 @@ Collections.Assortments.cleanDirtyAssortmentTreeByReferenceDate = ( const updatedAssortmentCount = Collections.Assortments.update( selector, modifier, - collectionUpdateOptions + collectionUpdateOptions, ); const updatedAssortmentTextsCount = Collections.AssortmentTexts.update( selector, modifier, - collectionUpdateOptions + collectionUpdateOptions, ); const updatedAssortmentProductsCount = Collections.AssortmentProducts.update( selector, modifier, - collectionUpdateOptions + collectionUpdateOptions, ); const updatedAssortmentLinksCount = Collections.AssortmentLinks.update( selector, modifier, - collectionUpdateOptions + collectionUpdateOptions, ); const updatedAssortmentFiltersCount = Collections.AssortmentFilters.update( selector, modifier, - collectionUpdateOptions + collectionUpdateOptions, ); log( `Assortment Sync: Result of assortment cleaning with referenceDate=${referenceDate}`, @@ -182,7 +182,7 @@ Collections.Assortments.cleanDirtyAssortmentTreeByReferenceDate = ( updatedAssortmentLinksCount, updatedAssortmentFiltersCount, level: 'verbose', - } + }, ); }; @@ -195,7 +195,7 @@ Collections.Assortments.updateCleanAssortmentActivation = () => { { $set: { isActive: false }, }, - { bypassCollection2: true, multi: true } + { bypassCollection2: true, multi: true }, ); const enabledCleanAssortmentsCount = Collections.Assortments.update( { @@ -205,7 +205,7 @@ Collections.Assortments.updateCleanAssortmentActivation = () => { { $set: { isActive: true }, }, - { bypassCollection2: true, multi: true } + { bypassCollection2: true, multi: true }, ); log(`Assortment Sync: Result of assortment activation`, { @@ -219,16 +219,16 @@ Collections.Assortments.wipeAssortments = (onlyDirty = true) => { const selector = onlyDirty ? { dirty: true } : {}; const removedAssortmentCount = Collections.Assortments.remove(selector); const removedAssortmentTextCount = Collections.AssortmentTexts.remove( - selector + selector, ); const removedAssortmentProductsCount = Collections.AssortmentProducts.remove( - selector + selector, ); const removedAssortmentLinksCount = Collections.AssortmentLinks.remove( - selector + selector, ); const removedAssortmentFiltersCount = Collections.AssortmentFilters.remove( - selector + selector, ); log(`result of assortment purging with onlyDirty=${onlyDirty}`, { @@ -251,7 +251,7 @@ Collections.AssortmentProducts.getNewSortKey = (assortmentId) => { }, { sort: { sortKey: -1 }, - } + }, ) || { sortKey: 0 }; return lastAssortmentProduct.sortKey + 1; }; @@ -268,10 +268,10 @@ Collections.AssortmentProducts.updateManualOrder = ({ }, { $set: { sortKey: sortKey + 1, updated: new Date() }, - } + }, ); return assortmentProductId; - } + }, ); const assortmentProducts = Collections.AssortmentProducts.find({ _id: { $in: changedAssortmentProductIds }, @@ -279,7 +279,7 @@ Collections.AssortmentProducts.updateManualOrder = ({ if (!skipInvalidation) { const assortmentIds = assortmentProducts.map( - ({ assortmentId }) => assortmentId + ({ assortmentId }) => assortmentId, ); Collections.Assortments.find({ _id: { $in: assortmentIds }, @@ -296,7 +296,7 @@ Collections.AssortmentFilters.getNewSortKey = (assortmentId) => { }, { sort: { sortKey: -1 }, - } + }, ) || { sortKey: 0 }; return lastAssortmentFilter.sortKey + 1; }; @@ -310,10 +310,10 @@ Collections.AssortmentFilters.updateManualOrder = ({ sortKeys }) => { }, { $set: { sortKey: sortKey + 1, updated: new Date() }, - } + }, ); return assortmentFilterId; - } + }, ); return Collections.AssortmentFilters.find({ _id: { $in: changedAssortmentFilterIds }, @@ -327,7 +327,7 @@ Collections.AssortmentLinks.getNewSortKey = (parentAssortmentId) => { }, { sort: { sortKey: -1 }, - } + }, ) || { sortKey: 0 }; return lastAssortmentProduct.sortKey + 1; }; @@ -341,10 +341,10 @@ Collections.AssortmentLinks.updateManualOrder = ({ sortKeys }) => { }, { $set: { sortKey: sortKey + 1, updated: new Date() }, - } + }, ); return assortmentLinkId; - } + }, ); return Collections.AssortmentLinks.find({ _id: { $in: changedAssortmentLinkIds }, @@ -355,7 +355,7 @@ Products.helpers({ assortmentIds() { return Collections.AssortmentProducts.find( { productId: this._id }, - { fields: { assortmentId: true } } + { fields: { assortmentId: true } }, ) .fetch() .map(({ assortmentId: id }) => id); @@ -415,7 +415,7 @@ Collections.Assortments.helpers({ updated: new Date(), }, }, - { bypassCollection2: true } + { bypassCollection2: true }, ); Collections.Assortments.update( @@ -429,7 +429,7 @@ Collections.Assortments.helpers({ $addToSet: { slugs: slug, }, - } + }, ); Collections.Assortments.update( { @@ -444,7 +444,7 @@ Collections.Assortments.helpers({ slugs: slug, }, }, - { multi: true } + { multi: true }, ); return Collections.AssortmentTexts.findOne({ assortmentId: this._id, @@ -511,7 +511,7 @@ Collections.Assortments.helpers({ { assortmentId: this._id }, { sort: { sortKey: 1 }, - } + }, ).fetch(); }, filterAssignments() { @@ -519,7 +519,7 @@ Collections.Assortments.helpers({ { assortmentId: this._id }, { sort: { sortKey: 1 }, - } + }, ).fetch(); }, productIds({ forceLiveCollection = false } = {}) { @@ -553,7 +553,7 @@ Collections.Assortments.helpers({ }, { sort: { sortKey: 1 }, - } + }, ).fetch(); }, async children({ includeInactive = false } = {}) { @@ -562,7 +562,7 @@ Collections.Assortments.helpers({ { fields: { childAssortmentId: 1 }, sort: { sortKey: 1 }, - } + }, ) .fetch() .map(({ childAssortmentId }) => childAssortmentId); @@ -578,7 +578,7 @@ Collections.Assortments.helpers({ { fields: { parentAssortmentId: 1 }, sort: { sortKey: 1 }, - } + }, ) .fetch() .map(({ parentAssortmentId }) => parentAssortmentId) @@ -588,17 +588,17 @@ Collections.Assortments.helpers({ const selector = !includeInactive ? { isActive: true } : {}; return findPreservingIds(Collections.Assortments)( selector, - this.parentIds() + this.parentIds(), ); }, collectProductIdCacheTree() { const ownProductIds = this.productAssignments().map( - ({ productId }) => productId + ({ productId }) => productId, ); const linkedAssortments = this.linkedAssortments(); const childAssortments = linkedAssortments.filter( - ({ parentAssortmentId }) => parentAssortmentId === this._id + ({ parentAssortmentId }) => parentAssortmentId === this._id, ); const productIds = childAssortments.map((childAssortment) => { @@ -626,7 +626,7 @@ Collections.Assortments.helpers({ updated: new Date(), _cachedProductIds: productIds, }, - } + }, ); if (skipUpstreamTraversal) return updateCount; @@ -650,7 +650,7 @@ Collections.Assortments.helpers({ Collections.AssortmentTexts.makeSlug = ( { slug, title, assortmentId }, - options + options, ) => { const checkSlugIsUnique = (newPotentialSlug) => { return ( @@ -662,7 +662,7 @@ Collections.AssortmentTexts.makeSlug = ( }; return findUnusedSlug( checkSlugIsUnique, - options + options, )({ existingSlug: slug, title: title || assortmentId, diff --git a/packages/core-assortments/db/schema.js b/packages/core-assortments/db/schema.js index f53b7472a2..fc26e1c88d 100644 --- a/packages/core-assortments/db/schema.js +++ b/packages/core-assortments/db/schema.js @@ -18,8 +18,8 @@ Collections.Assortments.attachSchema( '_cachedProductIds.$': String, ...Schemas.timestampFields, }, - { requiredByDefault: false } - ) + { requiredByDefault: false }, + ), ); Collections.AssortmentTexts.attachSchema( @@ -33,8 +33,8 @@ Collections.AssortmentTexts.attachSchema( slug: { type: String, index: true }, ...Schemas.timestampFields, }, - { requiredByDefault: false } - ) + { requiredByDefault: false }, + ), ); Collections.AssortmentProducts.attachSchema( @@ -48,8 +48,8 @@ Collections.AssortmentProducts.attachSchema( meta: { type: Object, blackbox: true }, ...Schemas.timestampFields, }, - { requiredByDefault: false } - ) + { requiredByDefault: false }, + ), ); Collections.AssortmentLinks.attachSchema( @@ -63,8 +63,8 @@ Collections.AssortmentLinks.attachSchema( meta: { type: Object, blackbox: true }, ...Schemas.timestampFields, }, - { requiredByDefault: false } - ) + { requiredByDefault: false }, + ), ); Collections.AssortmentFilters.attachSchema( @@ -78,6 +78,6 @@ Collections.AssortmentFilters.attachSchema( meta: { type: Object, blackbox: true }, ...Schemas.timestampFields, }, - { requiredByDefault: false } - ) + { requiredByDefault: false }, + ), ); diff --git a/packages/core-assortments/tree-zipper/zipTreeByDeepness.js b/packages/core-assortments/tree-zipper/zipTreeByDeepness.js index 52a67a6f31..aed350f308 100644 --- a/packages/core-assortments/tree-zipper/zipTreeByDeepness.js +++ b/packages/core-assortments/tree-zipper/zipTreeByDeepness.js @@ -36,7 +36,7 @@ const concatItemsByLevels = (levelArray) => { ...acc, [level]: [...(acc[level] || []), items], }; - }, {}) + }, {}), ); }; diff --git a/packages/core-bookmarks/db/helpers.js b/packages/core-bookmarks/db/helpers.js index 447bf785bb..4b86e849cd 100644 --- a/packages/core-bookmarks/db/helpers.js +++ b/packages/core-bookmarks/db/helpers.js @@ -61,7 +61,7 @@ Bookmarks.migrateBookmarks = async ({ }, { multi: true, - } + }, ); }; diff --git a/packages/core-bookmarks/db/schema.js b/packages/core-bookmarks/db/schema.js index c51ef37711..dbfabdfa5f 100644 --- a/packages/core-bookmarks/db/schema.js +++ b/packages/core-bookmarks/db/schema.js @@ -9,6 +9,6 @@ Bookmarks.attachSchema( productId: { type: String, required: true, index: true }, ...Schemas.timestampFields, }, - { requiredByDefault: false } - ) + { requiredByDefault: false }, + ), ); diff --git a/packages/core-countries/db/schema.js b/packages/core-countries/db/schema.js index e2bc36a22c..956ca0d891 100644 --- a/packages/core-countries/db/schema.js +++ b/packages/core-countries/db/schema.js @@ -17,6 +17,6 @@ Countries.attachSchema( defaultCurrencyId: String, ...Schemas.timestampFields, }, - { requiredByDefault: false } - ) + { requiredByDefault: false }, + ), ); diff --git a/packages/core-currencies/db/schema.js b/packages/core-currencies/db/schema.js index b1b0990409..61038d7616 100644 --- a/packages/core-currencies/db/schema.js +++ b/packages/core-currencies/db/schema.js @@ -15,6 +15,6 @@ Currencies.attachSchema( authorId: { type: String, required: true }, ...Schemas.timestampFields, }, - { requiredByDefault: false } - ) + { requiredByDefault: false }, + ), ); diff --git a/packages/core-delivery/db/helpers.js b/packages/core-delivery/db/helpers.js index b07c4f3f37..02e2bb5434 100644 --- a/packages/core-delivery/db/helpers.js +++ b/packages/core-delivery/db/helpers.js @@ -28,13 +28,13 @@ DeliveryProviders.helpers({ estimatedDeliveryThroughput(context) { return Promise.await( new DeliveryDirector(this).estimatedDeliveryThroughput( - this.defaultContext(context) - ) + this.defaultContext(context), + ), ); }, isAutoReleaseAllowed(context) { return new DeliveryDirector(this).isAutoReleaseAllowed( - this.defaultContext(context) + this.defaultContext(context), ); }, run(command, context, ...args) { @@ -42,18 +42,18 @@ DeliveryProviders.helpers({ new DeliveryDirector(this).run( command, this.defaultContext(context), - ...args - ) + ...args, + ), ); }, send(context) { return Promise.await( - new DeliveryDirector(this).send(this.defaultContext(context)) + new DeliveryDirector(this).send(this.defaultContext(context)), ); }, orderPrice( { country, order, user, useNetPrice, providerContext }, - requestContext + requestContext, ) { const currency = Countries.resolveDefaultCurrencyCode({ isoCode: country, @@ -78,7 +78,7 @@ DeliveryProviders.helpers({ _id: crypto .createHash('sha256') .update( - [this._id, country, useNetPrice, order ? order._id : ''].join('') + [this._id, country, useNetPrice, order ? order._id : ''].join(''), ) .digest('hex'), amount: orderPrice.amount, @@ -109,7 +109,7 @@ DeliveryProviders.updateProvider = ({ _id, ...rest }) => { ...rest, updated: new Date(), }, - } + }, ); return DeliveryProviders.findOne({ _id, deleted: null }); }; @@ -121,7 +121,7 @@ DeliveryProviders.removeProvider = ({ _id }) => { $set: { deleted: new Date(), }, - } + }, ); return DeliveryProviders.findOne({ _id }); }; @@ -132,13 +132,13 @@ DeliveryProviders.findProviderById = (_id, ...options) => DeliveryProviders.findProviders = ({ type } = {}, ...options) => DeliveryProviders.find( { ...(type ? { type } : {}), deleted: null }, - ...options + ...options, ).fetch(); DeliveryProviders.findSupported = ({ order }, ...options) => { const providers = DeliveryProviders.findProviders( {}, - ...options + ...options, ).filter((deliveryProvider) => deliveryProvider.isActive(order)); return settings.filterSupportedProviders({ providers, order }); }; diff --git a/packages/core-delivery/db/schema.js b/packages/core-delivery/db/schema.js index 7dbb549c59..86b1ca1a5d 100644 --- a/packages/core-delivery/db/schema.js +++ b/packages/core-delivery/db/schema.js @@ -19,8 +19,8 @@ DeliveryProviders.attachSchema( 'configuration.$.value': { type: String }, ...Schemas.timestampFields, }, - { requiredByDefault: false } - ) + { requiredByDefault: false }, + ), ); Migrations.add({ @@ -32,7 +32,7 @@ Migrations.add({ { $set: { adapterKey: 'shop.unchained.post' }, }, - { multi: true } + { multi: true }, ); }, down() { @@ -41,7 +41,7 @@ Migrations.add({ { $set: { adapterKey: 'ch.dagobert.post' }, }, - { multi: true } + { multi: true }, ); }, }); diff --git a/packages/core-delivery/director.js b/packages/core-delivery/director.js index 153fc91caf..1a614ddbb1 100644 --- a/packages/core-delivery/director.js +++ b/packages/core-delivery/director.js @@ -78,7 +78,7 @@ export class DeliveryDirector { const Adapter = this.interfaceClass(); if (!Adapter) { throw new Error( - `Delivery Plugin ${this.provider.adapterKey} not available` + `Delivery Plugin ${this.provider.adapterKey} not available`, ); } return new Adapter(this.provider.configuration, context); diff --git a/packages/core-delivery/plugins/pick-mup.js b/packages/core-delivery/plugins/pick-mup.js index e2fd6f0330..a3c2ddb922 100644 --- a/packages/core-delivery/plugins/pick-mup.js +++ b/packages/core-delivery/plugins/pick-mup.js @@ -24,7 +24,7 @@ const fetchPickMupLocations = async (key, idsFilter) => { }, body: null, method: 'GET', - } + }, ); const result = await data.json(); const { stores = [] } = result || {}; diff --git a/packages/core-delivery/settings.js b/packages/core-delivery/settings.js index ccdffc28ba..16e1cc9b05 100644 --- a/packages/core-delivery/settings.js +++ b/packages/core-delivery/settings.js @@ -15,7 +15,7 @@ const settings = { load({ sortProviders, filterSupportedProviders = allProviders } = {}) { if (sortProviders) { logger.warn( - 'sortProviders is deprecated, please specifc filterSupportedProviders instead' + 'sortProviders is deprecated, please specifc filterSupportedProviders instead', ); this.filterSupportedProviders = ({ providers }) => { return providers.sort(sortProviders).map(({ _id }) => _id); diff --git a/packages/core-discounting/director.js b/packages/core-discounting/director.js index c1711cf121..12d498820a 100644 --- a/packages/core-discounting/director.js +++ b/packages/core-discounting/director.js @@ -85,12 +85,12 @@ class DiscountDirector { async resolveDiscountKeyFromStaticCode(options) { if (!this.context.order) return []; log( - `DiscountDirector -> Find user discount for static code ${options?.code}` + `DiscountDirector -> Find user discount for static code ${options?.code}`, ); const discounts = await Promise.all( DiscountDirector.sortedAdapters() .filter((AdapterClass) => - AdapterClass.isManualAdditionAllowed(options?.code) + AdapterClass.isManualAdditionAllowed(options?.code), ) .map(async (AdapterClass) => { const adapter = new AdapterClass({ context: this.context }); @@ -98,7 +98,7 @@ class DiscountDirector { key: AdapterClass.key, isValid: await adapter.isValidForCodeTriggering(options), }; - }) + }), ); return discounts.find(({ isValid }) => isValid === true)?.key; @@ -113,14 +113,14 @@ class DiscountDirector { key: AdapterClass.key, isValid: await adapter.isValidForSystemTriggering(options), }; - }) + }), ); const validDiscounts = discounts .filter(({ isValid }) => isValid === true) .map(({ key }) => key); if (validDiscounts.length > 0) { log( - `DiscountDirector -> Found ${validDiscounts.length} system discounts` + `DiscountDirector -> Found ${validDiscounts.length} system discounts`, ); } return validDiscounts; @@ -136,7 +136,7 @@ class DiscountDirector { static registerAdapter(adapter) { log( - `${this.name} -> Registered ${adapter.key} ${adapter.version} (${adapter.label})` + `${this.name} -> Registered ${adapter.key} ${adapter.version} (${adapter.label})`, ); DiscountDirector.adapters.set(adapter.key, adapter); } diff --git a/packages/core-documents/director.js b/packages/core-documents/director.js index c0b655c338..52b0b662ea 100644 --- a/packages/core-documents/director.js +++ b/packages/core-documents/director.js @@ -54,17 +54,17 @@ class DocumentDirector { return Promise.all( this.adapters.map(async (adapter) => { log( - `DocumentDirector via ${adapter.constructor.key} -> Execute '${name}'` + `DocumentDirector via ${adapter.constructor.key} -> Execute '${name}'`, ); if (!adapter[name]) throw new Error( - `Document Adapter ${adapter.constructor.key} misses ${name}` + `Document Adapter ${adapter.constructor.key} misses ${name}`, ); return adapter[name]({ ancestors, ...options, }); - }) + }), ); } @@ -78,7 +78,7 @@ class DocumentDirector { static registerAdapter(adapter) { log( - `${this.name} -> Registered ${adapter.key} ${adapter.version} (${adapter.label})` + `${this.name} -> Registered ${adapter.key} ${adapter.version} (${adapter.label})`, ); DocumentDirector.adapters.set(adapter.key, adapter); } diff --git a/packages/core-documents/plugins/smallinvoice.js b/packages/core-documents/plugins/smallinvoice.js index d438975af9..2a85a1b1a8 100644 --- a/packages/core-documents/plugins/smallinvoice.js +++ b/packages/core-documents/plugins/smallinvoice.js @@ -82,7 +82,7 @@ class SmallinvoiceAPI { amount: quantity, vat, discount: null, - }) + }), ); } @@ -98,7 +98,7 @@ class SmallinvoiceAPI { amount: quantity, vat, discount: null, - }) + }), ); } @@ -138,7 +138,7 @@ class SmallinvoiceAPI { if (clientId) { const { data: editResult } = this.post( `/client/edit/id/${clientId}`, - mappedBody + mappedBody, ); if (editResult.error) throw new Error(editResult.error); return clientId; diff --git a/packages/core-files/createFilesCollection/FilesCollection.js b/packages/core-files/createFilesCollection/FilesCollection.js index 02142b525f..8c8412eb5d 100644 --- a/packages/core-files/createFilesCollection/FilesCollection.js +++ b/packages/core-files/createFilesCollection/FilesCollection.js @@ -20,7 +20,7 @@ FilesCollection.prototype.insertWithRemoteBuffer = async function insertWithRemo if (err) return reject(err); return resolve(fileObj); }, - true // proceedAfterUpload + true, // proceedAfterUpload ); } catch (e) { reject(e); @@ -56,7 +56,7 @@ FilesCollection.prototype.insertWithRemoteFile = async function insertWithRemote if (err) return reject(err); return resolve(fileObj); }, - true // proceedAfterUpload + true, // proceedAfterUpload ); } catch (e) { reject(e); @@ -81,7 +81,7 @@ FilesCollection.prototype.insertWithRemoteURL = async function insertWithRemoteU (err, fileObj) => { if (err) return reject(err); return resolve(fileObj); - } + }, ); } catch (e) { reject(e); diff --git a/packages/core-files/createFilesCollection/index.js b/packages/core-files/createFilesCollection/index.js index 36ae045954..1f3e72c879 100644 --- a/packages/core-files/createFilesCollection/index.js +++ b/packages/core-files/createFilesCollection/index.js @@ -22,7 +22,7 @@ export default (collectionName, customSettings = null) => { createDefaultSettings(), customSettings, getSetting('files.default'), - getSetting(['files', collectionName]) + getSetting(['files', collectionName]), ); const configByType = Types[mergedSettings.storage.type]; diff --git a/packages/core-files/createFilesCollection/types/gridfs.js b/packages/core-files/createFilesCollection/types/gridfs.js index 8e13a54710..63272955f8 100644 --- a/packages/core-files/createFilesCollection/types/gridfs.js +++ b/packages/core-files/createFilesCollection/types/gridfs.js @@ -6,7 +6,7 @@ import { MongoInternals } from 'meteor/mongo'; export default (collectionName) => { const gridFSBucket = new MongoInternals.NpmModule.GridFSBucket( MongoInternals.defaultRemoteCollectionDriver().mongo.db, - { bucketName: collectionName } + { bucketName: collectionName }, ); const ObjID = MongoInternals.NpmModule.ObjectID; @@ -20,7 +20,7 @@ export default (collectionName) => { gridFSBucket.openUploadStream(file.name, { contentType: file.type || 'binary/octet-stream', metadata, - }) + }), ) .on('error', (err) => { console.error(err); // eslint-disable-line @@ -34,7 +34,7 @@ export default (collectionName) => { $set: { [property]: ver._id.toHexString() }, }); this.unlink(this.collection.findOne(file._id), versionName); // Unlink files from FS - }) + }), ); }); }, @@ -42,7 +42,7 @@ export default (collectionName) => { const { gridFsFileId } = file.versions[versionName].meta || {}; if (gridFsFileId) { const readStream = gridFSBucket.openDownloadStream( - new ObjID(gridFsFileId) + new ObjID(gridFsFileId), ); readStream.on('data', (data) => { http.response.write(data); @@ -60,7 +60,7 @@ export default (collectionName) => { http.response.setHeader( 'Content-Disposition', - `inline; filename="${file.name}"` + `inline; filename="${file.name}"`, ); http.response.setHeader('Cache-Control', this.cacheControl); } diff --git a/packages/core-filters/db/helpers.js b/packages/core-filters/db/helpers.js index e51ae9b849..0416d8c509 100644 --- a/packages/core-filters/db/helpers.js +++ b/packages/core-filters/db/helpers.js @@ -15,7 +15,7 @@ const MAX_UNCOMPRESSED_FILTER_PRODUCTS = 1000; Filters.createFilter = ( { locale, title, type, key, options, isActive = false, ...rest }, - { skipInvalidation = false } = {} + { skipInvalidation = false } = {}, ) => { const filter = { isActive, @@ -36,7 +36,7 @@ Filters.createFilter = ( Filters.updateFilter = ( { filterId, ...filter }, - { skipInvalidation = false } = {} + { skipInvalidation = false } = {}, ) => { const modifier = { $set: { @@ -65,7 +65,7 @@ Filters.getLocalizedTexts = (filterId, filterOptionValue, locale) => filterId, filterOptionValue: filterOptionValue || { $eq: null }, }, - locale + locale, ); Filters.sync = (syncFn) => { @@ -82,12 +82,12 @@ Filters.markFiltersDirty = () => { const updatedFiltersCount = Filters.update( {}, dirtyModifier, - collectionUpdateOptions + collectionUpdateOptions, ); const updatedFilterTextsCount = FilterTexts.update( {}, dirtyModifier, - collectionUpdateOptions + collectionUpdateOptions, ); const timestamp = new Date(); log(`Filter Sync: Marked Filters dirty at timestamp ${timestamp}`, { @@ -116,12 +116,12 @@ Filters.cleanFiltersByReferenceDate = (referenceDate) => { const updatedFiltersCount = Filters.update( selector, modifier, - collectionUpdateOptions + collectionUpdateOptions, ); const updatedFilterTextsCount = FilterTexts.update( selector, modifier, - collectionUpdateOptions + collectionUpdateOptions, ); log( `Filter Sync: Result of filter cleaning with referenceDate=${referenceDate}`, @@ -129,7 +129,7 @@ Filters.cleanFiltersByReferenceDate = (referenceDate) => { updatedFiltersCount, updatedFilterTextsCount, level: 'verbose', - } + }, ); }; @@ -142,7 +142,7 @@ Filters.updateCleanFilterActivation = () => { { $set: { isActive: false }, }, - { bypassCollection2: true, multi: true } + { bypassCollection2: true, multi: true }, ); const enabledCleanFiltersCount = Filters.update( { @@ -152,7 +152,7 @@ Filters.updateCleanFilterActivation = () => { { $set: { isActive: true }, }, - { bypassCollection2: true, multi: true } + { bypassCollection2: true, multi: true }, ); log(`Filter Sync: Result of filter activation`, { @@ -197,7 +197,7 @@ Filters.helpers({ filterOptionValue: filterOptionValue || null, }, }, - { bypassCollection2: true } + { bypassCollection2: true }, ); return FilterTexts.findOne(selector); }, @@ -223,8 +223,8 @@ Filters.helpers({ { key: this.key, value, - } - ) + }, + ), ); if (!selector) return []; const products = Products.find(selector, { fields: { _id: true } }).fetch(); @@ -245,7 +245,7 @@ Filters.helpers({ ...accumulator, [option]: this.collectProductIds({ value: option }), }), - {} + {}, ); } @@ -275,7 +275,7 @@ Filters.helpers({ } : cache, }, - } + }, ); }, cache() { @@ -298,7 +298,7 @@ Filters.helpers({ ...accumulator, [key]: value, }), - {} + {}, ), }; this._isCacheTransformed = true; // eslint-disable-line @@ -384,7 +384,7 @@ Filters.helpers({ const filteredByOtherFiltersSet = intersectProductIds({ productIds: examinedProductIdSet, filters: otherFilters.filter( - (otherFilter) => otherFilter.key !== this.key + (otherFilter) => otherFilter.key !== this.key, ), filterQuery: queryWithoutOwnFilter, forceLiveCollection, diff --git a/packages/core-filters/db/schema.js b/packages/core-filters/db/schema.js index 1a23c5d52f..fb585499b9 100644 --- a/packages/core-filters/db/schema.js +++ b/packages/core-filters/db/schema.js @@ -25,8 +25,8 @@ Filters.attachSchema( meta: { type: Object, blackbox: true }, ...Schemas.timestampFields, }, - { requiredByDefault: false } - ) + { requiredByDefault: false }, + ), ); FilterTexts.attachSchema( @@ -39,6 +39,6 @@ FilterTexts.attachSchema( subtitle: String, ...Schemas.timestampFields, }, - { requiredByDefault: false } - ) + { requiredByDefault: false }, + ), ); diff --git a/packages/core-filters/director.js b/packages/core-filters/director.js index 2dc31a65e2..23ee16d828 100644 --- a/packages/core-filters/director.js +++ b/packages/core-filters/director.js @@ -52,7 +52,7 @@ class FilterDirector { return this.reduceAdapters(async (lastSelector, concreteAdapter) => { return concreteAdapter.transformProductSelector( await lastSelector, - options + options, ); }, defaultSelector || null); } @@ -73,14 +73,14 @@ class FilterDirector { return this.reduceAdapters(async (lastSelector, concreteAdapter) => { return concreteAdapter.transformFilterSelector( await lastSelector, - options + options, ); }, defaultSelector || null); } async reduceAdapters(reducer, initialValue) { const adapters = FilterDirector.sortedAdapters().filter((AdapterClass) => - AdapterClass.isActivatedFor(this.context) + AdapterClass.isActivatedFor(this.context), ); if (adapters.length === 0) { diff --git a/packages/core-filters/search/index.js b/packages/core-filters/search/index.js index 5e316bfd49..94b2eb78ca 100644 --- a/packages/core-filters/search/index.js +++ b/packages/core-filters/search/index.js @@ -37,10 +37,10 @@ const search = async ({ query: rawQuery, forceLiveCollection, context }) => { } const totalProductIds = fulltextSearch(searchConfiguration)( - query?.productIds + query?.productIds, ); const filteredProductIds = totalProductIds.then( - facetedSearch(searchConfiguration) + facetedSearch(searchConfiguration), ); return { diff --git a/packages/core-filters/search/parse-query-array.js b/packages/core-filters/search/parse-query-array.js index 096ecb0beb..6b34aefed0 100644 --- a/packages/core-filters/search/parse-query-array.js +++ b/packages/core-filters/search/parse-query-array.js @@ -4,5 +4,5 @@ export default (query) => ...accumulator, [key]: accumulator[key] ? accumulator[key].concat(value) : [value], }), - {} + {}, ); diff --git a/packages/core-languages/db/schema.js b/packages/core-languages/db/schema.js index 8e0ebb370e..d430f8f9ce 100644 --- a/packages/core-languages/db/schema.js +++ b/packages/core-languages/db/schema.js @@ -16,6 +16,6 @@ Languages.attachSchema( authorId: { type: String, required: true }, ...Schemas.timestampFields, }, - { requiredByDefault: false } - ) + { requiredByDefault: false }, + ), ); diff --git a/packages/core-logger/createLogger.js b/packages/core-logger/createLogger.js index 8f1b71d1a3..0fa3a49254 100644 --- a/packages/core-logger/createLogger.js +++ b/packages/core-logger/createLogger.js @@ -28,7 +28,7 @@ const myFormat = printf( ({ level, message, label: _label, timestamp: _timestamp, ...rest }) => { const otherPropsString = stringify(rest); return `${_timestamp} [${_label}] ${level}: ${message} ${otherPropsString}`; - } + }, ); export { transports, format }; @@ -42,7 +42,7 @@ export default (moduleName, moreTransports = []) => { timestamp(), label({ label: moduleName }), colorize(), - myFormat + myFormat, ), stderrLevels: ['error'], consoleWarnLevels: ['warn'], diff --git a/packages/core-logger/db/schema.js b/packages/core-logger/db/schema.js index f641c388a8..69dded38eb 100644 --- a/packages/core-logger/db/schema.js +++ b/packages/core-logger/db/schema.js @@ -13,8 +13,8 @@ Logs.attachSchema( meta: { type: Object, blackbox: true }, ...Schemas.timestampFields, }, - { requiredByDefault: false } - ) + { requiredByDefault: false }, + ), ); Migrations.add({ @@ -36,7 +36,7 @@ Migrations.add({ orderId: 1, userId: 1, }, - } + }, ); }); }, @@ -60,7 +60,7 @@ Migrations.add({ 'meta.orderId': 1, 'meta.userId': 1, }, - } + }, ); }); }, @@ -73,6 +73,6 @@ export default () => { { created: -1, }, - { expireAfterSeconds: 2 * ONE_DAY_IN_SECONDS } + { expireAfterSeconds: 2 * ONE_DAY_IN_SECONDS }, ); }; diff --git a/packages/core-messaging/director.js b/packages/core-messaging/director.js index 99fe1d2c67..fd96a23950 100644 --- a/packages/core-messaging/director.js +++ b/packages/core-messaging/director.js @@ -43,7 +43,7 @@ class MessagingDirector { static configureTemplate(template, resolver) { logger.info( - `${this.name} -> Registered custom template resolver for ${template}` + `${this.name} -> Registered custom template resolver for ${template}`, ); this.resolvers.set(template, resolver); } diff --git a/packages/core-messaging/worker/message.js b/packages/core-messaging/worker/message.js index 95d9015de0..0dfa4412ef 100644 --- a/packages/core-messaging/worker/message.js +++ b/packages/core-messaging/worker/message.js @@ -27,7 +27,7 @@ class Message extends WorkerPlugin { originalWorkId: _id, }); return work; - }) + }), ); return { success: true, result: { forked } }; } diff --git a/packages/core-orders/db/order-deliveries/helpers.js b/packages/core-orders/db/order-deliveries/helpers.js index 382a46f90d..18a1c08b05 100644 --- a/packages/core-orders/db/order-deliveries/helpers.js +++ b/packages/core-orders/db/order-deliveries/helpers.js @@ -73,7 +73,7 @@ OrderDeliveries.helpers({ if (arbitraryResponseData) { this.setStatus( OrderDeliveryStatus.DELIVERED, - JSON.stringify(arbitraryResponseData) + JSON.stringify(arbitraryResponseData), ); } }, @@ -106,7 +106,7 @@ OrderDeliveries.helpers({ { _id: this._id }, { $set: { updated: new Date(), calculation }, - } + }, ); }, }); @@ -134,7 +134,7 @@ OrderDeliveries.updateDelivery = ({ deliveryId, orderId, context }) => { { _id: deliveryId }, { $set: { context }, - } + }, ); Orders.updateCalculation({ orderId }); return OrderDeliveries.findOne({ _id: deliveryId }); diff --git a/packages/core-orders/db/order-deliveries/schema.js b/packages/core-orders/db/order-deliveries/schema.js index ec614f3f2d..6d61b9b3fc 100644 --- a/packages/core-orders/db/order-deliveries/schema.js +++ b/packages/core-orders/db/order-deliveries/schema.js @@ -30,8 +30,8 @@ OrderDeliveries.attachSchema( ...calculationFields, ...logFields, }, - { requiredByDefault: false } - ) + { requiredByDefault: false }, + ), ); export default OrderDeliveryStatus; diff --git a/packages/core-orders/db/order-discounts/helpers.js b/packages/core-orders/db/order-discounts/helpers.js index 7ed6806972..4362c3f254 100644 --- a/packages/core-orders/db/order-discounts/helpers.js +++ b/packages/core-orders/db/order-discounts/helpers.js @@ -83,7 +83,7 @@ OrderDiscounts.createManualOrderDiscount = ({ orderId, code, ...rest }) => { const order = Orders.findOne({ _id: orderId }); const director = new DiscountDirector({ order }); const discountKey = Promise.await( - director.resolveDiscountKeyFromStaticCode({ code }) + director.resolveDiscountKeyFromStaticCode({ code }), ); if (discountKey) { const newDiscount = OrderDiscounts.createDiscount({ @@ -117,7 +117,7 @@ OrderDiscounts.createDiscount = ({ const normalizedTrigger = trigger || OrderDiscountTrigger.USER; log( `Create Order Discount: ${discountKey} with trigger ${normalizedTrigger}`, - { orderId } + { orderId }, ); const discountId = OrderDiscounts.insert({ ...rest, @@ -139,7 +139,7 @@ OrderDiscounts.updateDiscount = ({ discountId, ...rest }) => { updated: new Date(), ...rest, }, - } + }, ); return OrderDiscounts.findOne({ _id: discountId }); }; @@ -197,8 +197,8 @@ OrderDiscounts.updateDiscounts = ({ orderId }) => { if (!isValid) { OrderDiscounts.removeDiscount({ discountId: discount._id }); } - }) - ) + }), + ), ); // 2. run auto-system discount @@ -213,6 +213,6 @@ OrderDiscounts.updateDiscounts = ({ orderId }) => { orderId, discountKey, trigger: OrderDiscountTrigger.SYSTEM, - }) + }), ); }; diff --git a/packages/core-orders/db/order-discounts/schema.js b/packages/core-orders/db/order-discounts/schema.js index e0c46b8020..076acce0b8 100644 --- a/packages/core-orders/db/order-discounts/schema.js +++ b/packages/core-orders/db/order-discounts/schema.js @@ -20,8 +20,8 @@ OrderDiscounts.attachSchema( ...contextFields, ...timestampFields, }, - { requiredByDefault: false } - ) + { requiredByDefault: false }, + ), ); export default OrderDiscountTrigger; diff --git a/packages/core-orders/db/order-documents/helpers.js b/packages/core-orders/db/order-documents/helpers.js index f5273eae31..08625ea65d 100644 --- a/packages/core-orders/db/order-documents/helpers.js +++ b/packages/core-orders/db/order-documents/helpers.js @@ -40,7 +40,7 @@ class OrderDocumentDirector extends DocumentDirector { type: OrderDocumentTypes.ORDER_CONFIRMATION, ...meta, }, - rest + rest, ); } }); @@ -66,7 +66,7 @@ class OrderDocumentDirector extends DocumentDirector { status: delivery.status, ...meta, }, - rest + rest, ); } }); @@ -92,7 +92,7 @@ class OrderDocumentDirector extends DocumentDirector { status: payment.status, ...meta, }, - rest + rest, ); const { file: receipt, meta: receiptMeta, ...receiptRest } = files[1]; this.context.order.addDocument( @@ -104,7 +104,7 @@ class OrderDocumentDirector extends DocumentDirector { status: payment.status, ...receiptMeta, }, - receiptRest + receiptRest, ); } }); diff --git a/packages/core-orders/db/order-payments/helpers.js b/packages/core-orders/db/order-payments/helpers.js index be0cdde7d3..ee41319bce 100644 --- a/packages/core-orders/db/order-payments/helpers.js +++ b/packages/core-orders/db/order-payments/helpers.js @@ -69,12 +69,12 @@ OrderPayments.helpers({ }, order, }, - order.userId + order.userId, ); if (arbitraryResponseData) { this.setStatus( OrderPaymentStatus.PAID, - JSON.stringify(arbitraryResponseData) + JSON.stringify(arbitraryResponseData), ); } }, @@ -105,7 +105,7 @@ OrderPayments.helpers({ const calculation = pricing.calculate(); return OrderPayments.update( { _id: this._id }, - { $set: { calculation, updated: new Date() } } + { $set: { calculation, updated: new Date() } }, ); }, }); @@ -133,7 +133,7 @@ OrderPayments.updatePayment = ({ orderId, paymentId, context }) => { { _id: paymentId }, { $set: { context, updated: new Date() }, - } + }, ); Orders.updateCalculation({ orderId }); return OrderPayments.findOne({ _id: paymentId }); diff --git a/packages/core-orders/db/order-payments/schema.js b/packages/core-orders/db/order-payments/schema.js index e9ebe67e20..cf1f30fb56 100644 --- a/packages/core-orders/db/order-payments/schema.js +++ b/packages/core-orders/db/order-payments/schema.js @@ -30,8 +30,8 @@ OrderPayments.attachSchema( ...calculationFields, ...logFields, }, - { requiredByDefault: false } - ) + { requiredByDefault: false }, + ), ); export default OrderPaymentStatus; diff --git a/packages/core-orders/db/order-positions/helpers.js b/packages/core-orders/db/order-positions/helpers.js index 3cf04c3d84..e202b0f5d8 100644 --- a/packages/core-orders/db/order-positions/helpers.js +++ b/packages/core-orders/db/order-positions/helpers.js @@ -58,7 +58,7 @@ OrderPositions.helpers({ errors.push(new Error('This product is not available anymore')); if (this.quotationId && !this.quotation().isProposalValid()) errors.push( - new Error('Quotation expired or fullfiled, please request a new offer') + new Error('Quotation expired or fullfiled, please request a new offer'), ); }, reserve() { @@ -75,7 +75,7 @@ OrderPositions.helpers({ return scheduling.map((schedule) => { const context = { warehousingProvider: WarehousingProviders.findProviderById( - schedule.warehousingProviderId + schedule.warehousingProviderId, ), deliveryProvider: order.delivery().provider(), product: this.product(), @@ -96,7 +96,7 @@ OrderPositions.helpers({ if (configurationItem.key === key) return configurationItem.value; return accumulator; }, - undefined + undefined, ); }, updateCalculation() { @@ -109,7 +109,7 @@ OrderPositions.helpers({ { _id: this._id }, { $set: { calculation }, - } + }, ); return OrderPositions.findOne({ _id: this._id }); }, @@ -146,7 +146,7 @@ OrderPositions.helpers({ { _id: this._id }, { $set: { scheduling }, - } + }, ); }, }); @@ -173,7 +173,7 @@ OrderPositions.upsertPosition = ({ }, { quantity: existingPosition.quantity + quantity, - } + }, ); } return OrderPositions.createPosition({ @@ -198,7 +198,7 @@ OrderPositions.createPosition = ({ `Create ${quantity}x Position with Product ${productId} ${ quotationId ? ` (${quotationId})` : '' }`, - { orderId } + { orderId }, ); const positionId = OrderPositions.insert({ ...rest, @@ -218,7 +218,7 @@ OrderPositions.createPosition = ({ OrderPositions.updatePosition = ( { orderId, positionId }, - { quantity = null, configuration = null } + { quantity = null, configuration = null }, ) => { const orderPosition = OrderPositions.findOne({ orderId, @@ -228,7 +228,7 @@ OrderPositions.updatePosition = ( if (quantity !== null) { log( `OrderPosition ${positionId} -> Update Quantity of ${positionId} to ${quantity}x`, - { orderId } + { orderId }, ); OrderPositions.update( @@ -238,15 +238,15 @@ OrderPositions.updatePosition = ( quantity, updated: new Date(), }, - } + }, ); } if (configuration !== null) { log( `OrderPosition ${positionId} -> Update confiugration of ${positionId} to ${JSON.stringify( - configuration + configuration, )}x`, - { orderId } + { orderId }, ); // check if the variant has changed const originalProduct = orderPosition.originalProduct(); @@ -262,7 +262,7 @@ OrderPositions.updatePosition = ( productId: resolvedProduct._id, updated: new Date(), }, - } + }, ); } @@ -273,7 +273,7 @@ OrderPositions.updatePosition = ( configuration, updated: new Date(), }, - } + }, ); } Orders.updateCalculation({ orderId }); diff --git a/packages/core-orders/db/order-positions/schema.js b/packages/core-orders/db/order-positions/schema.js index 7b027d5335..52a1541fdd 100644 --- a/packages/core-orders/db/order-positions/schema.js +++ b/packages/core-orders/db/order-positions/schema.js @@ -41,6 +41,6 @@ OrderPositions.attachSchema( ...contextFields, ...calculationFields, }, - { requiredByDefault: false } - ) + { requiredByDefault: false }, + ), ); diff --git a/packages/core-orders/db/orders/schema.js b/packages/core-orders/db/orders/schema.js index 1fbc4329e0..1371829cbb 100644 --- a/packages/core-orders/db/orders/schema.js +++ b/packages/core-orders/db/orders/schema.js @@ -40,8 +40,8 @@ Orders.attachSchema( ...calculationFields, ...logFields, }, - { requiredByDefault: false } - ) + { requiredByDefault: false }, + ), ); export default OrderStatus; diff --git a/packages/core-payment/db/helpers.js b/packages/core-payment/db/helpers.js index 442d5f1cbb..d1f209277f 100644 --- a/packages/core-payment/db/helpers.js +++ b/packages/core-payment/db/helpers.js @@ -15,7 +15,7 @@ Users.helpers({ sort: { created: -1, }, - } + }, ).fetch(); }, }); @@ -38,12 +38,12 @@ PaymentProviders.helpers({ }, isPayLaterAllowed(context) { return new PaymentDirector(this).isPayLaterAllowed( - this.defaultContext(context) + this.defaultContext(context), ); }, register(context) { return Promise.await( - new PaymentDirector(this).register(this.defaultContext(context)) + new PaymentDirector(this).register(this.defaultContext(context)), ); }, validate(credentials) { @@ -51,7 +51,7 @@ PaymentProviders.helpers({ }, sign(context) { return Promise.await( - new PaymentDirector(this).sign(this.defaultContext(context)) + new PaymentDirector(this).sign(this.defaultContext(context)), ); }, charge(context, userId) { @@ -109,7 +109,7 @@ PaymentCredentials.markPreferred = ({ userId, paymentCredentialsId }) => { $set: { isPreferred: true, }, - } + }, ); PaymentCredentials.update( { @@ -120,7 +120,7 @@ PaymentCredentials.markPreferred = ({ userId, paymentCredentialsId }) => { $set: { isPreferred: false, }, - } + }, ); }; @@ -147,7 +147,7 @@ PaymentCredentials.upsertCredentials = ({ token, meta, }, - } + }, ); if (insertedId) { @@ -168,7 +168,7 @@ PaymentCredentials.registerPaymentCredentials = ({ const paymentProvider = PaymentProviders.findOne({ _id: paymentProviderId }); const registration = paymentProvider.register( { transactionContext: paymentContext }, - userId + userId, ); if (!registration) return null; const { token, ...meta } = registration; @@ -210,7 +210,7 @@ PaymentProviders.updateProvider = ({ _id, ...rest }) => { ...rest, updated: new Date(), }, - } + }, ); return PaymentProviders.findOne({ _id, deleted: null }); }; @@ -222,7 +222,7 @@ PaymentProviders.removeProvider = ({ _id }) => { $set: { deleted: new Date(), }, - } + }, ); return PaymentProviders.findOne({ _id }); }; @@ -233,13 +233,13 @@ PaymentProviders.findProviderById = (_id, ...options) => PaymentProviders.findProviders = ({ type } = {}, ...options) => PaymentProviders.find( { ...(type ? { type } : {}), deleted: null }, - ...options + ...options, ).fetch(); PaymentProviders.findSupported = ({ order }, ...options) => { const providers = PaymentProviders.findProviders( {}, - ...options + ...options, ).filter((paymentProvider) => paymentProvider.isActive(order)); return settings.filterSupportedProviders({ providers, order }); }; diff --git a/packages/core-payment/db/schema.js b/packages/core-payment/db/schema.js index d35ec0125c..b637e798cc 100644 --- a/packages/core-payment/db/schema.js +++ b/packages/core-payment/db/schema.js @@ -20,8 +20,8 @@ PaymentProviders.attachSchema( 'configuration.$.value': { type: String }, ...Schemas.timestampFields, }, - { requiredByDefault: false } - ) + { requiredByDefault: false }, + ), ); PaymentCredentials.attachSchema( @@ -34,8 +34,8 @@ PaymentCredentials.attachSchema( meta: { type: Object, blackbox: true }, ...Schemas.timestampFields, }, - { requiredByDefault: false } - ) + { requiredByDefault: false }, + ), ); Migrations.add({ @@ -47,7 +47,7 @@ Migrations.add({ { $set: { adapterKey: 'shop.unchained.invoice' }, }, - { multi: true } + { multi: true }, ); }, down() { @@ -56,7 +56,7 @@ Migrations.add({ { $set: { adapterKey: 'ch.dagobert.invoice' }, }, - { multi: true } + { multi: true }, ); }, }); diff --git a/packages/core-payment/director.js b/packages/core-payment/director.js index 2d2d14d6fb..61cece32c8 100644 --- a/packages/core-payment/director.js +++ b/packages/core-payment/director.js @@ -85,7 +85,7 @@ class PaymentDirector { const Adapter = this.interfaceClass(); if (!Adapter) { throw new Error( - `Payment Plugin ${this.provider.adapterKey} not available` + `Payment Plugin ${this.provider.adapterKey} not available`, ); } return new Adapter(this.provider.configuration, context); @@ -157,7 +157,7 @@ class PaymentDirector { static registerAdapter(adapter) { log( - `${this.name} -> Registered ${adapter.key} ${adapter.version} (${adapter.label})` + `${this.name} -> Registered ${adapter.key} ${adapter.version} (${adapter.label})`, ); PaymentDirector.adapters.set(adapter.key, adapter); } diff --git a/packages/core-payment/plugins/apple-iap.js b/packages/core-payment/plugins/apple-iap.js index 3db17108bb..8d96d19ce2 100644 --- a/packages/core-payment/plugins/apple-iap.js +++ b/packages/core-payment/plugins/apple-iap.js @@ -18,7 +18,7 @@ import { Mongo } from 'meteor/mongo'; const logger = createLogger('unchained:core-payment:apple-iap'); const AppleTransactions = new Mongo.Collection( - 'payment_apple_iap_processed_transactions' + 'payment_apple_iap_processed_transactions', ); const { @@ -30,7 +30,7 @@ WebApp.connectHandlers.use( APPLE_IAP_WEBHOOK_PATH, bodyParser.json({ strict: false, - }) + }), ); const environments = { @@ -76,7 +76,7 @@ const fixPeriods = ({ // eslint-disable-next-line ({ original_transaction_id }) => { return original_transaction_id === transactionId; // eslint-disable-line - } + }, ); const adjustedSubscriptionPeriods = relevantTransactions @@ -100,7 +100,7 @@ const fixPeriods = ({ $pull: { periods: { orderId: { $in: [orderId, undefined, null] } }, }, - } + }, ); Subscriptions.update( @@ -114,7 +114,7 @@ const fixPeriods = ({ $push: { periods: { $each: adjustedSubscriptionPeriods }, }, - } + }, ); }; @@ -158,7 +158,7 @@ WebApp.connectHandlers.use(APPLE_IAP_WEBHOOK_PATH, async (req, res) => { }); logger.verbose( `Confirmed checkout for order ${checkedOut.orderNumber}`, - { orderId: checkedOut._id } + { orderId: checkedOut._id }, ); } } else { @@ -189,7 +189,7 @@ WebApp.connectHandlers.use(APPLE_IAP_WEBHOOK_PATH, async (req, res) => { }); logger.verbose( - `Processed notification for ${latestTransaction.original_transaction_id} and type ${responseBody.notification_type}` + `Processed notification for ${latestTransaction.original_transaction_id} and type ${responseBody.notification_type}`, ); if ( @@ -309,7 +309,7 @@ class AppleIAP extends PaymentAdapter { if (!transactionIdentifier) { throw new Error( - 'Apple IAP -> You have to set the transaction id on the order payment' + 'Apple IAP -> You have to set the transaction id on the order payment', ); } @@ -333,7 +333,7 @@ class AppleIAP extends PaymentAdapter { ); if (!matchedTransaction) { throw new Error( - `Apple IAP -> Cannot match transaction with identifier ${transactionIdentifier}` + `Apple IAP -> Cannot match transaction with identifier ${transactionIdentifier}`, ); } @@ -343,12 +343,12 @@ class AppleIAP extends PaymentAdapter { ...acc, [item.productId]: (acc[item.productId] || 0) + item.quantity, }; - }, {}) + }, {}), ); if (items.length !== 1) { throw new Error( - 'Apple IAP -> You can only checkout 1 unique product at once' + 'Apple IAP -> You can only checkout 1 unique product at once', ); } @@ -360,7 +360,7 @@ class AppleIAP extends PaymentAdapter { if (!orderMatchesTransaction) throw new Error( - 'Apple IAP -> Product in order does not match transaction' + 'Apple IAP -> Product in order does not match transaction', ); const transactionAlreadyProcessed = diff --git a/packages/core-payment/plugins/coinbase.js b/packages/core-payment/plugins/coinbase.js index 4de42bb0bb..b31bacd263 100644 --- a/packages/core-payment/plugins/coinbase.js +++ b/packages/core-payment/plugins/coinbase.js @@ -98,7 +98,7 @@ class Coinbase extends PaymentAdapter { const charge = await coinbase.resources.Charge.retrieve(chargeCode); const completed = !!charge.timeline.find( - (statusUpdate) => statusUpdate.status === 'COMPLETED' + (statusUpdate) => statusUpdate.status === 'COMPLETED', ); if (completed) { diff --git a/packages/core-payment/plugins/datatrans.js b/packages/core-payment/plugins/datatrans.js index 8ea68df11f..d18e0e4f02 100644 --- a/packages/core-payment/plugins/datatrans.js +++ b/packages/core-payment/plugins/datatrans.js @@ -69,7 +69,7 @@ const datatransAuthorize = async ({ 'Content-Type': 'application/xml', Authorization: `Basic ${DATATRANS_SECRET}`, }, - } + }, ); const xml = await result.text(); return xml2js.parseStringPromise(xml); @@ -77,7 +77,7 @@ const datatransAuthorize = async ({ WebApp.connectHandlers.use( DATATRANS_WEBHOOK_PATH, - bodyParser.urlencoded({ extended: false }) + bodyParser.urlencoded({ extended: false }), ); WebApp.connectHandlers.use(DATATRANS_WEBHOOK_PATH, (req, res) => { @@ -93,11 +93,11 @@ WebApp.connectHandlers.use(DATATRANS_WEBHOOK_PATH, (req, res) => { paymentProviderId, paymentContext: authorizationResponse, userId, - } + }, ); logger.info( `Datatrans Webhook: Unchained registered payment credentials for ${userId}`, - { userId } + { userId }, ); res.writeHead(200); return res.end(JSON.stringify(paymentCredentials)); @@ -109,7 +109,7 @@ WebApp.connectHandlers.use(DATATRANS_WEBHOOK_PATH, (req, res) => { res.writeHead(200); logger.info( `Datatrans Webhook: Unchained confirmed checkout for order ${order.orderNumber}`, - { orderId: order._id } + { orderId: order._id }, ); return res.end(JSON.stringify(order)); } catch (e) { @@ -120,7 +120,7 @@ WebApp.connectHandlers.use(DATATRANS_WEBHOOK_PATH, (req, res) => { // We also confirm a declined payment or a signature mismatch with 200 so // datatrans does not retry to send us the failed transaction logger.warn( - `Datatrans Webhook: Unchained declined checkout with message ${e.message}` + `Datatrans Webhook: Unchained declined checkout with message ${e.message}`, ); res.writeHead(200); return res.end(); @@ -196,7 +196,7 @@ class Datatrans extends PaymentAdapter { merchantId, amount, currency, - refno + refno, ); this.log( `Datatrans -> Signed for Registration ${JSON.stringify({ @@ -205,7 +205,7 @@ class Datatrans extends PaymentAdapter { amount, currency, refno, - })} with ${signature}` + })} with ${signature}`, ); return signature; } @@ -219,7 +219,7 @@ class Datatrans extends PaymentAdapter { merchantId, amount, currency, - refno + refno, ); this.log( `Datatrans -> Signed ${JSON.stringify({ @@ -228,7 +228,7 @@ class Datatrans extends PaymentAdapter { amount, currency, refno, - })} with ${signature}` + })} with ${signature}`, ); return signature; } @@ -269,14 +269,14 @@ class Datatrans extends PaymentAdapter { merchantId, '0', // amount 0 currency, - refno + refno, ); const validSign2 = generateSignature( aliasCC, merchantId, '0', // amount 0 currency, - uppTransactionId + uppTransactionId, ); if (sign === validSign && sign2 === validSign2) { this.log('Datatrans -> Registered successfully', transactionResponse); @@ -291,7 +291,7 @@ class Datatrans extends PaymentAdapter { } this.log( `Datatrans -> Somebody evil attempted to trick us, fix ${sign} === ${validSign}, ${sign2} === ${validSign2}`, - transactionResponse + transactionResponse, ); } this.log('Datatrans -> Registration declined', transactionResponse); @@ -318,7 +318,7 @@ class Datatrans extends PaymentAdapter { if (!response || response.status?.[0] !== 'success') { this.log( 'Datatrans -> Payment declined from authorization service', - result + result, ); throw new Error('Payment declined'); } @@ -326,7 +326,7 @@ class Datatrans extends PaymentAdapter { const convertedResponse = Object.fromEntries( Object.entries(response).map(([key, values]) => { return [key, values?.[0]]; - }) + }), ); return { ...paymentCredentials.meta, @@ -342,7 +342,7 @@ class Datatrans extends PaymentAdapter { async charge(payload) { if (!payload) { this.log( - 'Datatrans -> Not trying to charge because of missing payment authorization response, return false to provide later' + 'Datatrans -> Not trying to charge because of missing payment authorization response, return false to provide later', ); return false; } @@ -376,14 +376,14 @@ class Datatrans extends PaymentAdapter { merchantId, amount, currency, - refno + refno, ); const validSign2 = generateSignature( aliasCC, merchantId, amount, currency, - uppTransactionId + uppTransactionId, ); if ((sign === validSign && sign2 === validSign2) || ignoreSignatureCheck) { this.log('Datatrans -> Charged successfully', transactionResponse); @@ -401,7 +401,7 @@ class Datatrans extends PaymentAdapter { } this.log( `Datatrans -> Somebody evil attempted to trick us, fix ${sign} === ${validSign}, ${sign2} === ${validSign2}`, - transactionResponse + transactionResponse, ); throw new Error('Signature mismatch'); } diff --git a/packages/core-payment/plugins/paypal-checkout.js b/packages/core-payment/plugins/paypal-checkout.js index 8d0d47eb29..74414fb4c3 100644 --- a/packages/core-payment/plugins/paypal-checkout.js +++ b/packages/core-payment/plugins/paypal-checkout.js @@ -68,7 +68,7 @@ class PaypalCheckout extends PaymentAdapter { this.log( 'Paypal Native -> PAYPAL ORDER', - JSON.stringify(order.result, null, 2) + JSON.stringify(order.result, null, 2), ); this.log('Paypal Native -> OUR ORDER', this.context.order); this.log('Paypal Native -> OUR PRICE', pricing); diff --git a/packages/core-payment/plugins/paypal.js b/packages/core-payment/plugins/paypal.js index 99788afb03..a27a54a7ca 100644 --- a/packages/core-payment/plugins/paypal.js +++ b/packages/core-payment/plugins/paypal.js @@ -99,7 +99,7 @@ class Paypal extends PaymentAdapter { async charge({ paypalPaymentMethodNonce }) { if (!paypalPaymentMethodNonce) throw new Error( - 'You have to provide paypalPaymentMethodNonce in paymentContext' + 'You have to provide paypalPaymentMethodNonce in paymentContext', ); const braintree = require('braintree'); // eslint-disable-line const gateway = this.gateway(braintree); diff --git a/packages/core-payment/settings.js b/packages/core-payment/settings.js index 9c79718ee4..68e2a7c594 100644 --- a/packages/core-payment/settings.js +++ b/packages/core-payment/settings.js @@ -15,7 +15,7 @@ const settings = { load({ sortProviders, filterSupportedProviders = allProviders } = {}) { if (sortProviders) { logger.warn( - 'sortProviders is deprecated, please specifc filterSupportedProviders instead' + 'sortProviders is deprecated, please specifc filterSupportedProviders instead', ); this.filterSupportedProviders = ({ providers }) => { return providers.sort(sortProviders).map(({ _id }) => _id); diff --git a/packages/core-pricing/delivery-pricing/director.js b/packages/core-pricing/delivery-pricing/director.js index d5bbcda483..2c11859694 100644 --- a/packages/core-pricing/delivery-pricing/director.js +++ b/packages/core-pricing/delivery-pricing/director.js @@ -27,7 +27,7 @@ class DeliveryPricingAdapter { calculate() { const resultRaw = this.result.getRawPricingSheet(); resultRaw.forEach(({ amount, category }) => - this.log(`Delivery Calculation -> ${category} ${amount}`) + this.log(`Delivery Calculation -> ${category} ${amount}`), ); return resultRaw; } @@ -70,7 +70,7 @@ class DeliveryPricingDirector { calculate() { this.calculation = DeliveryPricingDirector.sortedAdapters() .filter((AdapterClass) => - AdapterClass.isActivatedFor(this.context.provider) + AdapterClass.isActivatedFor(this.context.provider), ) .reduce((calculation, AdapterClass) => { const discounts = this.context.discounts @@ -78,7 +78,7 @@ class DeliveryPricingDirector { discountId: discount._id, configuration: discount.configurationForPricingAdapterKey( AdapterClass.key, - calculation + calculation, ), })) .filter(({ configuration }) => configuration !== null); @@ -89,7 +89,7 @@ class DeliveryPricingDirector { discounts, }); const nextCalculationResult = Promise.await( - concreteAdapter.calculate() + concreteAdapter.calculate(), ); return calculation.concat(nextCalculationResult); } catch (error) { @@ -118,7 +118,7 @@ class DeliveryPricingDirector { static registerAdapter(adapter) { log( - `${this.name} -> Registered ${adapter.key} ${adapter.version} (${adapter.label})` + `${this.name} -> Registered ${adapter.key} ${adapter.version} (${adapter.label})`, ); DeliveryPricingDirector.adapters.set(adapter.key, adapter); } diff --git a/packages/core-pricing/delivery-pricing/sheet.js b/packages/core-pricing/delivery-pricing/sheet.js index c7efa88bc8..9920c1c72f 100644 --- a/packages/core-pricing/delivery-pricing/sheet.js +++ b/packages/core-pricing/delivery-pricing/sheet.js @@ -58,7 +58,7 @@ class DeliveryPricingSheet extends PricingSheet { discountPrices(explicitDiscountId) { const discountIds = this.getDiscountRows(explicitDiscountId).map( - ({ discountId }) => discountId + ({ discountId }) => discountId, ); return [...new Set(discountIds)] diff --git a/packages/core-pricing/order-pricing/director.js b/packages/core-pricing/order-pricing/director.js index 86eed150ae..a8e8155f2f 100644 --- a/packages/core-pricing/order-pricing/director.js +++ b/packages/core-pricing/order-pricing/director.js @@ -26,7 +26,7 @@ class OrderPricingAdapter { async calculate() { const resultRaw = this.result.getRawPricingSheet(); resultRaw.forEach(({ amount, category }) => - this.log(`Order Calculation -> ${category} ${amount}`) + this.log(`Order Calculation -> ${category} ${amount}`), ); return resultRaw; } @@ -68,7 +68,7 @@ class OrderPricingDirector { discountId: discount._id, configuration: discount.configurationForPricingAdapterKey( AdapterClass.key, - calculation + calculation, ), })) .filter(({ configuration }) => configuration !== null); @@ -79,7 +79,7 @@ class OrderPricingDirector { discounts, }); const nextCalculationResult = Promise.await( - concreteAdapter.calculate() + concreteAdapter.calculate(), ); return calculation.concat(nextCalculationResult); } catch (error) { @@ -107,7 +107,7 @@ class OrderPricingDirector { static registerAdapter(adapter) { log( - `${this.name} -> Registered ${adapter.key} ${adapter.version} (${adapter.label})` + `${this.name} -> Registered ${adapter.key} ${adapter.version} (${adapter.label})`, ); OrderPricingDirector.adapters.set(adapter.key, adapter); } diff --git a/packages/core-pricing/order-pricing/sheet.js b/packages/core-pricing/order-pricing/sheet.js index f38a7879b3..d148b8d70f 100644 --- a/packages/core-pricing/order-pricing/sheet.js +++ b/packages/core-pricing/order-pricing/sheet.js @@ -95,7 +95,7 @@ class OrderPricingSheet extends PricingSheet { discountPrices(explicitDiscountId) { const discountIds = this.getDiscountRows(explicitDiscountId).map( - ({ discountId }) => discountId + ({ discountId }) => discountId, ); return [...new Set(discountIds)] @@ -150,10 +150,10 @@ class OrderPricingSheet extends PricingSheet { items: formatter(this.total(OrderPricingSheetRowCategories.Items).amount), taxes: formatter(this.total(OrderPricingSheetRowCategories.Taxes).amount), delivery: formatter( - this.total(OrderPricingSheetRowCategories.Delivery).amount + this.total(OrderPricingSheetRowCategories.Delivery).amount, ), payment: formatter( - this.total(OrderPricingSheetRowCategories.Payment).amount + this.total(OrderPricingSheetRowCategories.Payment).amount, ), net: formatter(this.total().amount), }; diff --git a/packages/core-pricing/payment-pricing/director.js b/packages/core-pricing/payment-pricing/director.js index e6eba36586..6a5ad12ec4 100644 --- a/packages/core-pricing/payment-pricing/director.js +++ b/packages/core-pricing/payment-pricing/director.js @@ -25,7 +25,7 @@ class PaymentPricingAdapter { async calculate() { const resultRaw = this.result.getRawPricingSheet(); resultRaw.forEach(({ amount, category }) => - this.log(`Payment Calculation -> ${category} ${amount}`) + this.log(`Payment Calculation -> ${category} ${amount}`), ); return resultRaw; } @@ -56,7 +56,7 @@ class PaymentPricingDirector { calculate() { this.calculation = PaymentPricingDirector.sortedAdapters() .filter((AdapterClass) => - AdapterClass.isActivatedFor(this.context.provider) + AdapterClass.isActivatedFor(this.context.provider), ) .reduce((calculation, AdapterClass) => { try { @@ -65,7 +65,7 @@ class PaymentPricingDirector { calculation, }); const nextCalculationResult = Promise.await( - concreteAdapter.calculate() + concreteAdapter.calculate(), ); return calculation.concat(nextCalculationResult); } catch (error) { @@ -93,7 +93,7 @@ class PaymentPricingDirector { static registerAdapter(adapter) { log( - `${this.name} -> Registered ${adapter.key} ${adapter.version} (${adapter.label})` + `${this.name} -> Registered ${adapter.key} ${adapter.version} (${adapter.label})`, ); PaymentPricingDirector.adapters.set(adapter.key, adapter); } diff --git a/packages/core-pricing/payment-pricing/sheet.js b/packages/core-pricing/payment-pricing/sheet.js index 0af039e9d4..3d7bfa5a2e 100644 --- a/packages/core-pricing/payment-pricing/sheet.js +++ b/packages/core-pricing/payment-pricing/sheet.js @@ -58,7 +58,7 @@ class PaymentPricingSheet extends PricingSheet { discountPrices(explicitDiscountId) { const discountIds = this.getDiscountRows(explicitDiscountId).map( - ({ discountId }) => discountId + ({ discountId }) => discountId, ); return [...new Set(discountIds)] diff --git a/packages/core-pricing/plugins/order-discount.js b/packages/core-pricing/plugins/order-discount.js index 6bfd1c0538..e35e9e5256 100644 --- a/packages/core-pricing/plugins/order-discount.js +++ b/packages/core-pricing/plugins/order-discount.js @@ -36,7 +36,7 @@ const applyDiscountToMultipleShares = (shares, amount) => { currentTaxAmount + shareTaxAmount, ]; }, - [0, 0] + [0, 0], ); }; @@ -80,16 +80,16 @@ class OrderItems extends OrderPricingAdapter { const itemShares = this.context.items.map((item) => resolveRatioAndTaxDivisorForPricingSheet( item.pricing(), - totalAmountOfItems - ) + totalAmountOfItems, + ), ); const deliveryShare = resolveRatioAndTaxDivisorForPricingSheet( this.context.delivery?.pricing(), - totalAmountOfPaymentAndDelivery + totalAmountOfPaymentAndDelivery, ); const paymentShare = resolveRatioAndTaxDivisorForPricingSheet( this.context.payment?.pricing(), - totalAmountOfPaymentAndDelivery + totalAmountOfPaymentAndDelivery, ); let alreadyDeducted = 0; @@ -103,8 +103,8 @@ class OrderItems extends OrderPricingAdapter { itemShares, calculateAmountToSplit( { ...configuration, alreadyDeducted }, - totalAmountOfItems - ) + totalAmountOfItems, + ), ); alreadyDeducted = +itemsDiscountAmount; @@ -116,8 +116,8 @@ class OrderItems extends OrderPricingAdapter { [deliveryShare, paymentShare], calculateAmountToSplit( { ...configuration, alreadyDeducted }, - totalAmountOfPaymentAndDelivery - ) + totalAmountOfPaymentAndDelivery, + ), ); alreadyDeducted = +deliveryAndPaymentDiscountAmount; diff --git a/packages/core-pricing/plugins/order-items.js b/packages/core-pricing/plugins/order-items.js index 1f2795bae7..5517f99a3a 100644 --- a/packages/core-pricing/plugins/order-items.js +++ b/packages/core-pricing/plugins/order-items.js @@ -31,7 +31,7 @@ class OrderItems extends OrderPricingAdapter { { taxes: 0, items: 0, - } + }, ); this.result.addItems({ amount: totalAndTaxesOfAllItems.items }); if (totalAndTaxesOfAllItems.taxes !== 0) { diff --git a/packages/core-pricing/pricing-sheet.js b/packages/core-pricing/pricing-sheet.js index be25e00bbf..971abc4716 100644 --- a/packages/core-pricing/pricing-sheet.js +++ b/packages/core-pricing/pricing-sheet.js @@ -7,7 +7,7 @@ export default class PricingSheet { sum(filterOptions) { return this.filterBy(filterOptions).reduce( (sum, calculationRow) => sum + calculationRow.amount, - 0 + 0, ); } @@ -17,9 +17,9 @@ export default class PricingSheet { oldCalculation.filter( (row) => options[optionKey] === undefined || - row[optionKey] === options[optionKey] + row[optionKey] === options[optionKey], ), - this.calculation + this.calculation, ); } diff --git a/packages/core-pricing/product-pricing/director.js b/packages/core-pricing/product-pricing/director.js index 6a7a0ef118..467bd2f247 100644 --- a/packages/core-pricing/product-pricing/director.js +++ b/packages/core-pricing/product-pricing/director.js @@ -33,7 +33,7 @@ class ProductPricingAdapter { if (!resultRaw.length && !this.calculation.getRawPricingSheet().length) return null; resultRaw.forEach(({ amount, category }) => - this.log(`Item Calculation -> ${category} ${amount}`) + this.log(`Item Calculation -> ${category} ${amount}`), ); return resultRaw; } @@ -89,7 +89,7 @@ class ProductPricingDirector { discountId: discount._id, configuration: discount.configurationForPricingAdapterKey( AdapterClass.key, - calculation + calculation, ), })) .filter(({ configuration }) => configuration !== null); @@ -100,7 +100,7 @@ class ProductPricingDirector { discounts, }); const nextCalculationResult = Promise.await( - concreteAdapter.calculate() + concreteAdapter.calculate(), ); if (!nextCalculationResult) return null; if (!calculation) return nextCalculationResult; @@ -131,7 +131,7 @@ class ProductPricingDirector { static registerAdapter(adapter) { log( - `${this.name} -> Registered ${adapter.key} ${adapter.version} (${adapter.label})` + `${this.name} -> Registered ${adapter.key} ${adapter.version} (${adapter.label})`, ); ProductPricingDirector.adapters.set(adapter.key, adapter); } diff --git a/packages/core-pricing/product-pricing/sheet.js b/packages/core-pricing/product-pricing/sheet.js index e08053e021..cec844e6b1 100644 --- a/packages/core-pricing/product-pricing/sheet.js +++ b/packages/core-pricing/product-pricing/sheet.js @@ -71,7 +71,7 @@ class ProductPricingSheet extends PricingSheet { discountPrices(explicitDiscountId) { const discountIds = this.getDiscountRows(explicitDiscountId).map( - ({ discountId }) => discountId + ({ discountId }) => discountId, ); return [...new Set(discountIds)] diff --git a/packages/core-products/db/product-media/helpers.js b/packages/core-products/db/product-media/helpers.js index 5d888920ff..f73d6d4b05 100644 --- a/packages/core-products/db/product-media/helpers.js +++ b/packages/core-products/db/product-media/helpers.js @@ -17,7 +17,7 @@ ProductMedia.helpers({ ...fields, }, }, - { bypassCollection2: true } + { bypassCollection2: true }, ); return ProductMediaTexts.findOne({ productMediaId: this._id, locale }); }, @@ -41,7 +41,7 @@ ProductMedia.getNewSortKey = (productId) => { }, { sort: { sortKey: -1 }, - } + }, ) || { sortKey: 0 }; return lastProductMedia.sortKey + 1; }; @@ -54,7 +54,7 @@ ProductMedia.updateManualOrder = ({ sortKeys }) => { }, { $set: { sortKey: sortKey + 1, updated: new Date() }, - } + }, ); return productMediaId; }); diff --git a/packages/core-products/db/product-media/schema.js b/packages/core-products/db/product-media/schema.js index dfccd79208..4649bcbfa7 100644 --- a/packages/core-products/db/product-media/schema.js +++ b/packages/core-products/db/product-media/schema.js @@ -13,8 +13,8 @@ ProductMedia.attachSchema( meta: { type: Object, blackbox: true }, ...Schemas.timestampFields, }, - { requiredByDefault: false } - ) + { requiredByDefault: false }, + ), ); ProductMediaTexts.attachSchema( @@ -30,6 +30,6 @@ ProductMediaTexts.attachSchema( subtitle: String, ...Schemas.timestampFields, }, - { requiredByDefault: false } - ) + { requiredByDefault: false }, + ), ); diff --git a/packages/core-products/db/product-reviews/helpers.js b/packages/core-products/db/product-reviews/helpers.js index c76cef491d..37f76b2233 100644 --- a/packages/core-products/db/product-reviews/helpers.js +++ b/packages/core-products/db/product-reviews/helpers.js @@ -83,7 +83,7 @@ ProductReviews.updateReview = function updateReview({ ...review, updated: new Date(), }, - } + }, ); return this.findOne({ _id: productReviewId, deleted: null }); }; @@ -99,7 +99,7 @@ ProductReviews.addVote = function addVote({ productReviewId, type, ...vote }) { ...vote, }, }, - } + }, ); return this.findOne({ _id: productReviewId, deleted: null }); }; @@ -115,7 +115,7 @@ ProductReviews.removeVote = function addVote({ $pull: { votes: { userId, type }, }, - } + }, ); return this.findOne({ _id: productReviewId, deleted: null }); }; @@ -127,7 +127,7 @@ ProductReviews.deleteReview = function deleteReview({ productReviewId }) { $set: { deleted: new Date(), }, - } + }, ); return this.findOne({ _id: productReviewId }); }; @@ -146,6 +146,6 @@ ProductReviews.findReviews = function findReviews( ...(authorId ? { authorId } : {}), deleted: null, }, - ...options + ...options, ).fetch(); }; diff --git a/packages/core-products/db/product-reviews/schema.js b/packages/core-products/db/product-reviews/schema.js index ef185d3fee..45f2493c92 100644 --- a/packages/core-products/db/product-reviews/schema.js +++ b/packages/core-products/db/product-reviews/schema.js @@ -33,6 +33,6 @@ ProductReviews.attachSchema( 'votes.$.meta': { type: Object, blackbox: true }, ...Schemas.timestampFields, }, - { requiredByDefault: false } - ) + { requiredByDefault: false }, + ), ); diff --git a/packages/core-products/db/product-variations/collections.js b/packages/core-products/db/product-variations/collections.js index 8a661139d8..66ecec2ec7 100644 --- a/packages/core-products/db/product-variations/collections.js +++ b/packages/core-products/db/product-variations/collections.js @@ -2,5 +2,5 @@ import { Mongo } from 'meteor/mongo'; export const ProductVariations = new Mongo.Collection('product_variations'); export const ProductVariationTexts = new Mongo.Collection( - 'product_variation_texts' + 'product_variation_texts', ); diff --git a/packages/core-products/db/product-variations/helpers.js b/packages/core-products/db/product-variations/helpers.js index 16dd8c474d..31c8e53984 100644 --- a/packages/core-products/db/product-variations/helpers.js +++ b/packages/core-products/db/product-variations/helpers.js @@ -6,7 +6,7 @@ import { ProductVariations, ProductVariationTexts } from './collections'; ProductVariations.helpers({ upsertLocalizedText( locale, - { productVariationOptionValue = null, ...fields } + { productVariationOptionValue = null, ...fields }, ) { const selector = { productVariationId: this._id, @@ -23,7 +23,7 @@ ProductVariations.helpers({ productVariationOptionValue: productVariationOptionValue || null, }, }, - { bypassCollection2: true } + { bypassCollection2: true }, ); return ProductVariationTexts.findOne(selector); }, @@ -32,7 +32,7 @@ ProductVariations.helpers({ return ProductVariations.getLocalizedTexts( this._id, optionValue, - parsedLocale + parsedLocale, ); }, optionObject(productVariationOption) { @@ -47,7 +47,7 @@ ProductVariations.helpers({ ProductVariations.getLocalizedTexts = ( productVariationId, productVariationOptionValue, - locale + locale, ) => findLocalizedText( ProductVariationTexts, @@ -55,5 +55,5 @@ ProductVariations.getLocalizedTexts = ( productVariationId, productVariationOptionValue: productVariationOptionValue || { $eq: null }, }, - locale + locale, ); diff --git a/packages/core-products/db/product-variations/schema.js b/packages/core-products/db/product-variations/schema.js index 6b4ee1818c..5d6b3cda0a 100644 --- a/packages/core-products/db/product-variations/schema.js +++ b/packages/core-products/db/product-variations/schema.js @@ -17,8 +17,8 @@ ProductVariations.attachSchema( 'options.$': String, ...Schemas.timestampFields, }, - { requiredByDefault: false } - ) + { requiredByDefault: false }, + ), ); ProductVariationTexts.attachSchema( @@ -35,6 +35,6 @@ ProductVariationTexts.attachSchema( subtitle: String, ...Schemas.timestampFields, }, - { requiredByDefault: false } - ) + { requiredByDefault: false }, + ), ); diff --git a/packages/core-products/db/products/helpers.js b/packages/core-products/db/products/helpers.js index efff7b8888..d6949f0193 100644 --- a/packages/core-products/db/products/helpers.js +++ b/packages/core-products/db/products/helpers.js @@ -17,7 +17,7 @@ import { ProductStatus, ProductTypes } from './schema'; Products.createProduct = ( { locale, title, type, sequence, ...rest }, - { autopublish = false } = {} + { autopublish = false } = {}, ) => { const product = { created: new Date(), @@ -60,7 +60,7 @@ ProductTexts.makeSlug = ({ slug, title, productId }, options) => { }; return findUnusedSlug( checkSlugIsUnique, - options + options, )({ existingSlug: slug, title: title || productId, @@ -79,7 +79,7 @@ Products.helpers({ updated: new Date(), published: new Date(), }, - } + }, ); return true; default: @@ -97,7 +97,7 @@ Products.helpers({ updated: new Date(), published: null, }, - } + }, ); return true; default: @@ -124,7 +124,7 @@ Products.helpers({ ...fields, }, }, - { bypassCollection2: true } + { bypassCollection2: true }, ); Products.update( @@ -138,7 +138,7 @@ Products.helpers({ $addToSet: { slugs: slug, }, - } + }, ); Products.update( { @@ -153,7 +153,7 @@ Products.helpers({ slugs: slug, }, }, - { multi: true } + { multi: true }, ); return ProductTexts.findOne({ productId: this._id, locale }); }, @@ -247,7 +247,7 @@ Products.helpers({ }); }); const productIds = filtered.map( - (filteredAssignment) => filteredAssignment.productId + (filteredAssignment) => filteredAssignment.productId, ); const selector = { _id: { $in: productIds }, @@ -281,9 +281,9 @@ Products.helpers({ ...context, ...dispatch, }; - }) + }), ), - [] + [], ); }, @@ -311,9 +311,9 @@ Products.helpers({ ...context, ...stock, }; - }) + }), ), - [] + [], ); }, @@ -350,7 +350,7 @@ Products.helpers({ quantity, useNetPrice, user ? user._id : 'ANONYMOUS', - ].join('') + ].join(''), ) .digest('hex'), amount: userPrice.amount, @@ -367,7 +367,7 @@ Products.helpers({ const pricing = ((this.commerce && this.commerce.pricing) || []).sort( ( { maxQuantity: leftMaxQuantity = 0 }, - { maxQuantity: rightMaxQuantity = 0 } + { maxQuantity: rightMaxQuantity = 0 }, ) => { if ( leftMaxQuantity === rightMaxQuantity || @@ -377,7 +377,7 @@ Products.helpers({ if (leftMaxQuantity === 0) return -1; if (rightMaxQuantity === 0) return 1; return leftMaxQuantity - rightMaxQuantity; - } + }, ); const price = pricing.reduce( (oldValue, curPrice) => { @@ -399,7 +399,7 @@ Products.helpers({ countryCode: country, isTaxable: false, isNetPrice: false, - } + }, ); if (price.amount !== undefined && price.amount !== null) { return { @@ -419,15 +419,15 @@ Products.helpers({ const vectors = configuration.filter(({ key: configurationKey }) => { const isKeyEqualsVariationKey = Boolean( variations.filter( - ({ key: variationKey }) => variationKey === configurationKey - ).length + ({ key: variationKey }) => variationKey === configurationKey, + ).length, ); return isKeyEqualsVariationKey; }); const variants = this.proxyProducts(vectors); if (variants.length !== 1) { throw new Error( - 'There needs to be exactly one variant left when adding a ConfigurableProduct to the cart, configuration not distinct enough' + 'There needs to be exactly one variant left when adding a ConfigurableProduct to the cart, configuration not distinct enough', ); } const resolvedProduct = variants[0]; @@ -439,7 +439,7 @@ Products.helpers({ checkIsActive() { if (!this.isActive()) { throw new Error( - 'This product is not available for ordering at the moment' + 'This product is not available for ordering at the moment', ); } }, @@ -450,7 +450,7 @@ Products.helpers({ reviews({ limit, offset }) { return ProductReviews.findReviews( { productId: this._id }, - { skip: offset, limit } + { skip: offset, limit }, ); }, }); diff --git a/packages/core-products/db/products/schema.js b/packages/core-products/db/products/schema.js index 4786c853fe..1ed94d5cbd 100644 --- a/packages/core-products/db/products/schema.js +++ b/packages/core-products/db/products/schema.js @@ -28,7 +28,7 @@ const ProductCommerceSchema = new SimpleSchema( 'pricing.$.amount': Number, 'pricing.$.maxQuantity': Number, }, - { requiredByDefault: false } + { requiredByDefault: false }, ); const ProductWarehousingSchema = new SimpleSchema( @@ -36,7 +36,7 @@ const ProductWarehousingSchema = new SimpleSchema( baseUnit: String, sku: { type: String, index: true }, }, - { requiredByDefault: false } + { requiredByDefault: false }, ); const ProductSupplySchema = new SimpleSchema( @@ -46,7 +46,7 @@ const ProductSupplySchema = new SimpleSchema( lengthInMillimeters: Number, widthInMillimeters: Number, }, - { requiredByDefault: false } + { requiredByDefault: false }, ); const ProductPlanSchema = new SimpleSchema( @@ -57,7 +57,7 @@ const ProductPlanSchema = new SimpleSchema( trialInterval: String, trialIntervalCount: Number, }, - { requiredByDefault: false } + { requiredByDefault: false }, ); const ProductProxySchema = new SimpleSchema( @@ -67,7 +67,7 @@ const ProductProxySchema = new SimpleSchema( 'assignments.$.vector': { type: Object, blackbox: true }, 'assignments.$.productId': String, }, - { requiredByDefault: false } + { requiredByDefault: false }, ); const ProductConfigurationSchema = new SimpleSchema({ @@ -114,8 +114,8 @@ Products.attachSchema( meta: { type: Object, blackbox: true }, ...Schemas.timestampFields, }, - { requiredByDefault: false } - ) + { requiredByDefault: false }, + ), ); ProductTexts.attachSchema( @@ -133,6 +133,6 @@ ProductTexts.attachSchema( 'labels.$': String, ...Schemas.timestampFields, }, - { requiredByDefault: false } - ) + { requiredByDefault: false }, + ), ); diff --git a/packages/core-quotations/db/quotation-documents/helpers.js b/packages/core-quotations/db/quotation-documents/helpers.js index fa14fd0cbc..db4d10ada9 100644 --- a/packages/core-quotations/db/quotation-documents/helpers.js +++ b/packages/core-quotations/db/quotation-documents/helpers.js @@ -40,7 +40,7 @@ class QuotationDocumentDirector extends DocumentDirector { type: QuotationDocumentTypes.PROPOSAL, ...meta, }, - rest + rest, ); } }); diff --git a/packages/core-quotations/db/quotations/helpers.js b/packages/core-quotations/db/quotations/helpers.js index f41d1235e0..bbf0190e8b 100644 --- a/packages/core-quotations/db/quotations/helpers.js +++ b/packages/core-quotations/db/quotations/helpers.js @@ -32,7 +32,7 @@ Users.helpers({ sort: { created: -1, }, - } + }, ).fetch(); }, }); @@ -68,7 +68,7 @@ Quotations.helpers({ const locale = this.user().locale(options); return this.setStatus( QuotationStatus.PROCESSING, - 'verified elligibility manually' + 'verified elligibility manually', ) .process({ quotationContext }) .sendStatusToCustomer({ locale }); @@ -124,7 +124,7 @@ Quotations.helpers({ transformItemConfiguration(itemConfiguration) { const director = this.director(); return Promise.await( - director.transformItemConfiguration(itemConfiguration) + director.transformItemConfiguration(itemConfiguration), ); }, nextStatus() { @@ -182,7 +182,7 @@ Quotations.helpers({ quotationId: this._id, ...meta, }, - }) + }), ); } const { rawFile, userId } = objOrString; @@ -195,7 +195,7 @@ Quotations.helpers({ quotationId: this._id, ...meta, }, - }) + }), ); }, documents(options) { @@ -240,7 +240,7 @@ Quotations.helpers({ Quotations.requestQuotation = ( { productId, userId, countryCode, configuration }, - options + options, ) => { log('Create Quotation', { userId }); const quotationId = Quotations.insert({ @@ -268,7 +268,7 @@ Quotations.updateContext = ({ context, quotationId }) => { context, updated: new Date(), }, - } + }, ); return Quotations.findOne({ _id: quotationId }); }; @@ -284,7 +284,7 @@ Quotations.updateProposal = ({ price, expires, meta, quotationId }) => { meta, updated: new Date(), }, - } + }, ); return Quotations.findOne({ _id: quotationId }); }; @@ -294,7 +294,7 @@ Quotations.newQuotationNumber = () => { const hashids = new Hashids( 'unchained', 6, - 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890' + 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890', ); while (!quotationNumber) { const randomNumber = Math.floor(Math.random() * (999999999 - 1)) + 1; diff --git a/packages/core-quotations/db/quotations/schema.js b/packages/core-quotations/db/quotations/schema.js index e10fa36fac..9dd53b56c4 100644 --- a/packages/core-quotations/db/quotations/schema.js +++ b/packages/core-quotations/db/quotations/schema.js @@ -43,8 +43,8 @@ Quotations.attachSchema( ...contextFields, ...logFields, }, - { requiredByDefault: false } - ) + { requiredByDefault: false }, + ), ); Migrations.add({ @@ -63,7 +63,7 @@ Migrations.add({ $unset: { currency: 1, }, - } + }, ); }); }, @@ -80,7 +80,7 @@ Migrations.add({ $unset: { currencyCode: 1, }, - } + }, ); }); }, diff --git a/packages/core-quotations/director.js b/packages/core-quotations/director.js index 7a09d394f8..6471750068 100644 --- a/packages/core-quotations/director.js +++ b/packages/core-quotations/director.js @@ -77,7 +77,7 @@ class QuotationDirector { `${this.constructor.name} -> ${AdapterClass.key} (${AdapterClass.version}) skipped`, { level: 'warn', - } + }, ); } return activated; @@ -88,7 +88,7 @@ class QuotationDirector { const Adapter = this.findAppropriateAdapters(context).shift(); if (!Adapter) { throw new Error( - 'No suitable quotation plugin available for this context' + 'No suitable quotation plugin available for this context', ); } return new Adapter({ diff --git a/packages/core-subscriptions/db/subscriptions/helpers.js b/packages/core-subscriptions/db/subscriptions/helpers.js index bd4110e829..76914e3792 100644 --- a/packages/core-subscriptions/db/subscriptions/helpers.js +++ b/packages/core-subscriptions/db/subscriptions/helpers.js @@ -31,7 +31,7 @@ Users.helpers({ sort: { created: -1, }, - } + }, ).fetch(); }, }); @@ -98,7 +98,7 @@ Subscriptions.helpers({ return ( await this.setStatus( SubscriptionStatus.TERMINATED, - 'terminated manually' + 'terminated manually', ).process({ subscriptionContext }) ).sendStatusToCustomer({ locale }); }, @@ -108,7 +108,7 @@ Subscriptions.helpers({ return ( await this.setStatus( SubscriptionStatus.ACTIVE, - 'activated manually' + 'activated manually', ).process({ subscriptionContext }) ).sendStatusToCustomer({ locale }); }, @@ -144,7 +144,7 @@ Subscriptions.helpers({ if (this.nextStatus() === SubscriptionStatus.ACTIVE) { await this.reactivateSubscription( subscriptionContext, - orderIdForFirstPeriod + orderIdForFirstPeriod, ); } return this.setStatus(this.nextStatus(), 'subscription processed'); @@ -213,7 +213,7 @@ Subscriptions.createSubscription = async ( delivery, orderIdForFirstPeriod, }, - options + options, ) => { log('Create Subscription', { userId }); const subscriptionId = Subscriptions.insert({ @@ -238,7 +238,7 @@ Subscriptions.createSubscription = async ( const subscription = Subscriptions.findOne({ _id: subscriptionId }); const locale = subscription.user().locale(options); const initialized = await subscription.initializeSubscription( - orderIdForFirstPeriod + orderIdForFirstPeriod, ); return initialized.sendStatusToCustomer({ locale }); }; @@ -263,7 +263,7 @@ Subscriptions.addSubscriptionPeriod = async ({ $set: { updated: new Date(), }, - } + }, ); return Subscriptions.findOne({ _id: subscriptionId }); }; @@ -277,7 +277,7 @@ Subscriptions.updateBillingAddress = ({ billingAddress, subscriptionId }) => { billingAddress, updated: new Date(), }, - } + }, ); return Subscriptions.findOne({ _id: subscriptionId }); }; @@ -291,7 +291,7 @@ Subscriptions.updateContact = ({ contact, subscriptionId }) => { contact, updated: new Date(), }, - } + }, ); return Subscriptions.findOne({ _id: subscriptionId }); }; @@ -305,7 +305,7 @@ Subscriptions.updatePayment = ({ payment, subscriptionId }) => { payment, updated: new Date(), }, - } + }, ); return Subscriptions.findOne({ _id: subscriptionId }); }; @@ -319,7 +319,7 @@ Subscriptions.updateDelivery = ({ delivery, subscriptionId }) => { delivery, updated: new Date(), }, - } + }, ); return Subscriptions.findOne({ _id: subscriptionId }); }; @@ -333,7 +333,7 @@ Subscriptions.updatePlan = ({ plan, subscriptionId }) => { plan, updated: new Date(), }, - } + }, ); return Subscriptions.findOne({ _id: subscriptionId }); }; @@ -347,7 +347,7 @@ Subscriptions.updateContext = ({ context, subscriptionId }) => { context, updated: new Date(), }, - } + }, ); return Subscriptions.findOne({ _id: subscriptionId }); }; @@ -357,7 +357,7 @@ Subscriptions.newSubscriptionNumber = () => { const hashids = new Hashids( 'unchained', 6, - 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890' + 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890', ); while (!subscriptionNumber) { const randomNumber = Math.floor(Math.random() * (999999999 - 1)) + 1; @@ -365,7 +365,7 @@ Subscriptions.newSubscriptionNumber = () => { if ( Subscriptions.find( { subscriptionNumber: newHashID }, - { limit: 1 } + { limit: 1 }, ).count() === 0 ) { subscriptionNumber = newHashID; diff --git a/packages/core-subscriptions/db/subscriptions/schema.js b/packages/core-subscriptions/db/subscriptions/schema.js index 1710d912d2..f6ce0ccb90 100644 --- a/packages/core-subscriptions/db/subscriptions/schema.js +++ b/packages/core-subscriptions/db/subscriptions/schema.js @@ -20,7 +20,7 @@ export const PeriodSchema = new SimpleSchema( }, { requiredByDefault: false, - } + }, ); export const Schema = new SimpleSchema( @@ -60,7 +60,7 @@ export const Schema = new SimpleSchema( ...contextFields, ...logFields, }, - { requiredByDefault: false } + { requiredByDefault: false }, ); Subscriptions.attachSchema(Schema); diff --git a/packages/core-subscriptions/director.js b/packages/core-subscriptions/director.js index c40cc14c3b..2fd1b23a93 100644 --- a/packages/core-subscriptions/director.js +++ b/packages/core-subscriptions/director.js @@ -11,10 +11,10 @@ const SubscriptionError = { const periodForReferenceDate = ( referenceDate, intervalCount = 1, - interval = 'WEEK' + interval = 'WEEK', ) => { const start = moment(referenceDate).startOf( - interval === 'HOUR' ? 'minute' : 'hour' + interval === 'HOUR' ? 'minute' : 'hour', ); return { start: start.toDate(), @@ -52,7 +52,7 @@ class SubscriptionAdapter { ...periodForReferenceDate( referenceDate, plan.trialIntervalCount, - plan.trialInterval + plan.trialInterval, ), isTrial: true, }; @@ -70,7 +70,7 @@ class SubscriptionAdapter { ...periodForReferenceDate( lastEnd, plan.billingIntervalCount, - plan.billingInterval + plan.billingInterval, ), isTrial: false, }; @@ -105,11 +105,11 @@ class SubscriptionDirector { resolveAdapter(context) { const { subscription } = this.context; const Adapter = this.constructor.findAppropriateAdapters( - subscription.product()?.plan + subscription.product()?.plan, )?.[0]; if (!Adapter) { throw new Error( - 'No suitable subscription plugin available for this plan configuration' + 'No suitable subscription plugin available for this plan configuration', ); } const adapter = new Adapter({ @@ -162,7 +162,7 @@ class SubscriptionDirector { `${this.constructor.name} -> ${AdapterClass.key} (${AdapterClass.version}) skipped`, { level: 'warn', - } + }, ); } return activated; @@ -174,11 +174,11 @@ class SubscriptionDirector { const AdapterClass = this.findAppropriateAdapters(product.plan)?.[0]; if (!AdapterClass) { throw new Error( - 'No suitable subscription plugin available for this item' + 'No suitable subscription plugin available for this item', ); } const transformedItem = await AdapterClass.transformOrderItemToSubscription( - item + item, ); return { ...subscriptionData, diff --git a/packages/core-subscriptions/worker/generate-orders.js b/packages/core-subscriptions/worker/generate-orders.js index 44a97ffc22..3f4945e079 100644 --- a/packages/core-subscriptions/worker/generate-orders.js +++ b/packages/core-subscriptions/worker/generate-orders.js @@ -46,7 +46,7 @@ class GenerateSubscriptionOrders extends WorkerPlugin { }; } return null; - }) + }), ) ).filter(Boolean); diff --git a/packages/core-users/db/helpers.js b/packages/core-users/db/helpers.js index 2e6cddfdf6..353a294b2c 100644 --- a/packages/core-users/db/helpers.js +++ b/packages/core-users/db/helpers.js @@ -30,7 +30,7 @@ Users.helpers({ isEmailVerified() { log( 'user.isEmailVerified is deprecated, please use user.primaryEmail.verified', - { level: 'warn' } + { level: 'warn' }, ); return !!this.primaryEmail()?.verified; }, @@ -56,7 +56,7 @@ Users.helpers({ return [...this.emails] .sort( ({ verified: verifiedLeft }, { verified: verifiedRight }) => - verifiedLeft - verifiedRight + verifiedLeft - verifiedRight, ) .pop(); }, @@ -86,7 +86,7 @@ Users.helpers({ 'services.password.initial': true, updated: new Date(), }, - } + }, ); } const user = Users.findOne({ _id: this._id }); @@ -101,7 +101,7 @@ Users.helpers({ updated: new Date(), roles, }, - } + }, ); return Users.findOne({ _id: this._id }); }, @@ -126,7 +126,7 @@ Users.helpers({ updateEmail(email, { verified = false, skipEmailVerification = false } = {}) { log( 'user.updateEmail is deprecated, please use user.addEmail and user.removeEmail', - { level: 'warn' } + { level: 'warn' }, ); Accounts.addEmail(this._id, email, verified); (this.emails || []) @@ -208,7 +208,7 @@ Users.enrollUser = ({ password, email, displayName, address }) => { 'profile.address': address || null, 'services.password.initial': true, }, - } + }, ); if (!options.password) { // send an e-mail if password is not set allowing the user to set it @@ -227,6 +227,6 @@ Users.updateHeartbeat = ({ userId, ...options }) => { ...options, }, }, - } + }, ); }; diff --git a/packages/core-users/db/schema.js b/packages/core-users/db/schema.js index 39dc32cc7a..ea4b70b866 100644 --- a/packages/core-users/db/schema.js +++ b/packages/core-users/db/schema.js @@ -18,7 +18,7 @@ export const ProfileSchema = new SimpleSchema( blackbox: true, }, }, - { requiredByDefault: false } + { requiredByDefault: false }, ); export const LastLoginSchema = new SimpleSchema( @@ -28,7 +28,7 @@ export const LastLoginSchema = new SimpleSchema( countryContext: String, remoteAddress: String, }, - { requiredByDefault: false } + { requiredByDefault: false }, ); export const LastContactSchema = new SimpleSchema( @@ -36,7 +36,7 @@ export const LastContactSchema = new SimpleSchema( telNumber: String, emailAddress: String, }, - { requiredByDefault: false } + { requiredByDefault: false }, ); export const UserSchema = new SimpleSchema( @@ -63,7 +63,7 @@ export const UserSchema = new SimpleSchema( 'roles.$': String, ...timestampFields, }, - { requiredByDefault: false } + { requiredByDefault: false }, ); Meteor.users.attachSchema(UserSchema); @@ -94,7 +94,7 @@ Migrations.add({ 'profile.firstName': 1, 'profile.lastName': 1, }, - } + }, ); }); }, @@ -119,7 +119,7 @@ Migrations.add({ guest: 1, 'profile.displayName': 1, }, - } + }, ); }); }, @@ -145,7 +145,7 @@ Migrations.add({ $unset: { 'lastLogin.country': 1, }, - } + }, ); } }); @@ -167,7 +167,7 @@ Migrations.add({ $unset: { 'lastLogin.countryContext': 1, }, - } + }, ); } }); diff --git a/packages/core-users/patch-accounts.js b/packages/core-users/patch-accounts.js index 71707cc5b2..cbbc2ba974 100644 --- a/packages/core-users/patch-accounts.js +++ b/packages/core-users/patch-accounts.js @@ -8,7 +8,7 @@ export default () => { userId, email, 'resetPassword', - extraTokenData + extraTokenData, ); WorkerDirector.addWork({ @@ -33,7 +33,7 @@ export default () => { userId, email, 'enrollAccount', - extraTokenData + extraTokenData, ); WorkerDirector.addWork({ type: 'MESSAGE', diff --git a/packages/core-warehousing/db/collections.js b/packages/core-warehousing/db/collections.js index 39ff7e9300..e52a4661b3 100644 --- a/packages/core-warehousing/db/collections.js +++ b/packages/core-warehousing/db/collections.js @@ -1,7 +1,7 @@ import { Mongo } from 'meteor/mongo'; export const WarehousingProviders = new Mongo.Collection( - 'warehousing-providers' + 'warehousing-providers', ); export default WarehousingProviders; diff --git a/packages/core-warehousing/db/helpers.js b/packages/core-warehousing/db/helpers.js index 58248b5b28..c331289d37 100644 --- a/packages/core-warehousing/db/helpers.js +++ b/packages/core-warehousing/db/helpers.js @@ -21,7 +21,7 @@ WarehousingProviders.helpers({ }, estimatedDispatch(context) { return Promise.await( - new WarehousingDirector(this).estimatedDispatch(context) + new WarehousingDirector(this).estimatedDispatch(context), ); }, estimatedStock(context) { @@ -48,7 +48,7 @@ WarehousingProviders.updateProvider = ({ _id, ...rest }) => { ...rest, updated: new Date(), }, - } + }, ); return WarehousingProviders.findOne({ _id, deleted: null }); }; @@ -60,7 +60,7 @@ WarehousingProviders.removeProvider = ({ _id }) => { $set: { deleted: new Date(), }, - } + }, ); return WarehousingProviders.findOne({ _id }); }; @@ -71,7 +71,7 @@ WarehousingProviders.findProviderById = (_id, ...options) => WarehousingProviders.findProviders = ({ type } = {}, ...options) => WarehousingProviders.find( { ...(type ? { type } : {}), deleted: null }, - ...options + ...options, ).fetch(); WarehousingProviders.findSupported = ( @@ -80,7 +80,7 @@ WarehousingProviders.findSupported = ( ) => WarehousingProviders.findProviders( {}, - ...options + ...options, ).filter((warehousingProvider) => - warehousingProvider.isActive({ product, deliveryProvider }) + warehousingProvider.isActive({ product, deliveryProvider }), ); diff --git a/packages/core-warehousing/db/schema.js b/packages/core-warehousing/db/schema.js index df88a5fa5d..c7bbff2a6d 100644 --- a/packages/core-warehousing/db/schema.js +++ b/packages/core-warehousing/db/schema.js @@ -17,6 +17,6 @@ WarehousingProviders.attachSchema( 'configuration.$.value': { type: String }, ...Schemas.timestampFields, }, - { requiredByDefault: false } - ) + { requiredByDefault: false }, + ), ); diff --git a/packages/core-warehousing/director.js b/packages/core-warehousing/director.js index 9ad1b1e93f..a9ee6e6b81 100644 --- a/packages/core-warehousing/director.js +++ b/packages/core-warehousing/director.js @@ -61,7 +61,7 @@ class WarehousingDirector { const Adapter = this.interfaceClass(); if (!Adapter) { throw new Error( - `Warehousing Plugin ${this.provider.adapterKey} not available` + `Warehousing Plugin ${this.provider.adapterKey} not available`, ); } return new Adapter(this.provider.configuration, context); @@ -103,7 +103,7 @@ class WarehousingDirector { const referenceDate = WarehousingDirector.getReferenceDate(context); const warehousingThroughputTime = await this.throughputTime(context); const deliveryThroughputTime = deliveryProvider.estimatedDeliveryThroughput( - { ...context, warehousingThroughputTime } + { ...context, warehousingThroughputTime }, ); const shippingTimestamp = referenceDate.getTime() + warehousingThroughputTime; diff --git a/packages/core-warehousing/plugins/google-sheets.js b/packages/core-warehousing/plugins/google-sheets.js index 46e9828633..2ea7e3ecab 100644 --- a/packages/core-warehousing/plugins/google-sheets.js +++ b/packages/core-warehousing/plugins/google-sheets.js @@ -114,7 +114,7 @@ class GoogleSheets extends WarehousingAdapter { const time = parseInt(resolvedRow[selector].value, 10) || 0; log( `GoogleSheet: Resolve Time ${selector} (${quantity}) for ${sku}: ${time}`, - { level: 'verbose' } + { level: 'verbose' }, ); return time; } @@ -151,7 +151,7 @@ class GoogleSheets extends WarehousingAdapter { const timeInHours = await this.getRemoteTime( sku.toUpperCase(), quantity, - selector + selector, ); if (!timeInHours) return null; return timeInHours * 60 * 60 * 1000; @@ -166,7 +166,7 @@ class GoogleSheets extends WarehousingAdapter { const timeInHours = await this.getRemoteTime( sku.toUpperCase(), quantity, - selector + selector, ); if (!timeInHours) return null; return timeInHours * 60 * 60 * 1000; diff --git a/packages/core-worker/db/schema.js b/packages/core-worker/db/schema.js index 32b133a7ea..ab9ba85fa6 100644 --- a/packages/core-worker/db/schema.js +++ b/packages/core-worker/db/schema.js @@ -33,8 +33,8 @@ WorkQueue.attachSchema( timeout: Number, ...Schemas.timestampFields, }, - { requiredByDefault: false } - ) + { requiredByDefault: false }, + ), ); Migrations.add({ @@ -48,7 +48,7 @@ Migrations.add({ original: 'originalWorkId', }, }, - { bypassCollection2: true, multi: true } + { bypassCollection2: true, multi: true }, ); }, down() { @@ -59,7 +59,7 @@ Migrations.add({ originalWorkId: 'original', }, }, - { bypassCollection2: true, multi: true } + { bypassCollection2: true, multi: true }, ); }, }); @@ -79,7 +79,7 @@ export default () => { { created: -1, }, - { expireAfterSeconds: 30 * ONE_DAY_IN_SECONDS } + { expireAfterSeconds: 30 * ONE_DAY_IN_SECONDS }, ); WorkQueue.rawCollection().createIndex({ started: -1 }); WorkQueue.rawCollection().createIndex({ finished: 1 }); diff --git a/packages/core-worker/director.js b/packages/core-worker/director.js index be2e79a3c4..17276b0a12 100644 --- a/packages/core-worker/director.js +++ b/packages/core-worker/director.js @@ -30,13 +30,13 @@ class WorkerDirector { static registerPlugin(plugin /* WorkerPlugin */) { if (this.plugins[plugin.type]) throw new Error( - `${this.name}: There is already a plugin registered with type: ${plugin.type}` + `${this.name}: There is already a plugin registered with type: ${plugin.type}`, ); this.plugins[plugin.type] = plugin; log( - `${this.name} -> Registered ${plugin.type} ${plugin.key}@${plugin.version} (${plugin.label})` + `${this.name} -> Registered ${plugin.type} ${plugin.key}@${plugin.version} (${plugin.label})`, ); } @@ -44,7 +44,7 @@ class WorkerDirector { const { cronText } = configuration; this.autoSchedule[plugin.type] = configuration; log( - `${this.name} -> Configured ${plugin.type} ${plugin.key}@${plugin.version} (${plugin.label}) for Autorun at ${cronText}` + `${this.name} -> Configured ${plugin.type} ${plugin.key}@${plugin.version} (${plugin.label}) for Autorun at ${cronText}`, ); } @@ -101,7 +101,7 @@ class WorkerDirector { }, { upsert: true, - } + }, ); if (!result.lastErrorObject.updatedExisting) { log(`${this.name} -> Work added ${type} ${scheduled} ${retries}`); @@ -162,7 +162,7 @@ class WorkerDirector { const statusQuery = { $or: Object.entries(filterMap).reduce( (acc, [key, filter]) => (status.includes(key) ? [...acc, filter] : acc), - [] + [], ), }; const query = statusQuery.$or.length > 0 ? statusQuery : {}; @@ -198,7 +198,7 @@ class WorkerDirector { { $set: { started: new Date(), worker }, }, - { new: true } + { new: true }, ); this.events.emit(WorkerEventTypes.allocated, { work: result.value }); @@ -257,7 +257,7 @@ class WorkerDirector { ...(!workBeforeUpdate.started ? { started } : {}), worker, }, - } + }, ); const work = await this.work({ workId }); @@ -282,7 +282,7 @@ class WorkerDirector { $set: { deleted: new Date(), }, - } + }, ); const work = await this.work({ workId }); @@ -329,7 +329,7 @@ class WorkerDirector { worker, }, }, - { multi: true } + { multi: true }, ); } } diff --git a/packages/core-worker/schedulers/failedRescheduler.js b/packages/core-worker/schedulers/failedRescheduler.js index 465aa7acaf..8411a1676f 100644 --- a/packages/core-worker/schedulers/failedRescheduler.js +++ b/packages/core-worker/schedulers/failedRescheduler.js @@ -28,8 +28,8 @@ class FailedRescheduler { `${this.constructor.key} -> Reschedule failed work ${work._id} ${ work.type } for ${scheduled} (in ${Math.round( - workDelayMs / 1000 - )}). Remaining retries: ${work.retries}` + workDelayMs / 1000, + )}). Remaining retries: ${work.retries}`, ); this.WorkerDirector.addWork({ @@ -46,14 +46,14 @@ class FailedRescheduler { start() { this.WorkerDirector.events.on( WorkerEventTypes.finished, - this.handleFinishedWork.bind(this) + this.handleFinishedWork.bind(this), ); } stop() { this.WorkerDirector.events.off( WorkerEventTypes.finished, - this.handleFinishedWork.bind(this) + this.handleFinishedWork.bind(this), ); } } diff --git a/packages/core-worker/workers/base.js b/packages/core-worker/workers/base.js index c137f84a1b..2efdb3fa6f 100644 --- a/packages/core-worker/workers/base.js +++ b/packages/core-worker/workers/base.js @@ -29,7 +29,7 @@ class BaseWorker { getInternalTypes() { return this.WorkerDirector.getActivePluginTypes().filter( - (type) => type !== External.type + (type) => type !== External.type, ); } @@ -65,8 +65,8 @@ class BaseWorker { ...rest, retries: 0, }); - } - ) + }, + ), ); } diff --git a/packages/core-worker/workers/interval.js b/packages/core-worker/workers/interval.js index 34273d2c87..417fc8de15 100644 --- a/packages/core-worker/workers/interval.js +++ b/packages/core-worker/workers/interval.js @@ -28,10 +28,10 @@ class IntervalWorker extends BaseWorker { this.process({ maxWorkItemCount: this.batchCount, referenceDate: new Date( - Math.floor(new Date().getTime() / 1000) * 1000 + Math.floor(new Date().getTime() / 1000) * 1000, ), }), - this.intervalDelay + this.intervalDelay, ); setTimeout(() => { this.autorescheduleTypes(); diff --git a/packages/core/find-localized-text.js b/packages/core/find-localized-text.js index 415ba64b29..fac5055d56 100644 --- a/packages/core/find-localized-text.js +++ b/packages/core/find-localized-text.js @@ -31,7 +31,7 @@ const findLocalizedText = (collection, selector, locale) => { if (cachedText) return cachedText; const exactTranslation = collection.findOne( - extendSelectorWithLocale(selector, locale) + extendSelectorWithLocale(selector, locale), ); if (exactTranslation) { textCache.set(cacheKey, exactTranslation); @@ -41,7 +41,7 @@ const findLocalizedText = (collection, selector, locale) => { const fallbackLocale = getFallbackLocale(); if (fallbackLocale.normalized !== locale.normalized) { const fallbackTranslation = collection.findOne( - extendSelectorWithLocale(selector, fallbackLocale) + extendSelectorWithLocale(selector, fallbackLocale), ); if (fallbackTranslation) { textCache.set(cacheKey, fallbackTranslation); diff --git a/packages/core/locale-context.js b/packages/core/locale-context.js index 70007c34d1..90c2cb6266 100644 --- a/packages/core/locale-context.js +++ b/packages/core/locale-context.js @@ -53,11 +53,11 @@ export const buildLocaleContext = (req) => { // else fallback to base language & base country const languages = Languages.find( { isActive: true }, - { fields: { isoCode: 1, isBase: 1, isActive: 1 } } + { fields: { isoCode: 1, isBase: 1, isActive: 1 } }, ).fetch(); const countries = Countries.find( { isActive: true }, - { fields: { isoCode: 1, isBase: 1, isActive: 1 } } + { fields: { isoCode: 1, isBase: 1, isActive: 1 } }, ).fetch(); const supportedLocaleStrings = languages.reduce((accumulator, language) => { @@ -71,20 +71,20 @@ export const buildLocaleContext = (req) => { const supportedLocales = new Locales( supportedLocaleStrings, - getFallbackLocale().code + getFallbackLocale().code, ); const localeContext = resolveBestSupported( req.headers['accept-language'], - supportedLocales + supportedLocales, ); const countryContext = resolveBestCountry( localeContext.country, req.headers['x-shop-country'], - countries + countries, ); log( `Locale Context: Resolved ${localeContext.normalized} ${countryContext}`, - { level: 'debug' } + { level: 'debug' }, ); const newContext = { localeContext, diff --git a/packages/platform/fixtures.js b/packages/platform/fixtures.js index 1d94a7490b..809e20c815 100644 --- a/packages/platform/fixtures.js +++ b/packages/platform/fixtures.js @@ -7,24 +7,24 @@ const logger = createLogger('unchained:platform'); const addTextAndMediaToProduct = (productId, slug) => { faker.locale = 'de'; logger.verbose( - `unchained:platform -> fixtures: -> productText ${faker.locale}` + `unchained:platform -> fixtures: -> productText ${faker.locale}`, ); Factory.create('productText', { productId, locale: 'de', slug }); faker.locale = 'en'; logger.verbose( - `unchained:platform -> fixtures: -> productText ${faker.locale}` + `unchained:platform -> fixtures: -> productText ${faker.locale}`, ); Factory.create('productText', { productId, locale: 'en', slug }); // Add some random images to the product Array.from(Array(2)).forEach((value, sortKey) => { logger.verbose( - `unchained:platform -> fixtures: -> productMedia ${sortKey}` + `unchained:platform -> fixtures: -> productMedia ${sortKey}`, ); const productMedia = Factory.create('productMedia', { productId, sortKey }); faker.locale = 'de'; logger.verbose( - `unchained:platform -> fixtures: -> productMediaText ${faker.locale}` + `unchained:platform -> fixtures: -> productMediaText ${faker.locale}`, ); Factory.create('productMediaText', { productMediaId: productMedia._id, @@ -32,7 +32,7 @@ const addTextAndMediaToProduct = (productId, slug) => { }); faker.locale = 'en'; logger.verbose( - `unchained:platform -> fixtures: -> productMediaText ${faker.locale}` + `unchained:platform -> fixtures: -> productMediaText ${faker.locale}`, ); Factory.create('productMediaText', { productMediaId: productMedia._id, @@ -44,12 +44,12 @@ const addTextAndMediaToProduct = (productId, slug) => { const addTextToAssortment = (assortmentId, slug) => { faker.locale = 'de'; logger.verbose( - `unchained:platform -> fixtures: -> assortmentTexts ${faker.locale}` + `unchained:platform -> fixtures: -> assortmentTexts ${faker.locale}`, ); Factory.create('assortmentText', { assortmentId, locale: 'de', slug }); faker.locale = 'en'; logger.verbose( - `unchained:platform -> fixtures: -> assortmentTexts ${faker.locale}` + `unchained:platform -> fixtures: -> assortmentTexts ${faker.locale}`, ); Factory.create('assortmentText', { assortmentId, locale: 'en', slug }); }; @@ -58,7 +58,7 @@ const addVariationsToProduct = (productId) => { const addTranslation = (productVariationId, productVariationOptionValue) => { faker.locale = 'de'; logger.verbose( - `unchained:platform -> fixtures: --> productVariationText ${faker.locale}` + `unchained:platform -> fixtures: --> productVariationText ${faker.locale}`, ); Factory.create('productVariationText', { productVariationId, @@ -67,7 +67,7 @@ const addVariationsToProduct = (productId) => { }); faker.locale = 'en'; logger.verbose( - `unchained:platform -> fixtures: --> productVariationText ${faker.locale}` + `unchained:platform -> fixtures: --> productVariationText ${faker.locale}`, ); Factory.create('productVariationText', { productVariationId, @@ -190,7 +190,7 @@ export default () => { const addTranslation = (filterId, filterOptionValue) => { faker.locale = 'de'; logger.verbose( - `unchained:platform -> fixtures: --> filterText ${faker.locale}` + `unchained:platform -> fixtures: --> filterText ${faker.locale}`, ); Factory.create('filterText', { filterId, @@ -199,7 +199,7 @@ export default () => { }); faker.locale = 'en'; logger.verbose( - `unchained:platform -> fixtures: --> filterText ${faker.locale}` + `unchained:platform -> fixtures: --> filterText ${faker.locale}`, ); Factory.create('filterText', { filterId, diff --git a/packages/platform/intercept-emails.js b/packages/platform/intercept-emails.js index 666c75ead7..0d53b5c7e5 100644 --- a/packages/platform/intercept-emails.js +++ b/packages/platform/intercept-emails.js @@ -20,7 +20,7 @@ function writeFile(filename, data, done) { mailman.warnNoEmailPackage = function warnNoEmailPackage() { logger.warn( - 'unchained:platform -> Unchained Mail Manager could not start because you are not using the email package' + 'unchained:platform -> Unchained Mail Manager could not start because you are not using the email package', ); logger.warn('unchained:platform -> Please run `meteor add email`'); }; @@ -56,7 +56,7 @@ export default () => { return; } logger.verbose( - 'unchained:platform -> Mailman detected an outgoing email' + 'unchained:platform -> Mailman detected an outgoing email', ); open(filePath); }); diff --git a/packages/platform/setup-accounts.js b/packages/platform/setup-accounts.js index f1cdfedcc7..6848a90cfb 100755 --- a/packages/platform/setup-accounts.js +++ b/packages/platform/setup-accounts.js @@ -120,7 +120,7 @@ export default ({ mergeUserCartsOnLogin = true } = {}) => { locale: normalizedLocale, countryContext, mergeCarts: mergeUserCartsOnLogin, - }) + }), ); Promise.await( @@ -128,7 +128,7 @@ export default ({ mergeUserCartsOnLogin = true } = {}) => { fromUserId: userIdBeforeLogin, toUserId: user._id, mergeBookmarks: mergeUserCartsOnLogin, - }) + }), ); } }); @@ -141,7 +141,7 @@ export default ({ mergeUserCartsOnLogin = true } = {}) => { $set: { guest: false, }, - } + }, ); } return true; diff --git a/packages/platform/setup-templates.js b/packages/platform/setup-templates.js index fbf05010ce..ee34ce4468 100644 --- a/packages/platform/setup-templates.js +++ b/packages/platform/setup-templates.js @@ -16,22 +16,22 @@ export const MessageTypes = { export default () => { MessagingDirector.configureTemplate( MessageTypes.ACCOUNT_ACTION, - accountActionTemplate + accountActionTemplate, ); MessagingDirector.configureTemplate( MessageTypes.DELIVERY, - forwardDeliveryTemplate + forwardDeliveryTemplate, ); MessagingDirector.configureTemplate( MessageTypes.ORDER_CONFIRMATION, - orderConfirmationTemplate + orderConfirmationTemplate, ); MessagingDirector.configureTemplate( MessageTypes.QUOTATION_STATUS, - quotationStatusTemplate + quotationStatusTemplate, ); MessagingDirector.configureTemplate( MessageTypes.SUBSCRIPTION_STATUS, - subscriptionStatusTemplate + subscriptionStatusTemplate, ); }; diff --git a/packages/platform/setup-workqueue.js b/packages/platform/setup-workqueue.js index be6dbd98b8..df7ac8f8b4 100755 --- a/packages/platform/setup-workqueue.js +++ b/packages/platform/setup-workqueue.js @@ -18,7 +18,7 @@ export default ({ cronText }) => { handlers.push( new EventListenerWorker({ WorkerDirector, - }) + }), ); // handlers.push( // new IntervalWorker({ @@ -30,7 +30,7 @@ export default ({ cronText }) => { new CronWorker({ WorkerDirector, cronText, - }) + }), ); } diff --git a/packages/platform/templates/account-action.js b/packages/platform/templates/account-action.js index b1a11f1315..b39ced7e74 100644 --- a/packages/platform/templates/account-action.js +++ b/packages/platform/templates/account-action.js @@ -132,7 +132,7 @@ export default ({ userId, action, recipientEmail, token }) => { text: MessagingDirector.renderToText(textTemplate, templateVariables), html: MessagingDirector.renderMjmlToHtml( mjmlTemplate, - templateVariables + templateVariables, ), }, }, diff --git a/packages/platform/templates/forward-delivery.js b/packages/platform/templates/forward-delivery.js index 9bc6d24999..b0bd413df7 100644 --- a/packages/platform/templates/forward-delivery.js +++ b/packages/platform/templates/forward-delivery.js @@ -135,7 +135,7 @@ export default ({ orderId, transactionContext, config }) => { text: MessagingDirector.renderToText(textTemplate, templateVariables), html: MessagingDirector.renderMjmlToHtml( mjmlTemplate, - templateVariables + templateVariables, ), attachments: attachments.map((file) => ({ filename: `${order.orderNumber}_${file.name}`, diff --git a/packages/platform/templates/order-confirmation.js b/packages/platform/templates/order-confirmation.js index d43c04024a..e12f0727d7 100644 --- a/packages/platform/templates/order-confirmation.js +++ b/packages/platform/templates/order-confirmation.js @@ -114,7 +114,7 @@ export default ({ orderId, locale }) => { text: MessagingDirector.renderToText(textTemplate, templateVariables), html: MessagingDirector.renderMjmlToHtml( mjmlTemplate, - templateVariables + templateVariables, ), attachments: attachments.map((file) => ({ filename: `${order.orderNumber}_${file.name}`, diff --git a/packages/utils/address-schema.js b/packages/utils/address-schema.js index d1073408cb..03cc08359f 100644 --- a/packages/utils/address-schema.js +++ b/packages/utils/address-schema.js @@ -12,5 +12,5 @@ export default new SimpleSchema( regionCode: String, countryCode: String, }, - { requiredByDefault: false } + { requiredByDefault: false }, ); diff --git a/packages/utils/contact-schema.js b/packages/utils/contact-schema.js index 920bdecaf3..cb9dcdd19a 100644 --- a/packages/utils/contact-schema.js +++ b/packages/utils/contact-schema.js @@ -5,5 +5,5 @@ export default new SimpleSchema( telNumber: String, emailAddress: String, }, - { requiredByDefault: false } + { requiredByDefault: false }, ); diff --git a/packages/utils/find-preserving-ids.js b/packages/utils/find-preserving-ids.js index 813542b11c..bf0bee55cf 100644 --- a/packages/utils/find-preserving-ids.js +++ b/packages/utils/find-preserving-ids.js @@ -29,7 +29,7 @@ export default (Collection) => async (selector, ids, options = {}) => { const rawCollection = Collection.rawCollection(); const aggregateCollection = Meteor.wrapAsync( rawCollection.aggregate, - rawCollection + rawCollection, ); const aggregationPointer = aggregateCollection(filteredPipeline); const items = await aggregationPointer.toArray(); diff --git a/tests/auth-admin.test.js b/tests/auth-admin.test.js index a024c12878..3660a16620 100644 --- a/tests/auth-admin.test.js +++ b/tests/auth-admin.test.js @@ -99,7 +99,7 @@ describe('Auth for admin users', () => { describe('Mutation.updateUserAvatar', () => { it('update the avatar of a foreign user', async () => { const imageResult = await fetch( - 'https://assets-cdn.github.com/images/modules/logos_page/Octocat.png' + 'https://assets-cdn.github.com/images/modules/logos_page/Octocat.png', ); const imageBuffer = await imageResult.buffer(); const avatar = { diff --git a/tests/filter-option.test.js b/tests/filter-option.test.js index b1b8343baa..3e83667971 100644 --- a/tests/filter-option.test.js +++ b/tests/filter-option.test.js @@ -62,7 +62,7 @@ describe('FilterOption', () => { }); expect( - createFilterOption.options[createFilterOption.options.length - 1]._id + createFilterOption.options[createFilterOption.options.length - 1]._id, ).toEqual('multichoice-filter:test-filter-option'); }); diff --git a/tests/helpers.js b/tests/helpers.js index 86a8eb6e98..7e317e8d35 100644 --- a/tests/helpers.js +++ b/tests/helpers.js @@ -66,7 +66,7 @@ const convertLinkToFetch = (link) => ({ query, ...operation }) => execute(link, { query: gql(query), ...operation, - }) + }), ); export const createAnonymousGraphqlFetch = () => { diff --git a/tests/order-deliveries.test.js b/tests/order-deliveries.test.js index 01f4a5bf10..fa51f4fe03 100644 --- a/tests/order-deliveries.test.js +++ b/tests/order-deliveries.test.js @@ -95,7 +95,7 @@ describe('Order: Deliveries', () => { john: 'wayne', }, }, - } + }, ); expect(updateOrderDeliveryShipping).toMatchObject({ _id: SimpleDelivery._id, diff --git a/tests/product-variation.test.js b/tests/product-variation.test.js index ce29da4f9a..59744ee564 100644 --- a/tests/product-variation.test.js +++ b/tests/product-variation.test.js @@ -329,7 +329,7 @@ describe('ProductsVariation', () => { }, ], }, - } + }, ); expect(updateProductVariationTexts[0]._id).not.toBe(null); diff --git a/tests/public-queries.test.js b/tests/public-queries.test.js index f6f26bf85e..1ab44d15fc 100644 --- a/tests/public-queries.test.js +++ b/tests/public-queries.test.js @@ -84,10 +84,10 @@ describe('public queries', () => { expect(errors).toEqual(undefined); const de = data.translatedProductTexts.find( - (texts) => texts.locale === 'de' + (texts) => texts.locale === 'de', ); const fr = data.translatedProductTexts.find( - (texts) => texts.locale === 'fr' + (texts) => texts.locale === 'fr', ); expect(de.slug).toBe('slug-de'); expect(fr.slug).toBe('slug-fr'); @@ -107,10 +107,10 @@ describe('public queries', () => { expect(errors).toEqual(undefined); const de = data.translatedProductMediaTexts.find( - (texts) => texts.locale === 'de' + (texts) => texts.locale === 'de', ); const fr = data.translatedProductMediaTexts.find( - (texts) => texts.locale === 'fr' + (texts) => texts.locale === 'fr', ); expect(de.title).toBe('product-media-title-de'); expect(fr.title).toBe('product-media-title-fr'); diff --git a/tests/setup-basic.test.js b/tests/setup-basic.test.js index e79bd66805..b2624b042f 100644 --- a/tests/setup-basic.test.js +++ b/tests/setup-basic.test.js @@ -93,7 +93,7 @@ describe('basic setup of internationalization and localization context', () => { }); it.todo( - 'Currencies should have delete flags, as orders can depend on them' + 'Currencies should have delete flags, as orders can depend on them', ); it('query active currencies', async () => { diff --git a/tests/worker.test.js b/tests/worker.test.js index d689951a07..7bd2a1db25 100644 --- a/tests/worker.test.js +++ b/tests/worker.test.js @@ -50,11 +50,11 @@ describe('Worker Module', () => { }); expect(workQueue.filter(({ type }) => type === 'HEARTBEAT')).toHaveLength( - 1 + 1, ); const work = workQueue.find( - (w) => w._id === addWorkResult.data.addWork._id + (w) => w._id === addWorkResult.data.addWork._id, ); expect(work.status).toBe('SUCCESS'); @@ -92,7 +92,7 @@ describe('Worker Module', () => { }); expect(workQueue.filter(({ type }) => type === 'EXTERNAL')).toHaveLength( - 1 + 1, ); }); @@ -125,13 +125,13 @@ describe('Worker Module', () => { (r) => r.data.allocateWork && r.data.allocateWork.type === 'EXTERNAL' && - r.data.allocateWork._id - ) + r.data.allocateWork._id, + ), ).toHaveLength(1); // Hoist workId for later use workId = results.find( - (r) => r.data.allocateWork && r.data.allocateWork._id + (r) => r.data.allocateWork && r.data.allocateWork._id, ).data.allocateWork._id; }); @@ -148,7 +148,7 @@ describe('Worker Module', () => { }); expect(workQueue.filter(({ type }) => type === 'HEARTBEAT')).toHaveLength( - 0 + 0, ); }); @@ -292,7 +292,7 @@ describe('Worker Module', () => { }); expect( - workQueueBefore.filter(({ type }) => type === 'HEARTBEAT') + workQueueBefore.filter(({ type }) => type === 'HEARTBEAT'), ).toHaveLength(1); // Test if work is not done immediately @@ -312,7 +312,7 @@ describe('Worker Module', () => { }); expect( - workQueueMiddle.filter(({ type }) => type === 'HEARTBEAT') + workQueueMiddle.filter(({ type }) => type === 'HEARTBEAT'), ).toHaveLength(1); // Test if work is done eventually @@ -332,7 +332,7 @@ describe('Worker Module', () => { }); expect( - workQueueAfter.filter(({ type }) => type === 'HEARTBEAT') + workQueueAfter.filter(({ type }) => type === 'HEARTBEAT'), ).toHaveLength(0); }); @@ -382,7 +382,7 @@ describe('Worker Module', () => { }); expect( - workQueueBefore.filter(({ type }) => type === 'HEARTBEAT') + workQueueBefore.filter(({ type }) => type === 'HEARTBEAT'), ).toHaveLength(1); const workBefore = workQueueBefore.pop(); @@ -408,7 +408,7 @@ describe('Worker Module', () => { }); expect( - workQueueAfter.filter(({ type }) => type === 'HEARTBEAT') + workQueueAfter.filter(({ type }) => type === 'HEARTBEAT'), ).toHaveLength(1); }); From 454e532f583e92d514c9a2aa14258fa29f83e19c Mon Sep 17 00:00:00 2001 From: Pascal Kaufmann Date: Wed, 10 Jun 2020 13:01:36 +0200 Subject: [PATCH 3/4] Stripe now auto-confirms when using a stored credential --- packages/core-payment/plugins/stripe.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/packages/core-payment/plugins/stripe.js b/packages/core-payment/plugins/stripe.js index ba56adea6b..dc59e47aca 100644 --- a/packages/core-payment/plugins/stripe.js +++ b/packages/core-payment/plugins/stripe.js @@ -17,11 +17,8 @@ const { STRIPE_WEBHOOK_PATH = '/graphql/stripe', } = process.env; -const logger = createLogger('unchained:core-payment:stripe-webhook'); - -const stripe = require('stripe')(STRIPE_SECRET); - /* +Test Webhooks: brew install stripe/stripe-cli/stripe stripe login --api-key sk_.... @@ -29,6 +26,10 @@ stripe listen --forward-to http://localhost:3000/graphql/stripe stripe trigger payment_intent.succeeded */ +const logger = createLogger('unchained:core-payment:stripe-webhook'); + +const stripe = require('stripe')(STRIPE_SECRET); + WebApp.connectHandlers.use( STRIPE_WEBHOOK_PATH, bodyParser.raw({ type: 'application/json' }), @@ -212,7 +213,14 @@ class Stripe extends PaymentAdapter { const orderPayment = order.payment(); const paymentIntentObject = paymentIntentId ? await stripe.paymentIntents.retrieve(paymentIntentId) - : await this.constructor.createOrderPaymentIntent(orderPayment); + : await this.constructor.createOrderPaymentIntent(orderPayment, { + customer: paymentCredentials.meta?.customer, + confirm: true, + payment_method: paymentCredentials.token, + payment_method_types: paymentCredentials.meta?.payment_method_types, // eslint-disable-line + payment_method_options: + paymentCredentials.meta?.payment_method_options, // eslint-disable-line + }); if (paymentIntentObject.metadata?.orderPaymentId !== orderPayment?._id) { throw new Error( @@ -220,7 +228,6 @@ class Stripe extends PaymentAdapter { ); } - console.log(paymentIntentObject); if (paymentIntentObject.status === 'succeeded') { return paymentIntentObject; } From 7d1eee094ddc5fc47b380618e249618a2e83e103 Mon Sep 17 00:00:00 2001 From: Pascal Kaufmann Date: Wed, 10 Jun 2020 13:40:42 +0200 Subject: [PATCH 4/4] Add encrypted env for CI tests of stripe plugin --- .gitignore | 1 + codeship-services.yml | 2 ++ env.encrypted | 2 ++ 3 files changed, 5 insertions(+) create mode 100644 env.encrypted diff --git a/.gitignore b/.gitignore index aa54eb330b..6170413507 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ node_modules dockercfg codeship.aes .npm +/env diff --git a/codeship-services.yml b/codeship-services.yml index ec2bad4eb7..eec095a722 100644 --- a/codeship-services.yml +++ b/codeship-services.yml @@ -3,6 +3,8 @@ ci: context: . dockerfile: Dockerfile cached: true + encrypted_env_file: + - env.encrypted controlpanel: build: diff --git a/env.encrypted b/env.encrypted new file mode 100644 index 0000000000..b1287f1d1b --- /dev/null +++ b/env.encrypted @@ -0,0 +1,2 @@ +codeship:v2 +537wXcLX5UyHqPT6evSeSGFoIavxbj05FGGKnWZmUw0hTrb8glcO+MZLYBYPx/w2rZcIjiq3L3glS4nSujLksvPMKX7dt5uD3F7vyA8ZNRw1Te5NioQZP4zv6njkaaZBca0rw/kt8ezTwej2d0BEfTq8YIWWxdKlsxeXx0VqO/sGBfClQekOLyMQmtFOjo2JKeKtVuU3ECQwEm6jQknyUOqZWneq+OgZCzOfdTBF+cyui0TdNFcV6laFb0zgXZp2xKPYuUPdBOdnvm0dT/JJjbB8Ye6yAfxYamyn6t1Yr8SELWp1l08syObjLqgGzAcCgWhWjLEuJqHWFS0VNFLWU1mDfPqu0nV2iVdiadBV/shEWWLuZfHyca/hzY60dTayGPMZZ7wzHi7d5v+LSHXkUlJsH1C2vL8YME4mCLqAbmhCLrFkcVTLXqhBMkkFPmaUfcrHqOTubpVvPfq7enMtQfI7PnZFonqpmUTa0N/5/jBL0z8vvvB9QPa2BL43SDsT0fzdok4qx6Vk/13NZoOE5OFk2qMkEld99dTkFLEcV1DJCEmOzJY1PRtOi98DrGUGoQxVnj7ui/6UYZDrs6a3 \ No newline at end of file