Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions libs/payments/email/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": ["../../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}
14 changes: 14 additions & 0 deletions libs/payments/email/.swcrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"jsc": {
"target": "es2017",
"parser": {
"syntax": "typescript",
"decorators": true,
"dynamicImport": true
},
"transform": {
"decoratorMetadata": true,
"legacyDecorator": true
}
}
}
11 changes: 11 additions & 0 deletions libs/payments/email/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# email

This library was generated with [Nx](https://nx.dev).

## Building

Run `nx build payments-email` to build the library.

## Running unit tests

Run `nx test payments-email` to execute the unit tests via [Jest](https://jestjs.io).
43 changes: 43 additions & 0 deletions libs/payments/email/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/* eslint-disable */
import { readFileSync } from 'fs';
import { Config } from 'jest';

// Reading the SWC compilation config and remove the "exclude"
// for the test files to be compiled by SWC
const { exclude: _, ...swcJestConfig } = JSON.parse(
readFileSync(`${__dirname}/.swcrc`, 'utf-8')
);

// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves.
// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude"
if (swcJestConfig.swcrc === undefined) {
swcJestConfig.swcrc = false;
}

// Uncomment if using global setup/teardown files being transformed via swc
// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries
// jest needs EsModule Interop to find the default exported setup/teardown functions
// swcJestConfig.module.noInterop = false;

const config: Config = {
displayName: 'payments-email',
preset: '../../../jest.preset.js',
transform: {
'^.+\\.[tj]s$': ['@swc/jest', swcJestConfig],
},
moduleFileExtensions: ['ts', 'js', 'html'],
testEnvironment: 'node',
coverageDirectory: '../../../coverage/libs/payments/email',
reporters: [
'default',
[
'jest-junit',
{
outputDirectory: 'artifacts/tests/payments-email',
outputName: 'payments-email-jest-unit-results.xml',
},
],
],
};

export default config;
4 changes: 4 additions & 0 deletions libs/payments/email/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "@fxa/payments/email",
"version": "0.0.1"
}
51 changes: 51 additions & 0 deletions libs/payments/email/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"name": "payments-email",
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "libs/payments/email/src",
"projectType": "library",
"tags": ["scope:shared:lib:payments"],
"targets": {
"build": {
"executor": "@nx/esbuild:esbuild",
"outputs": ["{options.outputPath}"],
"defaultConfiguration": "production",
"options": {
"main": "libs/payments/email/src/index.ts",
"outputPath": "dist/libs/payments/email",
"outputFileName": "main.js",
"tsConfig": "libs/payments/email/tsconfig.lib.json",
"declaration": true,
"assets": [
{
"glob": "libs/payments/email/README.md",
"input": ".",
"output": "."
}
],
"platform": "node"
},
"configurations": {
"development": {
"minify": false
},
"production": {
"minify": true
}
}
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["libs/payments/email/**/*.ts"]
}
},
"test-unit": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "libs/payments/email/jest.config.ts"
}
}
}
}
5 changes: 5 additions & 0 deletions libs/payments/email/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/* 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 * from './lib/emailTemplate.manager';
29 changes: 29 additions & 0 deletions libs/payments/email/src/lib/emailTemplate.error.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/* 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 { BaseError } from '@fxa/shared/error';

/**
* EmailTemplateError is not intended for direct use, except for type-checking errors.
* When throwing a new EmailTemplateError, create a unique extension of the class.
*/
export class EmailTemplateError extends BaseError {
constructor(message: string, info: Record<string, any>, cause?: Error) {
super(message, {
info,
cause,
});
this.name = 'EmailTemplateError';
}
}

export class EmailTemplateRetrieveComponentError extends EmailTemplateError {
constructor(path: string, name: string) {
super(`Failed to retrieve email component ${name} from path: ${path}`, {
path,
name,
});
this.name = 'EmailTemplateRetrieveComponentError';
}
}
Loading