Skip to content

Commit

Permalink
feat(esm): moving all lambdas to esm (#1003)
Browse files Browse the repository at this point in the history
* feat(esm): moving account data deleter batch delete to esm

* feat(esm): moving account data deleter events to esm

* feat(esm): moving account delete monitor

* feat(esm): moving user list search indexing to esm

* feat(esm): moving annotations api events to esm

* feat(esm): moving fxa webhook proxy gateway to esm

* feat(esm): moving fxa webhook proxy sqs to esm

* feat(esm): moving instant sync events to esm

* feat(esm): moving sendgrid data to esm

* feat(esm): moving shareable lists to esm

* feat(esm): moving transactional emails to esm

* feat(esm): moving user list search corpus indexing to esm

* feat(esm): moving user list search corpus to esm

* feat(esm): moving user list search events to esm

* feat(esm): moving user list search kinesis to esm

* fix(esm): small lambda esm fixes

* fix(esm): updating jest to support esm

* fix(tests): ensure all tests pass
  • Loading branch information
bassrock authored Jan 6, 2025
1 parent 11c8b60 commit 862e48c
Show file tree
Hide file tree
Showing 177 changed files with 513 additions and 371 deletions.
9 changes: 0 additions & 9 deletions lambdas/account-data-deleter-batch-delete/jest.config.js

This file was deleted.

17 changes: 17 additions & 0 deletions lambdas/account-data-deleter-batch-delete/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import type { Config } from 'jest';

const config: Config = {
preset: 'ts-jest',
testEnvironment: 'node',
testMatch: ['**/?(*.)+(spec|integration).ts'],
testPathIgnorePatterns: ['/dist/'],
setupFiles: ['./jest.setup.ts'],
displayName: 'lambda-batchdelete',
testTimeout: 1000000,
moduleNameMapper: {
"^(\\.\\/.+)\\.js$": "$1",
"^(\\..\\/.+)\\.js$": "$1"
},
};

export default config;
1 change: 1 addition & 0 deletions lambdas/account-data-deleter-batch-delete/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"description": "",
"license": "ISC",
"author": "",
"type": "module",
"main": "dist/index.js",
"files": [
"dist",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { DynamoDBClient } from '@aws-sdk/client-dynamodb';
import { DynamoDBDocumentClient } from '@aws-sdk/lib-dynamodb';
import { BatchGetCommand } from '@aws-sdk/lib-dynamodb';
import { config } from './config';
import { BatchDeleteDyanmoClient } from './dynamoUtils';
import { seedData, truncateTable } from './test/utils';
import { config } from './config.ts';
import { BatchDeleteDyanmoClient } from './dynamoUtils.ts';
import { seedData, truncateTable } from './test/utils.ts';

describe('Data fetcher', () => {
const client = new DynamoDBClient({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { config } from './config';
import { config } from './config.ts';
import {
BatchWriteCommand,
BatchWriteCommandInput,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { config } from '../config';
import { deleteUserMutationCaller, userApiCalls } from './deleteMutation';
import { config } from '../config.ts';
import { deleteUserMutationCaller, userApiCalls } from './deleteMutation.ts';
import nock from 'nock';

describe('deleteUser mutation test', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { backOff } from 'exponential-backoff';
import { config } from '../config';
import { config } from '../config.ts';

/**
* Function that establishes the number of back off attempts
Expand Down
8 changes: 4 additions & 4 deletions lambdas/account-data-deleter-batch-delete/src/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { BatchDeleteDyanmoClient } from './dynamoUtils';
import { BatchDeleteDyanmoClient } from './dynamoUtils.ts';
import { DynamoDBClient } from '@aws-sdk/client-dynamodb';
import { config } from './config';
import * as DeleteMutation from './externalCaller/deleteMutation';
import { deleteUsers } from './index';
import { config } from './config.ts';
import * as DeleteMutation from './externalCaller/deleteMutation.ts';
import { deleteUsers } from './index.ts';
import * as Sentry from '@sentry/aws-serverless';

describe('deleteUsers spec test', () => {
Expand Down
6 changes: 3 additions & 3 deletions lambdas/account-data-deleter-batch-delete/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { config } from './config';
import { config } from './config.ts';
import * as Sentry from '@sentry/aws-serverless';
import { serverLogger } from '@pocket-tools/ts-logger';

Expand All @@ -11,9 +11,9 @@ Sentry.init({
});

import { EventBridgeEvent } from 'aws-lambda';
import { BatchDeleteDyanmoClient } from './dynamoUtils';
import { BatchDeleteDyanmoClient } from './dynamoUtils.ts';
import { DynamoDBClient } from '@aws-sdk/client-dynamodb';
import { deleteUserMutationCaller } from './externalCaller/deleteMutation';
import { deleteUserMutationCaller } from './externalCaller/deleteMutation.ts';

const dynamoDBClient = new DynamoDBClient({
region: config.aws.region,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from '@aws-sdk/lib-dynamodb';

import { chunk } from 'lodash';
import { config } from '../config';
import { config } from '../config.ts';

/**
* Seed data of consecutive stringified integers, hash key only
Expand Down
2 changes: 1 addition & 1 deletion lambdas/account-data-deleter-batch-delete/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"outDir": "dist",
"rootDir": "src"
},
"exclude": ["node_modules", "jest.config.js", "jest.setup.js"],
"exclude": ["node_modules", "jest.config.ts", "jest.setup.ts"],
"include": [
"src/**/*.ts",
]
Expand Down
8 changes: 0 additions & 8 deletions lambdas/account-data-deleter-events/jest.config.js

This file was deleted.

16 changes: 16 additions & 0 deletions lambdas/account-data-deleter-events/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import type { Config } from 'jest';

const config: Config = {
preset: 'ts-jest',
testEnvironment: 'node',
testMatch: ['**/?(*.)+(spec|integration).ts'],
testPathIgnorePatterns: ['/dist/'],
setupFiles: ['./jest.setup.ts'],
displayName: 'lambda-events',
moduleNameMapper: {
"^(\\.\\/.+)\\.js$": "$1",
"^(\\..\\/.+)\\.js$": "$1"
},
};

export default config;
1 change: 1 addition & 0 deletions lambdas/account-data-deleter-events/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"description": "",
"license": "ISC",
"author": "",
"type": "module",
"main": "dist/index.js",
"files": [
"dist",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { config } from '../../config';
import { config } from '../../config.ts';
import nock from 'nock';
import { accountDeleteHandler } from './';
import { callQueueDeleteEndpoint } from './postRequest';
import { accountDeleteHandler } from './index.ts';
import { callQueueDeleteEndpoint } from './postRequest.ts';
import { SQSRecord } from 'aws-lambda';

describe('accountDelete handler', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { AccountDeleteEvent } from '../../schemas/accountDeleteEvent';
import { AccountDeleteEvent } from '../../schemas/accountDeleteEvent.ts';
import {
callQueueDeleteEndpoint,
callStripeDeleteEndpoint,
} from './postRequest';
} from './postRequest.ts';
import { SQSRecord } from 'aws-lambda';
import { AggregateError } from '../../errors/AggregateError';
import { AggregateError } from '../../errors/AggregateError.ts';

type AccountDeleteBody = {
userId: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import fetchRetry from 'fetch-retry';
import { config } from '../../config';
import { config } from '../../config.ts';

const newFetch = fetchRetry(fetch);

Expand Down
2 changes: 1 addition & 1 deletion lambdas/account-data-deleter-events/src/handlers/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SQSRecord } from 'aws-lambda';
import { accountDeleteHandler } from './accountDelete';
import { accountDeleteHandler } from './accountDelete/index.ts';

export enum Event {
ACCOUNT_DELETION = 'account-deletion',
Expand Down
4 changes: 2 additions & 2 deletions lambdas/account-data-deleter-events/src/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Event, handlers } from './handlers';
import { handlerFn } from './index';
import { Event, handlers } from './handlers/index.ts';
import { handlerFn } from './index.ts';
import { SQSEvent } from 'aws-lambda';
import * as Sentry from '@sentry/aws-serverless';

Expand Down
4 changes: 2 additions & 2 deletions lambdas/account-data-deleter-events/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { config } from './config';
import { config } from './config.ts';
import * as Sentry from '@sentry/aws-serverless';
Sentry.init({
dsn: config.sentry.dsn,
Expand All @@ -7,7 +7,7 @@ Sentry.init({
serverName: config.app.name,
});
import { SQSBatchItemFailure, SQSEvent } from 'aws-lambda';
import { handlers } from './handlers';
import { handlers } from './handlers/index.ts';
import { serverLogger } from '@pocket-tools/ts-logger';

export async function handlerFn(event: SQSEvent): Promise<any> {
Expand Down
2 changes: 1 addition & 1 deletion lambdas/account-data-deleter-events/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"outDir": "dist",
"rootDir": "src"
},
"exclude": ["node_modules", "jest.config.js", "jest.setup.js"],
"exclude": ["node_modules", "jest.config.ts", "jest.setup.ts"],
"include": [
"src/**/*.ts",
]
Expand Down
8 changes: 0 additions & 8 deletions lambdas/account-delete-monitor/jest.config.js

This file was deleted.

16 changes: 16 additions & 0 deletions lambdas/account-delete-monitor/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import type { Config } from 'jest';

const config: Config = {
preset: 'ts-jest',
testEnvironment: 'node',
testMatch: ['**/?(*.)+(spec|integration).ts'],
testPathIgnorePatterns: ['/dist/'],
displayName: 'account-delete-monitor',
setupFiles: ['./jest.setup.ts'],
moduleNameMapper: {
"^(\\.\\/.+)\\.js$": "$1",
"^(\\..\\/.+)\\.js$": "$1"
},
};

export default config;
1 change: 1 addition & 0 deletions lambdas/account-delete-monitor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"description": "",
"license": "ISC",
"author": "",
"type": "module",
"main": "dist/index.js",
"files": [
"dist",
Expand Down
2 changes: 1 addition & 1 deletion lambdas/account-delete-monitor/src/dynamodb.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DynamoDBClient, DynamoDBClientConfig } from '@aws-sdk/client-dynamodb';
import { DynamoDBDocumentClient } from '@aws-sdk/lib-dynamodb';
import { config } from './config';
import { config } from './config.ts';

/** Initialize outside of handler to follow best practices
* Note that TCP connection reuse is enabled by default in v3
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { config } from '../config';
import { deleteUserMutationCaller, userApiCalls } from './deleteMutation';
import { config } from '../config.ts';
import { deleteUserMutationCaller, userApiCalls } from './deleteMutation.ts';
import nock from 'nock';

describe('deleteUser mutation test', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { backOff } from 'exponential-backoff';
import { config } from '../config';
import { config } from '../config.ts';

/**
* Function that establishes the number of back off attempts
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { accountDeleteHandler } from './accountDeleteHandler';
import { accountDeleteHandler } from './accountDeleteHandler.ts';
import { SQSRecord } from 'aws-lambda';
import { client, dynamo } from '../dynamodb';
import { client, dynamo } from '../dynamodb.ts';
import { GetCommand, PutCommand } from '@aws-sdk/lib-dynamodb';
import { config } from '../config';
import * as deleteMutation from '../externalCaller/deleteMutation';
import { truncateTable } from '../test/utils';
import { config } from '../config.ts';
import * as deleteMutation from '../externalCaller/deleteMutation.ts';
import { truncateTable } from '../test/utils.ts';

describe('Account delete handler', () => {
const record = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { client } from '../dynamodb';
import { accountDeleteHandler } from './accountDeleteHandler';
import { client } from '../dynamodb.ts';
import { accountDeleteHandler } from './accountDeleteHandler.ts';
import { type SQSRecord } from 'aws-lambda';

describe('Account delete handler', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { SQSRecord } from 'aws-lambda';
import { client } from '../dynamodb';
import { client } from '../dynamodb.ts';
import { GetCommand, PutCommand } from '@aws-sdk/lib-dynamodb';
import { config } from '../config';
import { config } from '../config.ts';
// import { expirationTimestamp } from '../utils';
import { epochMsToIsoDate } from '../utils';
import { DeleteRequestModel } from '../types';
import { deleteUserMutationCaller } from '../externalCaller/deleteMutation';
import { epochMsToIsoDate } from '../utils.ts';
import { DeleteRequestModel } from '../types.ts';
import { deleteUserMutationCaller } from '../externalCaller/deleteMutation.ts';

/**
* Store the account deletion request in DynamoDB for tracking, and to
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { SQSRecord } from 'aws-lambda';
import { client, dynamo } from '../dynamodb';
import { client, dynamo } from '../dynamodb.ts';
import { GetCommand, PutCommand } from '@aws-sdk/lib-dynamodb';
import { config } from '../config';
import { accountMergeHandler } from './accountMergeHandler';
import { truncateTable } from '../test/utils';
import { config } from '../config.ts';
import { accountMergeHandler } from './accountMergeHandler.ts';
import { truncateTable } from '../test/utils.ts';

describe('Account merge handler', () => {
beforeEach(async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { client } from '../dynamodb';
import { accountMergeHandler } from './accountMergeHandler';
import { client } from '../dynamodb.ts';
import { accountMergeHandler } from './accountMergeHandler.ts';
import { type SQSRecord } from 'aws-lambda';

describe('Account merge handler', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { SQSRecord } from 'aws-lambda';
import { client } from '../dynamodb';
import { client } from '../dynamodb.ts';
import { UpdateCommand } from '@aws-sdk/lib-dynamodb';
import { config } from '../config';
import { config } from '../config.ts';
// import { expirationTimestamp } from '../utils';
import { UserMergeEvent } from '../types';
import { UserMergeEvent } from '../types.ts';

/**
* Store records to identify history of merged accounts.
Expand Down
4 changes: 2 additions & 2 deletions lambdas/account-delete-monitor/src/handlers/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SQSRecord } from 'aws-lambda';
import { accountDeleteHandler } from './accountDeleteHandler';
import { accountMergeHandler } from './accountMergeHandler';
import { accountDeleteHandler } from './accountDeleteHandler.ts';
import { accountMergeHandler } from './accountMergeHandler.ts';

export enum Event {
ACCOUNT_DELETION = 'account-deletion',
Expand Down
4 changes: 2 additions & 2 deletions lambdas/account-delete-monitor/src/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Event, handlers } from './handlers';
import { processor } from './index';
import { Event, handlers } from './handlers/index.ts';
import { processor } from './index.ts';
import { type SQSEvent } from 'aws-lambda';
import * as Sentry from '@sentry/aws-serverless';

Expand Down
4 changes: 2 additions & 2 deletions lambdas/account-delete-monitor/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { config } from './config';
import { config } from './config.ts';
import * as Sentry from '@sentry/aws-serverless';
Sentry.init({
dsn: config.sentry.dsn,
Expand All @@ -12,7 +12,7 @@ import type {
SQSBatchResponse,
SQSBatchItemFailure,
} from 'aws-lambda';
import { handlers } from './handlers';
import { handlers } from './handlers/index.ts';
import { serverLogger } from '@pocket-tools/ts-logger';

/**
Expand Down
2 changes: 1 addition & 1 deletion lambdas/account-delete-monitor/src/utils.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as utils from './utils';
import * as utils from './utils.ts';

describe('util functions', () => {
describe('epochMsToIsoDate', () => {
Expand Down
Loading

0 comments on commit 862e48c

Please sign in to comment.