diff --git a/libs/google/project.json b/libs/google/project.json index 465778aae6c..d70a4b0158a 100644 --- a/libs/google/project.json +++ b/libs/google/project.json @@ -6,16 +6,20 @@ "tags": [], "targets": { "build": { - "executor": "@nx/esbuild:esbuild", + "dependsOn": ["build-ts"], + "executor": "nx:run-commands", + "options": { + "command": "echo Build complete" + } + }, + "build-ts": { + "executor": "@nx/js:tsc", "outputs": ["{options.outputPath}"], - "defaultConfiguration": "production", "options": { "main": "libs/google/src/index.ts", "outputPath": "dist/libs/google", - "outputFileName": "main.js", "tsConfig": "libs/google/tsconfig.lib.json", - "assets": ["libs/google/*.md"], - "declaration": true + "assets": ["libs/google/*.md"] } }, "lint": { diff --git a/libs/payments/auth/project.json b/libs/payments/auth/project.json index 25c46831fd1..72180c0d5de 100644 --- a/libs/payments/auth/project.json +++ b/libs/payments/auth/project.json @@ -6,14 +6,26 @@ "tags": [], "targets": { "build": { - "executor": "@nx/esbuild:esbuild", + "dependsOn": ["build-ts"], + "executor": "nx:run-commands", + "options": { + "command": "echo Build complete" + } + }, + "build-ts": { + "executor": "@nx/js:tsc", "outputs": ["{options.outputPath}"], "options": { - "outputPath": "dist/libs/payments/auth", "main": "libs/payments/auth/src/index.ts", + "outputPath": "dist/libs/payments/auth", "tsConfig": "libs/payments/auth/tsconfig.lib.json", - "assets": ["libs/payments/auth/*.md"], - "format": ["cjs"] + "assets": [ + { + "glob": "libs/payments/auth/*.md", + "input": ".", + "output": "." + } + ] } }, "test-unit": { diff --git a/libs/payments/capability/project.json b/libs/payments/capability/project.json index 14f212c9947..b39354d0c0c 100644 --- a/libs/payments/capability/project.json +++ b/libs/payments/capability/project.json @@ -6,31 +6,26 @@ "tags": ["scope:shared:lib:payments"], "targets": { "build": { - "executor": "@nx/esbuild:esbuild", + "dependsOn": ["build-ts"], + "executor": "nx:run-commands", + "options": { + "command": "echo Build complete" + } + }, + "build-ts": { + "executor": "@nx/js:tsc", "outputs": ["{options.outputPath}"], - "defaultConfiguration": "production", "options": { "main": "libs/payments/capability/src/index.ts", "outputPath": "dist/libs/payments/capability", - "outputFileName": "main.js", "tsConfig": "libs/payments/capability/tsconfig.lib.json", - "declaration": true, "assets": [ { "glob": "libs/payments/capability/README.md", "input": ".", "output": "." } - ], - "platform": "node" - }, - "configurations": { - "development": { - "minify": false - }, - "production": { - "minify": true - } + ] } }, "lint": { diff --git a/libs/payments/cart/project.json b/libs/payments/cart/project.json index a98a594cb56..bc040ed82fa 100644 --- a/libs/payments/cart/project.json +++ b/libs/payments/cart/project.json @@ -6,13 +6,18 @@ "tags": ["scope:shared:lib:payments"], "targets": { "build": { - "executor": "@nx/esbuild:esbuild", + "dependsOn": ["build-ts"], + "executor": "nx:run-commands", + "options": { + "command": "echo Build complete" + } + }, + "build-ts": { + "executor": "@nx/js:tsc", "outputs": ["{options.outputPath}"], - "defaultConfiguration": "production", "options": { "main": "libs/payments/cart/src/index.ts", "outputPath": "dist/libs/payments/cart", - "outputFileName": "main.js", "tsConfig": "libs/payments/cart/tsconfig.lib.json", "assets": [ { @@ -20,16 +25,7 @@ "input": ".", "output": "." } - ], - "platform": "node" - }, - "configurations": { - "development": { - "minify": false - }, - "production": { - "minify": true - } + ] } }, "lint": { diff --git a/libs/payments/cart/src/lib/cart.service.spec.ts b/libs/payments/cart/src/lib/cart.service.spec.ts index 7cc735d4c86..d6edcd31774 100644 --- a/libs/payments/cart/src/lib/cart.service.spec.ts +++ b/libs/payments/cart/src/lib/cart.service.spec.ts @@ -137,7 +137,7 @@ import { MockPaymentsGleanFactory, PaymentsGleanManager, PaymentsGleanService, -} from '@fxa/payments/metrics'; +} from '@fxa/payments/metrics'; // Circular! import { MockNimbusManagerConfigProvider, NimbusManager, diff --git a/libs/payments/cart/src/lib/cart.service.ts b/libs/payments/cart/src/lib/cart.service.ts index 00d2937e21d..dca17498beb 100644 --- a/libs/payments/cart/src/lib/cart.service.ts +++ b/libs/payments/cart/src/lib/cart.service.ts @@ -113,7 +113,7 @@ import { isPaymentIntentId } from './util/isPaymentIntentId'; import { isPaymentIntent } from './util/isPaymentIntent'; import { throwIntentFailedError } from './util/throwIntentFailedError'; import type { SubscriptionAttributionParams } from './checkout.types'; -import { handleException } from 'libs/shared/error/src/lib/sanitizeExceptionsDecorator'; +import { handleException } from '@fxa/shared/error'; import type { AsyncLocalStorage } from 'async_hooks'; import { AsyncLocalStorageCart } from './cart-als.provider'; import type { CartStore } from './cart-als.types'; @@ -843,17 +843,16 @@ export class CartService { effectiveUid && oldCart.eligibilityStatus === CartEligibilityStatus.CREATE ) { - const freeTrial = - await this.checkoutService.getFreeTrialEligibility({ - uid: effectiveUid, - offeringConfigId: oldCart.offeringConfigId, - countryCode: - cartDetailsInput.taxAddress?.countryCode ?? - oldCart.taxAddress?.countryCode ?? - '', - interval: oldCart.interval as SubplatInterval, - eligibilityStatus: EligibilityStatus.CREATE, - }); + const freeTrial = await this.checkoutService.getFreeTrialEligibility({ + uid: effectiveUid, + offeringConfigId: oldCart.offeringConfigId, + countryCode: + cartDetailsInput.taxAddress?.countryCode ?? + oldCart.taxAddress?.countryCode ?? + '', + interval: oldCart.interval as SubplatInterval, + eligibilityStatus: EligibilityStatus.CREATE, + }); cartDetails.isFreeTrial = !!freeTrial; } else { cartDetails.isFreeTrial = false; diff --git a/libs/payments/content-server/project.json b/libs/payments/content-server/project.json index f464da66072..901f750c787 100644 --- a/libs/payments/content-server/project.json +++ b/libs/payments/content-server/project.json @@ -6,13 +6,18 @@ "tags": ["scope:shared:lib:payments"], "targets": { "build": { - "executor": "@nx/esbuild:esbuild", + "dependsOn": ["build-ts"], + "executor": "nx:run-commands", + "options": { + "command": "echo Build complete" + } + }, + "build-ts": { + "executor": "@nx/js:tsc", "outputs": ["{options.outputPath}"], - "defaultConfiguration": "production", "options": { "main": "libs/payments/content-server/src/index.ts", "outputPath": "dist/libs/payments/content-server", - "outputFileName": "main.js", "tsConfig": "libs/payments/content-server/tsconfig.lib.json", "assets": [ { @@ -20,16 +25,7 @@ "input": ".", "output": "." } - ], - "platform": "node" - }, - "configurations": { - "development": { - "minify": false - }, - "production": { - "minify": true - } + ] } }, "lint": { diff --git a/libs/payments/currency/project.json b/libs/payments/currency/project.json index 36bde406d00..ea68cd8070e 100644 --- a/libs/payments/currency/project.json +++ b/libs/payments/currency/project.json @@ -6,31 +6,26 @@ "tags": ["scope:shared:lib:payments"], "targets": { "build": { - "executor": "@nx/esbuild:esbuild", + "dependsOn": ["build-ts"], + "executor": "nx:run-commands", + "options": { + "command": "echo Build complete" + } + }, + "build-ts": { + "executor": "@nx/js:tsc", "outputs": ["{options.outputPath}"], - "defaultConfiguration": "production", "options": { "main": "libs/payments/currency/src/index.ts", "outputPath": "dist/libs/payments/currency", - "outputFileName": "main.js", "tsConfig": "libs/payments/currency/tsconfig.lib.json", - "declaration": true, "assets": [ { "glob": "libs/payments/currency/README.md", "input": ".", "output": "." } - ], - "platform": "node" - }, - "configurations": { - "development": { - "minify": false - }, - "production": { - "minify": true - } + ] } }, "lint": { diff --git a/libs/payments/customer/package.json b/libs/payments/customer/package.json index 919acd56fb0..66b0c09805f 100644 --- a/libs/payments/customer/package.json +++ b/libs/payments/customer/package.json @@ -1,4 +1,4 @@ { - "name": "payments/customer", + "name": "@fxa/payments/customer", "version": "0.0.0" } diff --git a/libs/payments/customer/project.json b/libs/payments/customer/project.json index dac3a734533..94915423a23 100644 --- a/libs/payments/customer/project.json +++ b/libs/payments/customer/project.json @@ -6,31 +6,26 @@ "tags": ["scope:shared:lib:payments"], "targets": { "build": { - "executor": "@nx/esbuild:esbuild", + "dependsOn": ["build-ts"], + "executor": "nx:run-commands", + "options": { + "command": "echo Build complete" + } + }, + "build-ts": { + "executor": "@nx/js:tsc", "outputs": ["{options.outputPath}"], - "defaultConfiguration": "production", "options": { "main": "libs/payments/customer/src/index.ts", "outputPath": "dist/libs/payments/customer", - "outputFileName": "main.js", "tsConfig": "libs/payments/customer/tsconfig.lib.json", - "declaration": true, "assets": [ { "glob": "libs/payments/customer/README.md", "input": ".", "output": "." } - ], - "platform": "node" - }, - "configurations": { - "development": { - "minify": false - }, - "production": { - "minify": true - } + ] } }, "lint": { diff --git a/libs/payments/customer/src/index.ts b/libs/payments/customer/src/index.ts index f12e43f37aa..cb67e24dc4e 100644 --- a/libs/payments/customer/src/index.ts +++ b/libs/payments/customer/src/index.ts @@ -26,3 +26,4 @@ export * from './lib/util/getSubplatInterval'; export * from './lib/util/getSubplatIntervalFromSubscription'; export * from './lib/util/hasOpenInvoiceWithPaymentAttempts'; export * from './lib/util/retrieveSubscriptionItem'; +export * from './lib/util/getPriceFromSubscription'; diff --git a/libs/payments/customer/src/lib/util/getPaymentMethodErrorContent.ts b/libs/payments/customer/src/lib/util/getPaymentMethodErrorContent.ts index e8ee94a7e93..96efd38c253 100644 --- a/libs/payments/customer/src/lib/util/getPaymentMethodErrorContent.ts +++ b/libs/payments/customer/src/lib/util/getPaymentMethodErrorContent.ts @@ -6,7 +6,7 @@ import { BannerVariant, PaymentMethodErrorType, SubPlatPaymentMethodType, -} from '@fxa/payments/customer'; +} from '../..'; export function getPaymentMethodErrorContent( error: PaymentMethodErrorType, diff --git a/libs/payments/eligibility/project.json b/libs/payments/eligibility/project.json index c068dfcac5c..c868e7bfaa7 100644 --- a/libs/payments/eligibility/project.json +++ b/libs/payments/eligibility/project.json @@ -6,31 +6,26 @@ "tags": ["scope:shared:lib:payments"], "targets": { "build": { - "executor": "@nx/esbuild:esbuild", + "dependsOn": ["build-ts"], + "executor": "nx:run-commands", + "options": { + "command": "echo Build complete" + } + }, + "build-ts": { + "executor": "@nx/js:tsc", "outputs": ["{options.outputPath}"], - "defaultConfiguration": "production", "options": { "main": "libs/payments/eligibility/src/index.ts", "outputPath": "dist/libs/payments/eligibility", - "outputFileName": "main.js", "tsConfig": "libs/payments/eligibility/tsconfig.lib.json", - "declaration": true, "assets": [ { "glob": "libs/payments/eligibility/README.md", "input": ".", "output": "." } - ], - "platform": "node" - }, - "configurations": { - "development": { - "minify": false - }, - "production": { - "minify": true - } + ] } }, "lint": { diff --git a/libs/payments/events/package.json b/libs/payments/events/package.json index 4985c13d894..eecbc3279af 100644 --- a/libs/payments/events/package.json +++ b/libs/payments/events/package.json @@ -1,8 +1,4 @@ { "name": "@fxa/payments/events", - "version": "0.0.1", - "dependencies": {}, - "type": "commonjs", - "main": "./index.cjs", - "private": true + "version": "0.0.1" } diff --git a/libs/payments/events/project.json b/libs/payments/events/project.json index 5313e75450c..51b11a05b03 100644 --- a/libs/payments/events/project.json +++ b/libs/payments/events/project.json @@ -6,14 +6,21 @@ "tags": [], "targets": { "build": { - "executor": "@nx/esbuild:esbuild", + "dependsOn": ["build-ts"], + "executor": "nx:run-commands", + "options": { + "command": "echo Build complete" + } + }, + "build-ts": { + "executor": "@nx/js:tsc", "outputs": ["{options.outputPath}"], "options": { "outputPath": "dist/libs/payments/events", "main": "libs/payments/events/src/index.ts", "tsConfig": "libs/payments/events/tsconfig.lib.json", "assets": ["libs/payments/events/*.md"], - "declaration": true + "generatePackageJson": true } }, "test-unit": { diff --git a/libs/payments/experiments/package.json b/libs/payments/experiments/package.json index 5b05d511707..a3286e78257 100644 --- a/libs/payments/experiments/package.json +++ b/libs/payments/experiments/package.json @@ -1,9 +1,4 @@ { "name": "@fxa/payments/experiments", - "version": "0.0.1", - "private": true, - "type": "commonjs", - "main": "./index.cjs", - "types": "./index.d.ts", - "dependencies": {} + "version": "0.0.1" } diff --git a/libs/payments/experiments/project.json b/libs/payments/experiments/project.json index 0a2010b22c0..227bbc4a1b4 100644 --- a/libs/payments/experiments/project.json +++ b/libs/payments/experiments/project.json @@ -6,14 +6,21 @@ "tags": [], "targets": { "build": { - "executor": "@nx/esbuild:esbuild", + "dependsOn": ["build-ts"], + "executor": "nx:run-commands", + "options": { + "command": "echo Build complete" + } + }, + "build-ts": { + "executor": "@nx/js:tsc", "outputs": ["{options.outputPath}"], "options": { "outputPath": "dist/libs/payments/experiments", "main": "libs/payments/experiments/src/index.ts", "tsConfig": "libs/payments/experiments/tsconfig.lib.json", "assets": ["libs/payments/experiments/*.md"], - "declaration": true + "generatePackageJson": true } }, "test-unit": { diff --git a/libs/payments/iap/project.json b/libs/payments/iap/project.json index 9efc9aaaca0..f7a1ef20660 100644 --- a/libs/payments/iap/project.json +++ b/libs/payments/iap/project.json @@ -12,31 +12,26 @@ } }, "build": { - "executor": "@nx/esbuild:esbuild", + "dependsOn": ["build-ts"], + "executor": "nx:run-commands", + "options": { + "command": "echo Build complete" + } + }, + "build-ts": { + "executor": "@nx/js:tsc", "outputs": ["{options.outputPath}"], - "defaultConfiguration": "production", "options": { "main": "libs/payments/iap/src/index.ts", "outputPath": "dist/libs/payments/iap", - "outputFileName": "main.js", "tsConfig": "libs/payments/iap/tsconfig.lib.json", - "declaration": true, "assets": [ { "glob": "libs/payments/iap/README.md", "input": ".", "output": "." } - ], - "platform": "node" - }, - "configurations": { - "development": { - "minify": false - }, - "production": { - "minify": true - } + ] } }, "lint": { diff --git a/libs/payments/legacy/project.json b/libs/payments/legacy/project.json index 66f0b73fdbb..dd13fa9d19b 100644 --- a/libs/payments/legacy/project.json +++ b/libs/payments/legacy/project.json @@ -6,31 +6,26 @@ "tags": [], "targets": { "build": { - "executor": "@nx/esbuild:esbuild", + "dependsOn": ["build-ts"], + "executor": "nx:run-commands", + "options": { + "command": "echo Build complete" + } + }, + "build-ts": { + "executor": "@nx/js:tsc", "outputs": ["{options.outputPath}"], - "defaultConfiguration": "production", "options": { "main": "libs/payments/legacy/src/index.ts", "outputPath": "dist/libs/payments/legacy", - "outputFileName": "main.js", "tsConfig": "libs/payments/legacy/tsconfig.lib.json", - "declaration": true, "assets": [ { "glob": "libs/payments/legacy/README.md", "input": ".", "output": "." } - ], - "platform": "node" - }, - "configurations": { - "development": { - "minify": false - }, - "production": { - "minify": true - } + ] } }, "lint": { diff --git a/libs/payments/management/project.json b/libs/payments/management/project.json index 227c3b70203..7d3b554ca6e 100644 --- a/libs/payments/management/project.json +++ b/libs/payments/management/project.json @@ -6,13 +6,18 @@ "tags": ["scope:shared:lib:payments"], "targets": { "build": { - "executor": "@nx/esbuild:esbuild", + "dependsOn": ["build-ts"], + "executor": "nx:run-commands", + "options": { + "command": "echo Build complete" + } + }, + "build-ts": { + "executor": "@nx/js:tsc", "outputs": ["{options.outputPath}"], - "defaultConfiguration": "production", "options": { "main": "libs/payments/management/src/index.ts", "outputPath": "dist/libs/payments/management", - "outputFileName": "main.js", "tsConfig": "libs/payments/management/tsconfig.lib.json", "assets": [ { @@ -20,17 +25,7 @@ "input": ".", "output": "." } - ], - "platform": "node", - "declaration" : true - }, - "configurations": { - "development": { - "minify": false - }, - "production": { - "minify": true - } + ] } }, "lint": { diff --git a/libs/payments/metrics/package.json b/libs/payments/metrics/package.json index 749e02e1b97..232da79bb5f 100644 --- a/libs/payments/metrics/package.json +++ b/libs/payments/metrics/package.json @@ -1,8 +1,4 @@ { "name": "@fxa/payments/metrics", - "version": "0.0.1", - "dependencies": {}, - "type": "commonjs", - "main": "./index.cjs", - "private": true + "version": "0.0.1" } diff --git a/libs/payments/metrics/project.json b/libs/payments/metrics/project.json index 229178fcce4..b2e6fd0a124 100644 --- a/libs/payments/metrics/project.json +++ b/libs/payments/metrics/project.json @@ -6,16 +6,22 @@ "tags": [], "targets": { "build": { - "executor": "@nx/esbuild:esbuild", + "dependsOn": ["build-ts"], + "executor": "nx:run-commands", + "options": { + "command": "echo Build complete" + } + }, + "build-ts": { + "dependsOn": ["^build", "glean-generate", "glean-generate-frontend"], + "executor": "@nx/js:tsc", "outputs": ["{options.outputPath}"], "options": { "outputPath": "dist/libs/payments/metrics", "main": "libs/payments/metrics/src/index.ts", "tsConfig": "libs/payments/metrics/tsconfig.lib.json", - "assets": ["libs/payments/metrics/*.md"], - "declaration": true - }, - "dependsOn": ["glean-generate", "glean-generate-frontend"] + "assets": ["libs/payments/metrics/*.md"] + } }, "compile": { "command": "tsc -p libs/payments/metrics/tsconfig.json --noEmit", @@ -23,16 +29,38 @@ }, "glean-generate": { "dependsOn": ["glean-lint"], + "cache": true, + "inputs": [ + "{workspaceRoot}/libs/shared/metrics/glean/src/registry/subplat-backend-metrics.yaml" + ], + "outputs": [ + "{projectRoot}/src/lib/glean/__generated__/server_events.ts" + ], "command": "yarn glean translate libs/shared/metrics/glean/src/registry/subplat-backend-metrics.yaml -f typescript_server -o libs/payments/metrics/src/lib/glean/__generated__" }, "glean-lint": { + "cache": true, + "inputs": [ + "{workspaceRoot}/libs/shared/metrics/glean/src/registry/subplat-backend-metrics.yaml" + ], "command": "yarn glean glinter libs/shared/metrics/glean/src/registry/subplat-backend-metrics.yaml" }, "glean-generate-frontend": { "dependsOn": ["glean-lint-frontend"], + "cache": true, + "inputs": [ + "{workspaceRoot}/libs/shared/metrics/glean/src/registry/subplat-frontend-metrics.yaml" + ], + "outputs": [ + "{projectRoot}/src/lib/glean/__generated__/subscriptions.ts" + ], "command": "yarn glean translate libs/shared/metrics/glean/src/registry/subplat-frontend-metrics.yaml -f typescript -o libs/payments/metrics/src/lib/glean/__generated__" }, "glean-lint-frontend": { + "cache": true, + "inputs": [ + "{workspaceRoot}/libs/shared/metrics/glean/src/registry/subplat-frontend-metrics.yaml" + ], "command": "yarn glean glinter libs/shared/metrics/glean/src/registry/subplat-frontend-metrics.yaml" }, "test-unit": { diff --git a/libs/payments/metrics/src/lib/glean/glean.factory.ts b/libs/payments/metrics/src/lib/glean/glean.factory.ts index 588c0206b83..3ca5700e097 100644 --- a/libs/payments/metrics/src/lib/glean/glean.factory.ts +++ b/libs/payments/metrics/src/lib/glean/glean.factory.ts @@ -27,7 +27,6 @@ import { type StripeMetricsData, type SubPlatCmsMetricsData, } from './glean.types'; -import { ResultCartFactory } from '@fxa/payments/cart'; import { SubplatInterval, TaxAddressFactory } from '@fxa/payments/customer'; export const CheckoutParamsFactory = ( @@ -61,21 +60,15 @@ export const CommonMetricsFactory = ( export const CartMetricsFactory = ( override?: Partial -): CartMetrics => { - const resultCart = ResultCartFactory({ - ...override, - }); - - return { - uid: resultCart.uid, - errorReasonId: resultCart.errorReasonId, - couponCode: resultCart.couponCode, - currency: faker.finance.currencyCode().toLowerCase(), - stripeCustomerId: `cus_${faker.string.alphanumeric({ length: 14 })}`, - taxAddress: resultCart.taxAddress, - ...override, - }; -}; +): CartMetrics => ({ + uid: undefined, + errorReasonId: null, + couponCode: undefined, + currency: faker.finance.currencyCode().toLowerCase(), + stripeCustomerId: `cus_${faker.string.alphanumeric({ length: 14 })}`, + taxAddress: undefined, + ...override, +}); export const CmsMetricsDataFactory = ( override?: Partial @@ -106,10 +99,7 @@ export const SubscriptionCancellationDataFactory = ( export const TrialConversionDataFactory = ( override?: Partial ): TrialConversionData => ({ - conversionStatus: faker.helpers.arrayElement([ - 'successful', - 'unsuccessful', - ]), + conversionStatus: faker.helpers.arrayElement(['successful', 'unsuccessful']), providerEventId: `evt_${faker.string.alphanumeric({ length: 24 })}`, productId: `prod_${faker.string.alphanumeric({ length: 14 })}`, billingCountry: faker.location.countryCode(), diff --git a/libs/payments/metrics/src/lib/glean/glean.service.spec.ts b/libs/payments/metrics/src/lib/glean/glean.service.spec.ts index 05f13f57c1e..7037cfb1399 100644 --- a/libs/payments/metrics/src/lib/glean/glean.service.spec.ts +++ b/libs/payments/metrics/src/lib/glean/glean.service.spec.ts @@ -55,7 +55,6 @@ import { } from '@fxa/shared/experiments'; import { MockFirestoreProvider } from '@fxa/shared/db/firestore'; import { MockStatsDProvider } from '@fxa/shared/metrics/statsd'; -import { AsyncLocalStorageCartProvider } from '@fxa/payments/cart'; describe('PaymentsGleanService', () => { let paymentsGleanService: PaymentsGleanService; @@ -72,7 +71,6 @@ describe('PaymentsGleanService', () => { const moduleRef = await Test.createTestingModule({ providers: [ AccountManager, - AsyncLocalStorageCartProvider, CustomerManager, Logger, MockFirestoreProvider, diff --git a/libs/payments/metrics/src/lib/glean/glean.service.ts b/libs/payments/metrics/src/lib/glean/glean.service.ts index ce7ade2c2ef..0b5222aa538 100644 --- a/libs/payments/metrics/src/lib/glean/glean.service.ts +++ b/libs/payments/metrics/src/lib/glean/glean.service.ts @@ -28,7 +28,7 @@ import type { StripePrice, StripeSubscription, } from '@fxa/payments/stripe'; -import { getPriceFromSubscription } from 'libs/payments/customer/src/lib/util/getPriceFromSubscription'; +import { getPriceFromSubscription } from '@fxa/payments/customer'; import { PaymentsGleanManager } from './glean.manager'; import { Logger, Injectable } from '@nestjs/common'; diff --git a/libs/payments/metrics/src/lib/glean/glean.types.ts b/libs/payments/metrics/src/lib/glean/glean.types.ts index d4a9789e180..c80daf8045c 100644 --- a/libs/payments/metrics/src/lib/glean/glean.types.ts +++ b/libs/payments/metrics/src/lib/glean/glean.types.ts @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import type { ResultCart } from '@fxa/payments/cart'; import type { SubplatInterval } from '@fxa/payments/customer'; export const CheckoutTypes = [ @@ -31,15 +30,14 @@ export type CommonMetrics = { searchParams: Record; }; -export type CartMetrics = Pick< - ResultCart, - | 'uid' - | 'errorReasonId' - | 'couponCode' - | 'currency' - | 'stripeCustomerId' - | 'taxAddress' ->; +export type CartMetrics = { + uid?: string; + errorReasonId?: string | null; + couponCode?: string | null; + currency?: string | null; + stripeCustomerId?: string | null; + taxAddress?: TaxAddress | null; +}; export type ExperimentationData = { nimbusUserId: string; diff --git a/libs/payments/paypal/project.json b/libs/payments/paypal/project.json index 6b054faf470..4ad3086e4f7 100644 --- a/libs/payments/paypal/project.json +++ b/libs/payments/paypal/project.json @@ -6,13 +6,18 @@ "tags": ["scope:shared:lib:payments"], "targets": { "build": { - "executor": "@nx/esbuild:esbuild", + "dependsOn": ["build-ts"], + "executor": "nx:run-commands", + "options": { + "command": "echo Build complete" + } + }, + "build-ts": { + "executor": "@nx/js:tsc", "outputs": ["{options.outputPath}"], - "defaultConfiguration": "production", "options": { "main": "libs/payments/paypal/src/index.ts", "outputPath": "dist/libs/payments/paypal", - "outputFileName": "main.js", "tsConfig": "libs/payments/paypal/tsconfig.lib.json", "assets": [ { @@ -20,16 +25,7 @@ "input": ".", "output": "." } - ], - "platform": "node" - }, - "configurations": { - "development": { - "minify": false - }, - "production": { - "minify": true - } + ] } }, "lint": { diff --git a/libs/payments/stripe/package.json b/libs/payments/stripe/package.json index a7bee9df242..d6e657f0991 100644 --- a/libs/payments/stripe/package.json +++ b/libs/payments/stripe/package.json @@ -1,4 +1,4 @@ { - "name": "payments/stripe", + "name": "@fxa/payments/stripe", "version": "0.0.0" } diff --git a/libs/payments/stripe/project.json b/libs/payments/stripe/project.json index 799281ebbe6..192924b3c58 100644 --- a/libs/payments/stripe/project.json +++ b/libs/payments/stripe/project.json @@ -6,31 +6,26 @@ "tags": ["scope:shared:lib:payments"], "targets": { "build": { - "executor": "@nx/esbuild:esbuild", + "dependsOn": ["build-ts"], + "executor": "nx:run-commands", + "options": { + "command": "echo Build complete" + } + }, + "build-ts": { + "executor": "@nx/js:tsc", "outputs": ["{options.outputPath}"], - "defaultConfiguration": "production", "options": { "main": "libs/payments/stripe/src/index.ts", "outputPath": "dist/libs/payments/stripe", - "outputFileName": "main.js", "tsConfig": "libs/payments/stripe/tsconfig.lib.json", - "declaration": true, "assets": [ { "glob": "libs/payments/stripe/README.md", "input": ".", "output": "." } - ], - "platform": "node" - }, - "configurations": { - "development": { - "minify": false - }, - "production": { - "minify": true - } + ] } }, "lint": { diff --git a/libs/payments/stripe/src/lib/factories/price.factory.ts b/libs/payments/stripe/src/lib/factories/price.factory.ts index 5d4aa9ee623..cf7f3324070 100644 --- a/libs/payments/stripe/src/lib/factories/price.factory.ts +++ b/libs/payments/stripe/src/lib/factories/price.factory.ts @@ -22,7 +22,8 @@ export const StripePriceFactory = ( const currency = override?.currency?.toLowerCase() || faker.finance.currencyCode().toLowerCase(); - const unit_amount = override?.unit_amount || faker.number.int({ max: 1000 }); + const unit_amount = + override?.unit_amount || faker.number.int({ min: 1, max: 1000 }); const unit_amount_decimal = override?.unit_amount_decimal || faker.commerce.price({ min: 1000 }); return { diff --git a/libs/payments/webhooks/package.json b/libs/payments/webhooks/package.json index ab7319314da..b3b861f0b1e 100644 --- a/libs/payments/webhooks/package.json +++ b/libs/payments/webhooks/package.json @@ -1,8 +1,4 @@ { "name": "@fxa/payments/webhooks", - "version": "0.0.1", - "dependencies": {}, - "type": "commonjs", - "main": "./index.cjs", - "private": true + "version": "0.0.1" } diff --git a/libs/payments/webhooks/project.json b/libs/payments/webhooks/project.json index c87a34748a6..c04f6bb1814 100644 --- a/libs/payments/webhooks/project.json +++ b/libs/payments/webhooks/project.json @@ -6,14 +6,21 @@ "tags": [], "targets": { "build": { - "executor": "@nx/esbuild:esbuild", + "dependsOn": ["build-ts"], + "executor": "nx:run-commands", + "options": { + "command": "echo Build complete" + } + }, + "build-ts": { + "executor": "@nx/js:tsc", "outputs": ["{options.outputPath}"], "options": { "outputPath": "dist/libs/payments/webhooks", "main": "libs/payments/webhooks/src/index.ts", "tsConfig": "libs/payments/webhooks/tsconfig.lib.json", "assets": ["libs/payments/webhooks/*.md"], - "declaration": true + "generatePackageJson": true } }, "test-unit": { diff --git a/libs/profile/client/package.json b/libs/profile/client/package.json index b0b290dfe74..93ed58cc369 100644 --- a/libs/profile/client/package.json +++ b/libs/profile/client/package.json @@ -1,8 +1,4 @@ { "name": "@fxa/profile/client", - "version": "0.0.1", - "dependencies": {}, - "type": "commonjs", - "main": "./index.cjs", - "private": true + "version": "0.0.1" } diff --git a/libs/profile/client/project.json b/libs/profile/client/project.json index d2f189825bf..bd7c0843a7f 100644 --- a/libs/profile/client/project.json +++ b/libs/profile/client/project.json @@ -6,14 +6,21 @@ "tags": [], "targets": { "build": { - "executor": "@nx/esbuild:esbuild", + "dependsOn": ["build-ts"], + "executor": "nx:run-commands", + "options": { + "command": "echo Build complete" + } + }, + "build-ts": { + "executor": "@nx/js:tsc", "outputs": ["{options.outputPath}"], "options": { "outputPath": "dist/libs/profile/client", "main": "libs/profile/client/src/index.ts", "tsConfig": "libs/profile/client/tsconfig.lib.json", "assets": ["libs/profile/client/*.md"], - "declaration": true + "generatePackageJson": true } }, "test-unit": { diff --git a/libs/shared/account/account/project.json b/libs/shared/account/account/project.json index f25982c12be..b544a652515 100644 --- a/libs/shared/account/account/project.json +++ b/libs/shared/account/account/project.json @@ -6,31 +6,26 @@ "tags": ["scope:shared:lib"], "targets": { "build": { - "executor": "@nx/esbuild:esbuild", + "dependsOn": ["build-ts"], + "executor": "nx:run-commands", + "options": { + "command": "echo Build complete" + } + }, + "build-ts": { + "executor": "@nx/js:tsc", "outputs": ["{options.outputPath}"], - "defaultConfiguration": "production", "options": { "main": "libs/shared/account/account/src/index.ts", "outputPath": "dist/libs/shared/account/account", - "outputFileName": "main.js", "tsConfig": "libs/shared/account/account/tsconfig.lib.json", - "declaration": true, "assets": [ { "glob": "libs/shared/account/account/README.md", "input": ".", "output": "." } - ], - "platform": "node" - }, - "configurations": { - "development": { - "minify": false - }, - "production": { - "minify": true - } + ] } }, "lint": { diff --git a/libs/shared/assets/project.json b/libs/shared/assets/project.json index 6b053260ef2..6b7209bc7ec 100644 --- a/libs/shared/assets/project.json +++ b/libs/shared/assets/project.json @@ -5,6 +5,13 @@ "projectType": "library", "targets": { "build": { + "dependsOn": ["build-ts"], + "executor": "nx:run-commands", + "options": { + "command": "echo Build complete" + } + }, + "build-ts": { "executor": "@nx/js:tsc", "outputs": ["{options.outputPath}"], "options": { diff --git a/libs/shared/cloud-tasks/project.json b/libs/shared/cloud-tasks/project.json index 1d68b8010af..fd98fb75622 100644 --- a/libs/shared/cloud-tasks/project.json +++ b/libs/shared/cloud-tasks/project.json @@ -6,31 +6,26 @@ "tags": [], "targets": { "build": { - "executor": "@nx/esbuild:esbuild", + "dependsOn": ["build-ts"], + "executor": "nx:run-commands", + "options": { + "command": "echo Build complete" + } + }, + "build-ts": { + "executor": "@nx/js:tsc", "outputs": ["{options.outputPath}"], - "defaultConfiguration": "production", "options": { "main": "libs/shared/cloud-tasks/src/index.ts", "outputPath": "dist/libs/shared/cloud-tasks", - "outputFileName": "main.js", "tsConfig": "libs/shared/cloud-tasks/tsconfig.lib.json", - "declaration": true, "assets": [ { "glob": "libs/shared/cloud-tasks/README.md", "input": ".", "output": "." } - ], - "platform": "node" - }, - "configurations": { - "development": { - "minify": false - }, - "production": { - "minify": true - } + ] } }, "lint": { diff --git a/libs/shared/cms/project.json b/libs/shared/cms/project.json index c0d56d735dc..63a46aa3064 100644 --- a/libs/shared/cms/project.json +++ b/libs/shared/cms/project.json @@ -12,31 +12,26 @@ } }, "build": { - "executor": "@nx/esbuild:esbuild", + "dependsOn": ["build-ts"], + "executor": "nx:run-commands", + "options": { + "command": "echo Build complete" + } + }, + "build-ts": { + "executor": "@nx/js:tsc", "outputs": ["{options.outputPath}"], - "defaultConfiguration": "production", "options": { "main": "libs/shared/cms/src/index.ts", "outputPath": "dist/libs/shared/cms", - "outputFileName": "main.js", "tsConfig": "libs/shared/cms/tsconfig.lib.json", - "declaration": true, "assets": [ { "glob": "libs/shared/cms/README.md", "input": ".", "output": "." } - ], - "platform": "node" - }, - "configurations": { - "development": { - "minify": false - }, - "production": { - "minify": true - } + ] } }, "lint": { diff --git a/libs/shared/db/firestore/project.json b/libs/shared/db/firestore/project.json index 2dc1dbde25f..ad0fa418ffb 100644 --- a/libs/shared/db/firestore/project.json +++ b/libs/shared/db/firestore/project.json @@ -6,31 +6,26 @@ "tags": ["scope:shared:lib"], "targets": { "build": { - "executor": "@nx/esbuild:esbuild", + "dependsOn": ["build-ts"], + "executor": "nx:run-commands", + "options": { + "command": "echo Build complete" + } + }, + "build-ts": { + "executor": "@nx/js:tsc", "outputs": ["{options.outputPath}"], - "defaultConfiguration": "production", "options": { "main": "libs/shared/db/firestore/src/index.ts", "outputPath": "dist/libs/shared/db/firestore", - "outputFileName": "main.js", "tsConfig": "libs/shared/db/firestore/tsconfig.lib.json", - "declaration": true, "assets": [ { "glob": "libs/shared/db/firestore/README.md", "input": ".", "output": "." } - ], - "platform": "node" - }, - "configurations": { - "development": { - "minify": false - }, - "production": { - "minify": true - } + ] } }, "lint": { diff --git a/libs/shared/db/mysql/account/project.json b/libs/shared/db/mysql/account/project.json index 4623aa4d9a1..34d11fcd98b 100644 --- a/libs/shared/db/mysql/account/project.json +++ b/libs/shared/db/mysql/account/project.json @@ -6,31 +6,26 @@ "tags": ["scope:shared:lib"], "targets": { "build": { - "executor": "@nx/esbuild:esbuild", + "dependsOn": ["build-ts"], + "executor": "nx:run-commands", + "options": { + "command": "echo Build complete" + } + }, + "build-ts": { + "executor": "@nx/js:tsc", "outputs": ["{options.outputPath}"], - "defaultConfiguration": "production", "options": { "main": "libs/shared/db/mysql/account/src/index.ts", "outputPath": "dist/libs/shared/db/mysql/account", - "outputFileName": "main.js", "tsConfig": "libs/shared/db/mysql/account/tsconfig.lib.json", - "declaration": true, "assets": [ { "glob": "libs/shared/db/mysql/account/README.md", "input": ".", "output": "." } - ], - "platform": "node" - }, - "configurations": { - "development": { - "minify": false - }, - "production": { - "minify": true - } + ] } }, "lint": { diff --git a/libs/shared/db/mysql/core/project.json b/libs/shared/db/mysql/core/project.json index fbdd06f8ac8..25cf734ac2f 100644 --- a/libs/shared/db/mysql/core/project.json +++ b/libs/shared/db/mysql/core/project.json @@ -6,31 +6,26 @@ "tags": ["scope:shared:lib"], "targets": { "build": { - "executor": "@nx/esbuild:esbuild", + "dependsOn": ["build-ts"], + "executor": "nx:run-commands", + "options": { + "command": "echo Build complete" + } + }, + "build-ts": { + "executor": "@nx/js:tsc", "outputs": ["{options.outputPath}"], - "defaultConfiguration": "production", "options": { "main": "libs/shared/db/mysql/core/src/index.ts", "outputPath": "dist/libs/shared/db/mysql/core", - "outputFileName": "main.js", "tsConfig": "libs/shared/db/mysql/core/tsconfig.lib.json", - "declaration": true, "assets": [ { "glob": "libs/shared/db/mysql/core/README.md", "input": ".", "output": "." } - ], - "platform": "node" - }, - "configurations": { - "development": { - "minify": false - }, - "production": { - "minify": true - } + ] } }, "lint": { diff --git a/libs/shared/db/type-cacheable/project.json b/libs/shared/db/type-cacheable/project.json index dd14ab15ede..10d4b7a8cf9 100644 --- a/libs/shared/db/type-cacheable/project.json +++ b/libs/shared/db/type-cacheable/project.json @@ -6,31 +6,26 @@ "tags": ["scope:shared:lib"], "targets": { "build": { - "executor": "@nx/esbuild:esbuild", + "dependsOn": ["build-ts"], + "executor": "nx:run-commands", + "options": { + "command": "echo Build complete" + } + }, + "build-ts": { + "executor": "@nx/js:tsc", "outputs": ["{options.outputPath}"], - "defaultConfiguration": "production", "options": { "main": "libs/shared/db/type-cacheable/src/index.ts", "outputPath": "dist/libs/shared/db/type-cacheable", - "outputFileName": "main.js", "tsConfig": "libs/shared/db/type-cacheable/tsconfig.lib.json", - "declaration": true, "assets": [ { "glob": "libs/shared/db/type-cacheable/README.md", "input": ".", "output": "." } - ], - "platform": "node" - }, - "configurations": { - "development": { - "minify": false - }, - "production": { - "minify": true - } + ] } }, "lint": { diff --git a/libs/shared/error/project.json b/libs/shared/error/project.json index 496b5868925..f07017606bd 100644 --- a/libs/shared/error/project.json +++ b/libs/shared/error/project.json @@ -6,31 +6,26 @@ "tags": ["scope:shared:lib"], "targets": { "build": { - "executor": "@nx/esbuild:esbuild", + "dependsOn": ["build-ts"], + "executor": "nx:run-commands", + "options": { + "command": "echo Build complete" + } + }, + "build-ts": { + "executor": "@nx/js:tsc", "outputs": ["{options.outputPath}"], - "defaultConfiguration": "production", "options": { "main": "libs/shared/error/src/index.ts", "outputPath": "dist/libs/shared/error", - "outputFileName": "main.js", "tsConfig": "libs/shared/error/tsconfig.lib.json", - "declaration": true, "assets": [ { "glob": "libs/shared/error/README.md", "input": ".", "output": "." } - ], - "platform": "node" - }, - "configurations": { - "development": { - "minify": false - }, - "production": { - "minify": true - } + ] } }, "lint": { diff --git a/libs/shared/error/src/index.ts b/libs/shared/error/src/index.ts index c0a5997d9e1..b8c9a63102b 100644 --- a/libs/shared/error/src/index.ts +++ b/libs/shared/error/src/index.ts @@ -1,5 +1,13 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -export { BaseError, BaseMultiError, TypeError, GENERIC_ERROR_MESSAGE } from './lib/error'; -export { SanitizeExceptions } from './lib/sanitizeExceptionsDecorator'; +export { + BaseError, + BaseMultiError, + TypeError, + GENERIC_ERROR_MESSAGE, +} from './lib/error'; +export { + SanitizeExceptions, + handleException, +} from './lib/sanitizeExceptionsDecorator'; diff --git a/libs/shared/experiments/package.json b/libs/shared/experiments/package.json index 320007c223e..8a7d93cfe00 100644 --- a/libs/shared/experiments/package.json +++ b/libs/shared/experiments/package.json @@ -1,9 +1,4 @@ { "name": "@fxa/shared/experiments", - "version": "0.0.1", - "private": true, - "type": "commonjs", - "main": "./index.cjs", - "types": "./index.d.ts", - "dependencies": {} + "version": "0.0.1" } diff --git a/libs/shared/experiments/project.json b/libs/shared/experiments/project.json index ebbdc29183f..841a2073736 100644 --- a/libs/shared/experiments/project.json +++ b/libs/shared/experiments/project.json @@ -6,14 +6,21 @@ "tags": [], "targets": { "build": { - "executor": "@nx/esbuild:esbuild", + "dependsOn": ["build-ts"], + "executor": "nx:run-commands", + "options": { + "command": "echo Build complete" + } + }, + "build-ts": { + "executor": "@nx/js:tsc", "outputs": ["{options.outputPath}"], "options": { "outputPath": "dist/libs/shared/experiments", "main": "libs/shared/experiments/src/index.ts", "tsConfig": "libs/shared/experiments/tsconfig.lib.json", "assets": ["libs/shared/experiments/*.md"], - "declaration": true + "generatePackageJson": true } }, "test-unit": { diff --git a/libs/shared/geodb/project.json b/libs/shared/geodb/project.json index 743ceee36e5..26775351ada 100644 --- a/libs/shared/geodb/project.json +++ b/libs/shared/geodb/project.json @@ -6,31 +6,26 @@ "tags": [], "targets": { "build": { - "executor": "@nx/esbuild:esbuild", + "dependsOn": ["build-ts"], + "executor": "nx:run-commands", + "options": { + "command": "echo Build complete" + } + }, + "build-ts": { + "executor": "@nx/js:tsc", "outputs": ["{options.outputPath}"], - "defaultConfiguration": "production", "options": { "main": "libs/shared/geodb/src/index.ts", "outputPath": "dist/libs/shared/geodb", - "outputFileName": "main.js", "tsConfig": "libs/shared/geodb/tsconfig.lib.json", - "declaration": true, "assets": [ { "glob": "libs/shared/geodb/README.md", "input": ".", "output": "." } - ], - "platform": "node" - }, - "configurations": { - "development": { - "minify": false - }, - "production": { - "minify": true - } + ] } }, "test-unit": { diff --git a/libs/shared/guards/project.json b/libs/shared/guards/project.json index 484c7621f17..2802301053b 100644 --- a/libs/shared/guards/project.json +++ b/libs/shared/guards/project.json @@ -6,14 +6,21 @@ "tags": [], "targets": { "build": { - "executor": "@nx/esbuild:esbuild", + "dependsOn": ["build-ts"], + "executor": "nx:run-commands", + "options": { + "command": "echo Build complete" + } + }, + "build-ts": { + "executor": "@nx/js:tsc", "outputs": ["{options.outputPath}"], "options": { "outputPath": "dist/libs/shared/guards", "main": "libs/shared/guards/src/index.ts", "tsConfig": "libs/shared/guards/tsconfig.lib.json", "assets": ["libs/shared/guards/*.md"], - "format": ["cjs"] + "generatePackageJson": true } }, "test-unit": { diff --git a/libs/shared/l10n/project.json b/libs/shared/l10n/project.json index 4fafde9e7b9..23700dc0421 100644 --- a/libs/shared/l10n/project.json +++ b/libs/shared/l10n/project.json @@ -6,32 +6,31 @@ "tags": [], "targets": { "build": { - "executor": "@nx/esbuild:esbuild", + "dependsOn": ["build-ts"], + "executor": "nx:run-commands", + "options": { + "command": "echo Build complete" + } + }, + "build-ts": { + "executor": "@nx/js:tsc", "outputs": ["{options.outputPath}"], - "defaultConfiguration": "production", "options": { "main": "libs/shared/l10n/src/index.ts", "outputPath": "dist/libs/shared/l10n", - "outputFileName": "main.js", "tsConfig": "libs/shared/l10n/tsconfig.lib.json", - "declaration": true, "assets": [ { "glob": "libs/shared/l10n/README.md", "input": ".", "output": "." + }, + { + "glob": "src/**/*.json", + "input": "libs/shared/l10n", + "output": "." } - ], - "platform": "node", - "format": ["cjs", "esm"] - }, - "configurations": { - "development": { - "minify": false - }, - "production": { - "minify": true - } + ] } }, "lint": { diff --git a/libs/shared/l10n/src/lib/l10n.utils.spec.ts b/libs/shared/l10n/src/lib/l10n.utils.spec.ts index 681a7a3449f..a7048fa3e34 100644 --- a/libs/shared/l10n/src/lib/l10n.utils.spec.ts +++ b/libs/shared/l10n/src/lib/l10n.utils.spec.ts @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import supportedLanguages from './supported-languages.json'; +const supportedLanguages: string[] = require('./supported-languages.json'); import { determineDirection, determineLocale, diff --git a/libs/shared/l10n/src/lib/l10n.utils.ts b/libs/shared/l10n/src/lib/l10n.utils.ts index b15a8352497..a0f2a420035 100644 --- a/libs/shared/l10n/src/lib/l10n.utils.ts +++ b/libs/shared/l10n/src/lib/l10n.utils.ts @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ import { negotiateLanguages } from '@fluent/langneg'; -import availableLocales from './supported-languages.json'; +const availableLocales: string[] = require('./supported-languages.json'); import moment from 'moment'; import { LocalizeOptions } from './l10n.types'; import { DEFAULT_LOCALE, EN_GB_LOCALES } from './l10n.constants'; @@ -162,7 +162,7 @@ export function determineLocale( )[0]; } -import rtlLocales from './rtl-locales.json'; +const rtlLocales: string[] = require('./rtl-locales.json'); /** * Given a set of supported languages and an accept-language http header value, this resolves the direction of the language that fits best. diff --git a/libs/shared/l10n/src/lib/localizer/localizer.rsc.factory.spec.ts b/libs/shared/l10n/src/lib/localizer/localizer.rsc.factory.spec.ts index e69d2647d22..0f76b11b597 100644 --- a/libs/shared/l10n/src/lib/localizer/localizer.rsc.factory.spec.ts +++ b/libs/shared/l10n/src/lib/localizer/localizer.rsc.factory.spec.ts @@ -5,7 +5,7 @@ import { Test } from '@nestjs/testing'; import { LocalizerRscFactory } from './localizer.rsc.factory'; import { ILocalizerBindings } from './localizer.interfaces'; -import supportedLanguages from '../supported-languages.json'; +const supportedLanguages: string[] = require('../supported-languages.json'); import { LocalizerRsc } from './localizer.rsc'; describe('LocalizerRscFactory', () => { diff --git a/libs/shared/l10n/src/lib/localizer/localizer.rsc.factory.ts b/libs/shared/l10n/src/lib/localizer/localizer.rsc.factory.ts index a80312bc18b..f552fff5cab 100644 --- a/libs/shared/l10n/src/lib/localizer/localizer.rsc.factory.ts +++ b/libs/shared/l10n/src/lib/localizer/localizer.rsc.factory.ts @@ -5,7 +5,7 @@ import 'server-only'; import { Injectable } from '@nestjs/common'; import { LocalizerBase } from './localizer.base'; import type { ILocalizerBindings } from './localizer.interfaces'; -import supportedLanguages from '../supported-languages.json'; +const supportedLanguages: string[] = require('../supported-languages.json'); import { FluentBundle } from '@fluent/bundle'; import { LocalizerRsc } from './localizer.rsc'; import { JSDOM } from 'jsdom'; diff --git a/libs/shared/l10n/src/lib/supported-languages.spec.ts b/libs/shared/l10n/src/lib/supported-languages.spec.ts index cbfdede42c6..7306862e879 100644 --- a/libs/shared/l10n/src/lib/supported-languages.spec.ts +++ b/libs/shared/l10n/src/lib/supported-languages.spec.ts @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import supportedLanguages from './supported-languages.json'; +const supportedLanguages: string[] = require('./supported-languages.json'); describe('l10n/supportedLanguages:', () => { it('returns an array of languages', () => { diff --git a/libs/shared/l10n/tsconfig.lib.json b/libs/shared/l10n/tsconfig.lib.json index 4befa7f0990..6836ea5b7f0 100644 --- a/libs/shared/l10n/tsconfig.lib.json +++ b/libs/shared/l10n/tsconfig.lib.json @@ -1,6 +1,7 @@ { "extends": "./tsconfig.json", "compilerOptions": { + "rootDir": "../../..", "outDir": "../../../dist/out-tsc", "declaration": true, "types": ["node"] diff --git a/libs/shared/log/project.json b/libs/shared/log/project.json index abe5a80584d..8a863f92a71 100644 --- a/libs/shared/log/project.json +++ b/libs/shared/log/project.json @@ -6,31 +6,26 @@ "tags": ["scope:shared:lib"], "targets": { "build": { - "executor": "@nx/esbuild:esbuild", + "dependsOn": ["build-ts"], + "executor": "nx:run-commands", + "options": { + "command": "echo Build complete" + } + }, + "build-ts": { + "executor": "@nx/js:tsc", "outputs": ["{options.outputPath}"], - "defaultConfiguration": "production", "options": { "main": "libs/shared/log/src/index.ts", "outputPath": "dist/libs/shared/log", - "outputFileName": "main.js", "tsConfig": "libs/shared/log/tsconfig.lib.json", - "declaration": true, "assets": [ { "glob": "libs/shared/log/README.md", "input": ".", "output": "." } - ], - "platform": "node" - }, - "configurations": { - "development": { - "minify": false - }, - "production": { - "minify": true - } + ] } }, "lint": { diff --git a/libs/shared/metrics/glean/package.json b/libs/shared/metrics/glean/package.json index d290f411949..92f661e3459 100644 --- a/libs/shared/metrics/glean/package.json +++ b/libs/shared/metrics/glean/package.json @@ -1,8 +1,4 @@ { "name": "@fxa/shared/glean", - "version": "0.0.1", - "dependencies": {}, - "type": "commonjs", - "main": "./index.cjs", - "private": true + "version": "0.0.1" } diff --git a/libs/shared/metrics/glean/project.json b/libs/shared/metrics/glean/project.json index 15e93ffb155..a4aca87ec4a 100644 --- a/libs/shared/metrics/glean/project.json +++ b/libs/shared/metrics/glean/project.json @@ -6,15 +6,21 @@ "tags": [], "targets": { "build": { - "executor": "@nx/esbuild:esbuild", + "dependsOn": ["build-ts"], + "executor": "nx:run-commands", + "options": { + "command": "echo Build complete" + } + }, + "build-ts": { + "executor": "@nx/js:tsc", "outputs": ["{options.outputPath}"], "options": { "outputPath": "dist/libs/shared/metrics/glean", "main": "libs/shared/metrics/glean/src/index.ts", "tsConfig": "libs/shared/metrics/glean/tsconfig.lib.json", "assets": ["libs/shared/metrics/glean/*.md"], - "declaration": true, - "format": ["cjs"] + "generatePackageJson": true } }, "test-unit": { diff --git a/libs/shared/metrics/statsd/project.json b/libs/shared/metrics/statsd/project.json index 5f24cd072ff..1ae0ef1ad33 100644 --- a/libs/shared/metrics/statsd/project.json +++ b/libs/shared/metrics/statsd/project.json @@ -6,31 +6,26 @@ "tags": ["scope:shared:lib"], "targets": { "build": { - "executor": "@nx/esbuild:esbuild", + "dependsOn": ["build-ts"], + "executor": "nx:run-commands", + "options": { + "command": "echo Build complete" + } + }, + "build-ts": { + "executor": "@nx/js:tsc", "outputs": ["{options.outputPath}"], - "defaultConfiguration": "production", "options": { "main": "libs/shared/metrics/statsd/src/index.ts", "outputPath": "dist/libs/shared/metrics/statsd", - "outputFileName": "main.js", "tsConfig": "libs/shared/metrics/statsd/tsconfig.lib.json", - "declaration": true, "assets": [ { "glob": "libs/shared/metrics/statsd/README.md", "input": ".", "output": "." } - ], - "platform": "node" - }, - "configurations": { - "development": { - "minify": false - }, - "production": { - "minify": true - } + ] } }, "lint": { diff --git a/libs/shared/mozlog/project.json b/libs/shared/mozlog/project.json index 031dca5c9b1..795f4231457 100644 --- a/libs/shared/mozlog/project.json +++ b/libs/shared/mozlog/project.json @@ -6,36 +6,26 @@ "tags": [], "targets": { "build": { - "executor": "@nx/esbuild:esbuild", + "dependsOn": ["build-ts"], + "executor": "nx:run-commands", + "options": { + "command": "echo Build complete" + } + }, + "build-ts": { + "executor": "@nx/js:tsc", "outputs": ["{options.outputPath}"], - "defaultConfiguration": "production", "options": { "main": "libs/shared/mozlog/src/index.ts", "outputPath": "dist/libs/shared/mozlog", - "outputFileName": "main.js", "tsConfig": "libs/shared/mozlog/tsconfig.lib.json", - "declaration": true, - "external": [ - "@nestjs/websockets/socket-module", - "@nestjs/microservices/microservices-module", - "@nestjs/microservices" - ], "assets": [ { "glob": "libs/shared/mozlog/README.md", "input": ".", "output": "." } - ], - "platform": "node" - }, - "configurations": { - "development": { - "minify": false - }, - "production": { - "minify": true - } + ] } }, "lint": { diff --git a/libs/shared/nestjs/customs/.eslintrc.json b/libs/shared/nestjs/customs/.eslintrc.json deleted file mode 100644 index 632e9b0e222..00000000000 --- a/libs/shared/nestjs/customs/.eslintrc.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "extends": ["../../../../.eslintrc.json"], - "ignorePatterns": ["!**/*"], - "overrides": [ - { - "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], - "rules": {} - }, - { - "files": ["*.ts", "*.tsx"], - "rules": {} - }, - { - "files": ["*.js", "*.jsx"], - "rules": {} - } - ] -} diff --git a/libs/shared/nestjs/customs/README.md b/libs/shared/nestjs/customs/README.md deleted file mode 100644 index 05cfa4fdf0a..00000000000 --- a/libs/shared/nestjs/customs/README.md +++ /dev/null @@ -1,12 +0,0 @@ -# Customs - -This library supports adding customs (i.e. rate-limiting) as a nestjs service. It was initially designed to work with -FxA's graphql-api, but could be repurposed to work else where. - -## Building - -Run `nx build customs` to build the library. - -## Running unit tests - -Run `nx test-unit customs` to execute the unit tests via [Jest](https://jestjs.io). diff --git a/libs/shared/nestjs/customs/jest.config.ts b/libs/shared/nestjs/customs/jest.config.ts deleted file mode 100644 index 6a96e5baef0..00000000000 --- a/libs/shared/nestjs/customs/jest.config.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { Config } from 'jest'; - -/* eslint-disable */ -const config: Config = { - displayName: 'shared-nestjs-customs', - preset: '../../../../jest.preset.js', - testEnvironment: 'node', - transform: { - '^.+\\.[tj]s$': ['ts-jest', { tsconfig: '/tsconfig.spec.json' }], - }, - moduleFileExtensions: ['ts', 'js', 'html'], - coverageDirectory: '../../../../coverage/libs/nestjs/customs', - reporters: [ - 'default', - [ - 'jest-junit', - { - outputDirectory: 'artifacts/tests/lib/shared/nestjs/customs', - outputName: 'nestjs-customs-jest-unit-results.xml', - }, - ], - ], -}; - -export default config; diff --git a/libs/shared/nestjs/customs/package.json b/libs/shared/nestjs/customs/package.json deleted file mode 100644 index cc51ecb6f51..00000000000 --- a/libs/shared/nestjs/customs/package.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "name": "@fxa/shared/nestjs/customs", - "version": "0.0.1", - "private": true, - "type": "commonjs", - "main": "./index.cjs", - "types": "./index.d.ts", - "dependencies": {} -} diff --git a/libs/shared/nestjs/customs/project.json b/libs/shared/nestjs/customs/project.json deleted file mode 100644 index e24c5acaa12..00000000000 --- a/libs/shared/nestjs/customs/project.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "name": "shared-nestjs-customs", - "$schema": "../../../../node_modules/nx/schemas/project-schema.json", - "sourceRoot": "libs/shared/nestjs/customs/src", - "projectType": "library", - "tags": ["scope:shared:lib"], - "targets": { - "build": { - "executor": "@nx/esbuild:esbuild", - "outputs": ["{options.outputPath}"], - "options": { - "outputPath": "dist/libs/shared/nestjs/customs", - "main": "libs/shared/nestjs/customs/src/index.ts", - "tsConfig": "libs/shared/nestjs/customs/tsconfig.lib.json", - "external": [ - "@nestjs/websockets/socket-module", - "@nestjs/microservices/microservices-module", - "@nestjs/microservices" - ], - "assets": ["libs/shared/nestjs/customs/*.md"], - "format": ["cjs"] - } - }, - "test-unit": { - "executor": "@nx/jest:jest", - "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], - "options": { - "jestConfig": "libs/shared/nestjs/customs/jest.config.ts", - "testPathPattern": ["^(?!.*\\.in\\.spec\\.ts$).*$"] - } - } - } -} diff --git a/libs/shared/nestjs/customs/src/index.ts b/libs/shared/nestjs/customs/src/index.ts deleted file mode 100644 index b0b7823b157..00000000000 --- a/libs/shared/nestjs/customs/src/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './lib/customs.module'; -export * from './lib/customs.service'; diff --git a/libs/shared/nestjs/customs/src/lib/customs.module.ts b/libs/shared/nestjs/customs/src/lib/customs.module.ts deleted file mode 100644 index abb9f02c06e..00000000000 --- a/libs/shared/nestjs/customs/src/lib/customs.module.ts +++ /dev/null @@ -1,29 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -import { Module } from '@nestjs/common'; -import { LegacyStatsDProvider } from '@fxa/shared/metrics/statsd'; -import { LOGGER_PROVIDER } from '@fxa/shared/log'; -import { CustomsService } from './customs.service'; -import { - RateLimitProvider, - RateLimitRedisProvider, -} from '@fxa/accounts/rate-limit'; -import { MozLoggerService } from '@fxa/shared/mozlog'; - -@Module({ - providers: [ - CustomsService, - RateLimitRedisProvider, - RateLimitProvider, - MozLoggerService, - LegacyStatsDProvider, - { - provide: LOGGER_PROVIDER, - useClass: MozLoggerService, - }, - ], - exports: [CustomsService], -}) -export class CustomsModule {} diff --git a/libs/shared/nestjs/customs/src/lib/customs.service.spec.ts b/libs/shared/nestjs/customs/src/lib/customs.service.spec.ts deleted file mode 100644 index edbbf73be32..00000000000 --- a/libs/shared/nestjs/customs/src/lib/customs.service.spec.ts +++ /dev/null @@ -1,202 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -import { Test, TestingModule } from '@nestjs/testing'; -import { GraphQLError } from 'graphql'; - -import { CustomsService } from './customs.service'; -import { MozLoggerService } from '@fxa/shared/mozlog'; -import { RateLimitClient } from '../../../../../accounts/rate-limit/src'; -import { ConfigService } from '@nestjs/config'; -import * as superagent from 'superagent'; -import { LOGGER_PROVIDER } from '../../../../log/src'; -import { StatsD, StatsDService } from '../../../../metrics/statsd/src'; - -jest.mock('superagent', () => ({ - post: jest.fn(), -})); - -describe('Customs Service', () => { - const mockConfig = new ConfigService({ - customsUrl: 'http://localhost:7000', - l10n: { - defaultLanguage: 'en', - supportedLanguages: ['en', 'fr'], - }, - }); - const mockLogger = { - debug: jest.fn(), - warn: jest.fn(), - }; - const mockStatsd = { - increment: jest.fn(), - } as unknown as StatsD; - const mockRateLimit = { - supportsAction: jest.fn(), - skip: jest.fn(), - check: jest.fn(), - }; - const mockL10nTsFormatter = { - format: jest.fn(), - }; - - let service: CustomsService; - - beforeEach(async () => { - const module: TestingModule = await Test.createTestingModule({ - providers: [ - { provide: ConfigService, useValue: mockConfig }, - { provide: 'L10N_TS_FORMATTER', useValue: mockL10nTsFormatter }, - { provide: RateLimitClient, useValue: mockRateLimit }, - { provide: StatsDService, useValue: mockStatsd }, - { provide: LOGGER_PROVIDER, useValue: mockLogger }, - { provide: MozLoggerService, useValue: mockLogger }, - CustomsService, - ], - }).compile(); - service = module.get(CustomsService); - - jest.resetAllMocks(); - }); - - it('should be defined', () => { - expect(service).toBeDefined(); - }); - - describe('for rate limit rule', () => { - it('can call rate limiter when rate limit rule is defined', async () => { - mockRateLimit.supportsAction.mockImplementation(() => true); - await service.check({ - action: 'test', - ip: '127.0.0.1', - }); - - expect(superagent.post).toBeCalledTimes(0); - expect(mockRateLimit.check).toBeCalledTimes(1); - expect(mockStatsd.increment).toBeCalledWith('customs.check.v2', [ - 'action:test', - ]); - }); - - it('should throw too many requests error, when rate limit rule is defined', async () => { - mockRateLimit.supportsAction.mockImplementation(() => true); - mockRateLimit.check.mockImplementation(async (action) => { - if (action === 'unblockEmail') { - return null; - } - - return { - retryAfter: 100, - block: true, - }; - }); - - let error: GraphQLError | null = null; - try { - await service.check({ - action: 'test', - ip: '127.0.0.1', - email: 'foo@mozilla.com', - uid: '123', - // Important! Trigger and check localized error message state! - acceptLanguage: 'fr', - }); - } catch (err) { - error = err; - } - - expect(mockRateLimit.check).toHaveBeenCalled(); - expect(mockRateLimit.check).toHaveBeenCalledWith('test', { - ip: '127.0.0.1', - email: 'foo@mozilla.com', - uid: '123', - ip_email: '127.0.0.1_foo@mozilla.com', - ip_uid: '127.0.0.1_123', - }); - expect(mockRateLimit.check).toHaveBeenCalledWith('unblockEmail', { - ip: '127.0.0.1', - email: 'foo@mozilla.com', - ip_email: '127.0.0.1_foo@mozilla.com', - uid: '123', - ip_uid: '127.0.0.1_123', - }); - - expect(error).toBeDefined(); - expect(error?.message).toEqual('Client has sent too many requests'); - expect(error?.extensions).toEqual({ - code: 429, - errno: 114, - error: 'Too Many Requests', - 'retry-after': 100, - // Since an 'acceptLanguage' of 'fr' was provided - retryAfterLocalized: 'dans quelques secondes', - // Since we mocked an unblock being allowed. - verificationMethod: 'email-captcha', - verificationReason: 'login', - }); - }); - }); - - describe('for customs service', () => { - it('can call customs', async () => { - (superagent.post as unknown as jest.SpyInstance).mockReturnValue({ - send: () => ({ - ok: () => ({ - status: 200, - body: { - blocked: false, - }, - }), - }), - }); - - await service.check({ - action: 'test', - ip: '127.0.0.1', - }); - - expect(superagent.post).toBeCalledTimes(1); - expect(mockRateLimit.check).toBeCalledTimes(0); - expect(mockStatsd.increment).toBeCalledWith('customs.check.v1', [ - 'action:test', - ]); - }); - - it('should throw too many requests error, when rate limit rule is defined', async () => { - (superagent.post as unknown as jest.SpyInstance).mockReturnValue({ - send: () => ({ - ok: () => ({ - status: 200, - body: { - block: true, - retryAfter: 101, - }, - }), - }), - }); - - let error: GraphQLError | null = null; - try { - await service.check({ - action: 'test', - ip: '127.0.0.1', - // Important! Trigger and check localized error message state! - acceptLanguage: 'fr', - }); - } catch (err) { - error = err; - } - - expect(error).toBeDefined(); - expect(error?.message).toEqual('Client has sent too many requests'); - expect(error?.extensions).toEqual({ - code: 429, - errno: 114, - error: 'Too Many Requests', - 'retry-after': 101, - retryAfterLocalized: 'dans quelques secondes', - }); - }); - }); -}); diff --git a/libs/shared/nestjs/customs/src/lib/customs.service.ts b/libs/shared/nestjs/customs/src/lib/customs.service.ts deleted file mode 100644 index d87e760c085..00000000000 --- a/libs/shared/nestjs/customs/src/lib/customs.service.ts +++ /dev/null @@ -1,240 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { BadRequestException, Inject, Injectable } from '@nestjs/common'; -import { ConfigService } from '@nestjs/config'; -import superagent from 'superagent'; -import { - BlockOnOpts, - RateLimit, - RateLimitClient, -} from '@fxa/accounts/rate-limit'; -import { MozLoggerService } from '@fxa/shared/mozlog'; -import { LOGGER_PROVIDER } from '@fxa/shared/log'; -import { localizeTimestamp } from '@fxa/shared/l10n'; -import { StatsD, StatsDService } from '@fxa/shared/metrics/statsd'; -import { GraphQLError } from 'graphql'; - -type AnyObject = Record; - -export type CheckOptions = BlockOnOpts & { - action: string; - headers?: AnyObject; - query?: AnyObject; - payload?: AnyObject; - acceptLanguage?: string; -}; - -type CheckResponse = { - block: boolean; - blockReason?: string; - suspect?: boolean; - unblock?: boolean; - retryAfter?: number; -}; - -@Injectable() -export class CustomsService { - private customsUrl: string; - private l10nTimestampFormatter: ReturnType; - - constructor( - config: ConfigService, - @Inject(RateLimitClient) private readonly rateLimit: RateLimit, - @Inject(LOGGER_PROVIDER) private readonly log: MozLoggerService, - @Inject(StatsDService) private readonly statsd: StatsD - ) { - // Customs service url - const customsUrl = config.get('customsUrl'); - if (!customsUrl) { - throw new Error('No customs URL provided.'); - } - this.customsUrl = customsUrl; - - // l10nTimestampFormatter - const defaultLanguage = config.get('l10n.defaultLanguage'); - if (!defaultLanguage) { - throw new Error('Config missing l10n.defaultLanguage.'); - } - const supportedLanguages = config.get('l10n.supportedLanguages'); - if (!supportedLanguages) { - throw new Error('Config missing l10n.supportedLanguages'); - } - this.l10nTimestampFormatter = localizeTimestamp({ - defaultLanguage, - supportedLanguages, - }); - } - - async check(options: CheckOptions): Promise { - let response: CheckResponse = { block: false }; - - // If a rate limit is configured for the supplied action, use this rate limit instead. - // Otherwise call the legacy customs service. - const supported = this.rateLimit.supportsAction(options.action); - if (supported) { - if (options.ip && options.email) { - options.ip_email = `${options.ip}_${options.email}`; - } - if (options.ip && options.uid) { - options.ip_uid = `${options.ip}_${options.uid}`; - } - - response = await this.checkRateLimit(options); - } else { - // TODO: Remove legacy calls to customs. FXA-11635 - // If the customs service wasn't configured, short circuit. - if (!this.customsUrl || this.customsUrl === 'none') { - return response; - } - response = await this.checkCustomsService(options); - } - - if (response.block) { - if (response.retryAfter) { - const extraData: any = { - // Not using pascal case to maintain backwards compat with auth-server - 'retry-after': response.retryAfter, - }; - - // Respect user's preferred locale - if (options.acceptLanguage) { - const retryAfterLocalized = this.l10nTimestampFormatter.format( - Date.now() + response.retryAfter, - options.acceptLanguage - ); - extraData.retryAfterLocalized = retryAfterLocalized; - } - - // If the response, can be unblocked, signal these options. Again, this maintains - // backward compatibility with auth server. - if (response.unblock) { - extraData.verificationMethod = 'email-captcha'; - extraData.verificationReason = 'login'; - } - - throw new GraphQLError('Client has sent too many requests', { - extensions: { - code: 429, - error: 'Too Many Requests', - errno: 114, - ...extraData, - }, - }); - } - - // TODO: Remove legacy calls to customs. FXA-11635 - // Note that for the v2 rate limiter, we always return a retry after! So the following is no longer needed. - const errorStr = 'The request was blocked for security reasons'; - throw new BadRequestException( - { error: 'Request blocked', errno: 125, code: 400, message: errorStr }, - errorStr - ); - } - - return response; - } - - private async checkRateLimit(options: CheckOptions): Promise { - const { action, ip, email, uid, ip_email, ip_uid } = options; - - // Check if we can ignore the user - const skip = this.rateLimit.skip({ - ip, - email, - uid, - }); - if (skip) { - this.statsd.increment( - `customs.check.v2.skip`, - [ip ? 'ip' : '', email ? 'email' : '', uid ? 'uid' : ''].filter( - (x) => !!x - ) - ); - return { block: false }; - } - - // Run the rate limit check. If the response is null, we do not block. - this.statsd.increment(`customs.check.v2`, [`action:${action}`]); - const result = await this.rateLimit.check(action, { - ip, - email, - uid, - ip_email, - ip_uid, - }); - this.log.debug('customs', { - msg: `Rate Limiting checked`, - ip, - email, - uid, - action, - blocked: result !== null, - }); - - this.statsd.increment( - `customs.request.v2.check`, - [ - action, - result != null ? 'blocked' : '', - result?.reason ? `blockReason:${result.reason}` : '', - ].filter((x) => !!x) - ); - - if (result == null) { - return { block: false }; - } - - // We use the rate limiter to allow X number unblock attempts per day. Once - // unblock attempts have been exhausted, the user cannot request an unblock - // code and must wait until the unblockEmail ban duration has expired. Similar - // logic existed in the old customs server, but these sorts of decisions are - // actually domain of the service using customs and not customs itself, so - // this is the revised approach. - let canUnblock = false; - if ( - ip_email && - ip && - email && - this.rateLimit.supportsAction('unblockEmail') - ) { - const unblockResult = await this.rateLimit.check('unblockEmail', { - ip, - email, - uid, - ip_email, - ip_uid, - }); - canUnblock = unblockResult == null; - } - - return { - block: true, - unblock: canUnblock, - retryAfter: result.retryAfter, - }; - } - - private async checkCustomsService(options: CheckOptions) { - // Record stat so we can monitor conversion from v1 to v2 - this.statsd.increment(`customs.check.v1`, [`action:${options.action}`]); - - const result = await superagent - .post(this.customsUrl + '/check') - .send(options) - .ok((res) => res.status < 600); - - if (result.status < 200 || result.status >= 300) { - throw new Error('Customs server failed to respond as expected.'); - } - const response = result.body as CheckResponse; - - this.log.debug('customs', { - msg: `Customs service checked`, - ...options, - ...response, - }); - - return response; - } -} diff --git a/libs/shared/nestjs/customs/tsconfig.json b/libs/shared/nestjs/customs/tsconfig.json deleted file mode 100644 index 4022fd4d0ad..00000000000 --- a/libs/shared/nestjs/customs/tsconfig.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "extends": "../../../../tsconfig.base.json", - "compilerOptions": { - "module": "commonjs", - "forceConsistentCasingInFileNames": true, - "strict": true, - "noImplicitOverride": true, - "noPropertyAccessFromIndexSignature": true, - "noImplicitReturns": true, - "noFallthroughCasesInSwitch": true - }, - "files": [], - "include": [], - "references": [ - { - "path": "./tsconfig.lib.json" - }, - { - "path": "./tsconfig.spec.json" - } - ] -} diff --git a/libs/shared/nestjs/customs/tsconfig.lib.json b/libs/shared/nestjs/customs/tsconfig.lib.json deleted file mode 100644 index 18f2d37a19a..00000000000 --- a/libs/shared/nestjs/customs/tsconfig.lib.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "../../../../dist/out-tsc", - "declaration": true, - "types": ["node"] - }, - "include": ["src/**/*.ts"], - "exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"] -} diff --git a/libs/shared/nestjs/customs/tsconfig.spec.json b/libs/shared/nestjs/customs/tsconfig.spec.json deleted file mode 100644 index 6668655fc39..00000000000 --- a/libs/shared/nestjs/customs/tsconfig.spec.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "../../../../dist/out-tsc", - "module": "commonjs", - "types": ["jest", "node"] - }, - "include": [ - "jest.config.ts", - "src/**/*.test.ts", - "src/**/*.spec.ts", - "src/**/*.d.ts" - ] -} diff --git a/libs/shared/notifier/project.json b/libs/shared/notifier/project.json index f0acd5c3064..8e013d90245 100644 --- a/libs/shared/notifier/project.json +++ b/libs/shared/notifier/project.json @@ -6,36 +6,26 @@ "tags": [], "targets": { "build": { - "executor": "@nx/esbuild:esbuild", + "dependsOn": ["build-ts"], + "executor": "nx:run-commands", + "options": { + "command": "echo Build complete" + } + }, + "build-ts": { + "executor": "@nx/js:tsc", "outputs": ["{options.outputPath}"], - "defaultConfiguration": "production", "options": { "main": "libs/shared/notifier/src/index.ts", "outputPath": "dist/libs/shared/notifier", - "outputFileName": "main.js", "tsConfig": "libs/shared/notifier/tsconfig.lib.json", - "declaration": true, - "external": [ - "@nestjs/websockets/socket-module", - "@nestjs/microservices/microservices-module", - "@nestjs/microservices" - ], "assets": [ { "glob": "libs/shared/notifier/README.md", "input": ".", "output": "." } - ], - "platform": "node" - }, - "configurations": { - "development": { - "minify": false - }, - "production": { - "minify": true - } + ] } }, "lint": { diff --git a/libs/shared/otel/project.json b/libs/shared/otel/project.json index 67916bf7d7d..7deaabb0264 100644 --- a/libs/shared/otel/project.json +++ b/libs/shared/otel/project.json @@ -6,15 +6,21 @@ "tags": [], "targets": { "build": { - "executor": "@nx/esbuild:esbuild", + "dependsOn": ["build-ts"], + "executor": "nx:run-commands", + "options": { + "command": "echo Build complete" + } + }, + "build-ts": { + "executor": "@nx/js:tsc", "outputs": ["{options.outputPath}"], "options": { "outputPath": "dist/libs/shared/otel", "main": "libs/shared/otel/src/index.ts", "tsConfig": "libs/shared/otel/tsconfig.lib.json", "assets": ["libs/shared/otel/*.md"], - "declaration": true, - "platform": "node" + "generatePackageJson": true } }, "test-unit": { diff --git a/libs/shared/otp/project.json b/libs/shared/otp/project.json index bf78883db2b..5801db3fa8a 100644 --- a/libs/shared/otp/project.json +++ b/libs/shared/otp/project.json @@ -6,31 +6,26 @@ "tags": [], "targets": { "build": { - "executor": "@nx/esbuild:esbuild", + "dependsOn": ["build-ts"], + "executor": "nx:run-commands", + "options": { + "command": "echo Build complete" + } + }, + "build-ts": { + "executor": "@nx/js:tsc", "outputs": ["{options.outputPath}"], - "defaultConfiguration": "production", "options": { "main": "libs/shared/otp/src/index.ts", "outputPath": "dist/libs/shared/otp", - "outputFileName": "main.js", "tsConfig": "libs/shared/otp/tsconfig.lib.json", - "declaration": true, "assets": [ { "glob": "libs/shared/otp/README.md", "input": ".", "output": "." } - ], - "platform": "node" - }, - "configurations": { - "development": { - "minify": false - }, - "production": { - "minify": true - } + ] } }, "test-unit": { diff --git a/libs/shared/pem-jwk/project.json b/libs/shared/pem-jwk/project.json index 93704d09ee2..25173bce781 100644 --- a/libs/shared/pem-jwk/project.json +++ b/libs/shared/pem-jwk/project.json @@ -6,32 +6,26 @@ "tags": [], "targets": { "build": { - "executor": "@nx/esbuild:esbuild", + "dependsOn": ["build-ts"], + "executor": "nx:run-commands", + "options": { + "command": "echo Build complete" + } + }, + "build-ts": { + "executor": "@nx/js:tsc", "outputs": ["{options.outputPath}"], - "defaultConfiguration": "production", "options": { "main": "libs/shared/pem-jwk/src/index.ts", "outputPath": "dist/libs/shared/pem-jwk", - "outputFileName": "main.js", "tsConfig": "libs/shared/pem-jwk/tsconfig.lib.json", - "declaration": true, "assets": [ { "glob": "libs/shared/pem-jwk/README.md", "input": ".", "output": "." } - ], - "platform": "node", - "format": ["cjs", "esm"] - }, - "configurations": { - "development": { - "minify": false - }, - "production": { - "minify": true - } + ] } }, "test-unit": { diff --git a/libs/shared/react/project.json b/libs/shared/react/project.json index 42a3602c6d3..7ad10d30282 100644 --- a/libs/shared/react/project.json +++ b/libs/shared/react/project.json @@ -6,6 +6,13 @@ "tags": [], "targets": { "build": { + "dependsOn": ["build-ts"], + "executor": "nx:run-commands", + "options": { + "command": "echo Build complete" + } + }, + "build-ts": { "executor": "@nx/js:tsc", "outputs": ["{options.outputPath}"], "options": { diff --git a/libs/shared/sentry-browser/package.json b/libs/shared/sentry-browser/package.json index 01e83c4837f..4aab946b116 100644 --- a/libs/shared/sentry-browser/package.json +++ b/libs/shared/sentry-browser/package.json @@ -1,8 +1,4 @@ { "name": "@fxa/shared/sentry-browser", - "version": "0.0.1", - "dependencies": {}, - "type": "commonjs", - "main": "./index.cjs", - "private": true + "version": "0.0.1" } diff --git a/libs/shared/sentry-browser/project.json b/libs/shared/sentry-browser/project.json index 221ce77e56a..2d6c013c74d 100644 --- a/libs/shared/sentry-browser/project.json +++ b/libs/shared/sentry-browser/project.json @@ -6,14 +6,21 @@ "tags": ["scope:shared:lib"], "targets": { "build": { - "executor": "@nx/esbuild:esbuild", + "dependsOn": ["build-ts"], + "executor": "nx:run-commands", + "options": { + "command": "echo Build complete" + } + }, + "build-ts": { + "executor": "@nx/js:tsc", "outputs": ["{options.outputPath}"], "options": { "outputPath": "dist/libs/shared/sentry-browser", "main": "libs/shared/sentry-browser/src/index.ts", "tsConfig": "libs/shared/sentry-browser/tsconfig.lib.json", "assets": ["libs/shared/sentry-browser/*.md"], - "format": ["cjs"] + "generatePackageJson": true } }, "test-unit": { diff --git a/libs/shared/sentry-nest/package.json b/libs/shared/sentry-nest/package.json index 2edc7f50612..64a1c31ca13 100644 --- a/libs/shared/sentry-nest/package.json +++ b/libs/shared/sentry-nest/package.json @@ -1,8 +1,4 @@ { "name": "@fxa/shared/sentry-nest", - "version": "0.0.1", - "dependencies": {}, - "type": "commonjs", - "main": "./index.cjs", - "private": true + "version": "0.0.1" } diff --git a/libs/shared/sentry-nest/project.json b/libs/shared/sentry-nest/project.json index 62995b8ed65..e05bef50fae 100644 --- a/libs/shared/sentry-nest/project.json +++ b/libs/shared/sentry-nest/project.json @@ -6,14 +6,21 @@ "tags": ["scope:shared:lib"], "targets": { "build": { - "executor": "@nx/esbuild:esbuild", + "dependsOn": ["build-ts"], + "executor": "nx:run-commands", + "options": { + "command": "echo Build complete" + } + }, + "build-ts": { + "executor": "@nx/js:tsc", "outputs": ["{options.outputPath}"], "options": { "outputPath": "dist/libs/shared/sentry-nest", "main": "libs/shared/sentry-nest/src/index.ts", "tsConfig": "libs/shared/sentry-nest/tsconfig.lib.json", "assets": ["libs/shared/sentry-nest/*.md"], - "format": ["cjs"] + "generatePackageJson": true } }, "test-unit": { diff --git a/libs/shared/sentry-next/package.json b/libs/shared/sentry-next/package.json index 3a7fa353c82..454aa639fb0 100644 --- a/libs/shared/sentry-next/package.json +++ b/libs/shared/sentry-next/package.json @@ -1,8 +1,4 @@ { "name": "@fxa/shared/sentry-next", - "version": "0.0.1", - "dependencies": {}, - "type": "commonjs", - "main": "./index.cjs", - "private": true + "version": "0.0.1" } diff --git a/libs/shared/sentry-next/project.json b/libs/shared/sentry-next/project.json index 3c9b27f34a8..31ebbd9ccfd 100644 --- a/libs/shared/sentry-next/project.json +++ b/libs/shared/sentry-next/project.json @@ -6,14 +6,21 @@ "tags": ["scope:shared:lib"], "targets": { "build": { - "executor": "@nx/esbuild:esbuild", + "dependsOn": ["build-ts"], + "executor": "nx:run-commands", + "options": { + "command": "echo Build complete" + } + }, + "build-ts": { + "executor": "@nx/js:tsc", "outputs": ["{options.outputPath}"], "options": { "outputPath": "dist/libs/shared/sentry-next", "main": "libs/shared/sentry-next/src/index.ts", "tsConfig": "libs/shared/sentry-next/tsconfig.lib.json", "assets": ["libs/shared/sentry-next/*.md"], - "format": ["cjs"] + "generatePackageJson": true } }, "test-unit": { diff --git a/libs/shared/sentry-node/package.json b/libs/shared/sentry-node/package.json index e171c04c158..ce087b8577e 100644 --- a/libs/shared/sentry-node/package.json +++ b/libs/shared/sentry-node/package.json @@ -1,8 +1,4 @@ { "name": "@fxa/shared/sentry-node", - "version": "0.0.1", - "dependencies": {}, - "type": "commonjs", - "main": "./index.cjs", - "private": true + "version": "0.0.1" } diff --git a/libs/shared/sentry-node/project.json b/libs/shared/sentry-node/project.json index 17bc52aded5..3317d9d95a7 100644 --- a/libs/shared/sentry-node/project.json +++ b/libs/shared/sentry-node/project.json @@ -6,14 +6,21 @@ "tags": ["scope:shared:lib"], "targets": { "build": { - "executor": "@nx/esbuild:esbuild", + "dependsOn": ["build-ts"], + "executor": "nx:run-commands", + "options": { + "command": "echo Build complete" + } + }, + "build-ts": { + "executor": "@nx/js:tsc", "outputs": ["{options.outputPath}"], "options": { "outputPath": "dist/libs/shared/sentry-node", "main": "libs/shared/sentry-node/src/index.ts", "tsConfig": "libs/shared/sentry-node/tsconfig.lib.json", "assets": ["libs/shared/sentry-node/*.md"], - "format": ["cjs"] + "generatePackageJson": true } }, "test-unit": { diff --git a/libs/shared/sentry-utils/package.json b/libs/shared/sentry-utils/package.json index 1a8293c67b0..93c4df10f91 100644 --- a/libs/shared/sentry-utils/package.json +++ b/libs/shared/sentry-utils/package.json @@ -1,8 +1,4 @@ { "name": "@fxa/shared/sentry-utils", - "version": "0.0.1", - "dependencies": {}, - "type": "commonjs", - "main": "./index.cjs", - "private": true + "version": "0.0.1" } diff --git a/libs/shared/sentry-utils/project.json b/libs/shared/sentry-utils/project.json index 06dcb58a9eb..f45f5ebe0d2 100644 --- a/libs/shared/sentry-utils/project.json +++ b/libs/shared/sentry-utils/project.json @@ -6,14 +6,20 @@ "tags": ["scope:shared:lib"], "targets": { "build": { - "executor": "@nx/esbuild:esbuild", + "dependsOn": ["build-ts"], + "executor": "nx:run-commands", + "options": { + "command": "echo Build complete" + } + }, + "build-ts": { + "executor": "@nx/js:tsc", "outputs": ["{options.outputPath}"], "options": { "outputPath": "dist/libs/shared/sentry-utils", "main": "libs/shared/sentry-utils/src/index.ts", "tsConfig": "libs/shared/sentry-utils/tsconfig.lib.json", - "assets": ["libs/shared/sentry-utils/*.md"], - "format": ["cjs"] + "assets": ["libs/shared/sentry-utils/*.md"] } }, "test-unit": { diff --git a/libs/shared/sentry/project.json b/libs/shared/sentry/project.json index 5278bb2a734..f7987b90c9b 100644 --- a/libs/shared/sentry/project.json +++ b/libs/shared/sentry/project.json @@ -6,39 +6,26 @@ "tags": [], "targets": { "build": { - "executor": "@nx/esbuild:esbuild", + "dependsOn": ["build-ts"], + "executor": "nx:run-commands", + "options": { + "command": "echo Build complete" + } + }, + "build-ts": { + "executor": "@nx/js:tsc", "outputs": ["{options.outputPath}"], - "defaultConfiguration": "production", "options": { "main": "libs/shared/sentry/src/index.ts", "outputPath": "dist/libs/shared/sentry", - "outputFileName": "main.js", "tsConfig": "libs/shared/sentry/tsconfig.lib.json", - "declaration": true, - "external": [ - "@apollo/gateway", - "@apollo/subgraph", - "@as-integrations/fastify", - "@nestjs/websockets/socket-module", - "@nestjs/microservices/microservices-module", - "@nestjs/microservices" - ], "assets": [ { "glob": "libs/shared/sentry/README.md", "input": ".", "output": "." } - ], - "platform": "node" - }, - "configurations": { - "development": { - "minify": false - }, - "production": { - "minify": true - } + ] } }, "lint": { diff --git a/libs/vendored/common-password-list/project.json b/libs/vendored/common-password-list/project.json index 1af294361df..3fed226ccab 100644 --- a/libs/vendored/common-password-list/project.json +++ b/libs/vendored/common-password-list/project.json @@ -6,31 +6,26 @@ "tags": [], "targets": { "build": { - "executor": "@nx/esbuild:esbuild", + "dependsOn": ["build-ts"], + "executor": "nx:run-commands", + "options": { + "command": "echo Build complete" + } + }, + "build-ts": { + "executor": "@nx/js:tsc", "outputs": ["{options.outputPath}"], - "defaultConfiguration": "production", "options": { "main": "libs/vendored/common-password-list/src/index.ts", "outputPath": "dist/libs/vendored/common-password-list", - "outputFileName": "main.js", "tsConfig": "libs/vendored/common-password-list/tsconfig.lib.json", - "declaration": true, "assets": [ { "glob": "libs/vendored/common-password-list/README.md", "input": ".", "output": "." } - ], - "platform": "node" - }, - "configurations": { - "development": { - "minify": false - }, - "production": { - "minify": true - } + ] } }, "test-unit": { diff --git a/libs/vendored/crypto-relier/project.json b/libs/vendored/crypto-relier/project.json index b2f123fdeca..f7aebabc949 100644 --- a/libs/vendored/crypto-relier/project.json +++ b/libs/vendored/crypto-relier/project.json @@ -6,32 +6,26 @@ "tags": [], "targets": { "build": { - "executor": "@nx/esbuild:esbuild", + "dependsOn": ["build-ts"], + "executor": "nx:run-commands", + "options": { + "command": "echo Build complete" + } + }, + "build-ts": { + "executor": "@nx/js:tsc", "outputs": ["{options.outputPath}"], - "defaultConfiguration": "production", "options": { "main": "libs/vendored/crypto-relier/src/index.ts", "outputPath": "dist/libs/vendored/crypto-relier", - "outputFileName": "main.js", "tsConfig": "libs/vendored/crypto-relier/tsconfig.lib.json", - "declaration": true, "assets": [ { "glob": "libs/vendored/crypto-relier/README.md", "input": ".", "output": "." } - ], - "platform": "node", - "format": ["cjs", "esm"] - }, - "configurations": { - "development": { - "minify": false - }, - "production": { - "minify": true - } + ] } }, "test": { diff --git a/libs/vendored/incremental-encoder/project.json b/libs/vendored/incremental-encoder/project.json index 0a84e392f1f..743a3de4778 100644 --- a/libs/vendored/incremental-encoder/project.json +++ b/libs/vendored/incremental-encoder/project.json @@ -6,31 +6,26 @@ "tags": [], "targets": { "build": { - "executor": "@nx/esbuild:esbuild", + "dependsOn": ["build-ts"], + "executor": "nx:run-commands", + "options": { + "command": "echo Build complete" + } + }, + "build-ts": { + "executor": "@nx/js:tsc", "outputs": ["{options.outputPath}"], - "defaultConfiguration": "production", "options": { "main": "libs/vendored/incremental-encoder/src/index.ts", "outputPath": "dist/libs/vendored/incremental-encoder", - "outputFileName": "main.js", "tsConfig": "libs/vendored/incremental-encoder/tsconfig.lib.json", - "declaration": true, "assets": [ { "glob": "libs/vendored/incremental-encoder/README.md", "input": ".", "output": "." } - ], - "platform": "node" - }, - "configurations": { - "development": { - "minify": false - }, - "production": { - "minify": true - } + ] } }, "test-unit": { diff --git a/libs/vendored/jwtool/project.json b/libs/vendored/jwtool/project.json index 7bd9c8c5ef0..ff7cb55cf21 100644 --- a/libs/vendored/jwtool/project.json +++ b/libs/vendored/jwtool/project.json @@ -6,32 +6,26 @@ "tags": [], "targets": { "build": { - "executor": "@nx/esbuild:esbuild", + "dependsOn": ["build-ts"], + "executor": "nx:run-commands", + "options": { + "command": "echo Build complete" + } + }, + "build-ts": { + "executor": "@nx/js:tsc", "outputs": ["{options.outputPath}"], - "defaultConfiguration": "production", "options": { "main": "libs/vendored/jwtool/src/index.ts", "outputPath": "dist/libs/vendored/jwtool", - "outputFileName": "main.js", "tsConfig": "libs/vendored/jwtool/tsconfig.lib.json", - "declaration": true, "assets": [ { "glob": "libs/vendored/jwtool/README.md", "input": ".", "output": "." } - ], - "platform": "node", - "format": ["cjs", "esm"] - }, - "configurations": { - "development": { - "minify": false - }, - "production": { - "minify": true - } + ] } }, "test-unit": { diff --git a/libs/vendored/typesafe-node-firestore/project.json b/libs/vendored/typesafe-node-firestore/project.json index 732adbc9193..2fb64d0992c 100644 --- a/libs/vendored/typesafe-node-firestore/project.json +++ b/libs/vendored/typesafe-node-firestore/project.json @@ -6,31 +6,26 @@ "tags": [], "targets": { "build": { - "executor": "@nx/esbuild:esbuild", + "dependsOn": ["build-ts"], + "executor": "nx:run-commands", + "options": { + "command": "echo Build complete" + } + }, + "build-ts": { + "executor": "@nx/js:tsc", "outputs": ["{options.outputPath}"], - "defaultConfiguration": "production", "options": { "main": "libs/vendored/typesafe-node-firestore/src/index.ts", "outputPath": "dist/libs/vendored/typesafe-node-firestore", - "outputFileName": "main.js", "tsConfig": "libs/vendored/typesafe-node-firestore/tsconfig.lib.json", - "declaration": true, "assets": [ { "glob": "libs/vendored/typesafe-node-firestore/README.md", "input": ".", "output": "." } - ], - "platform": "node" - }, - "configurations": { - "development": { - "minify": false - }, - "production": { - "minify": true - } + ] } }, "test": {