diff --git a/.eslintrc b/.eslintrc index 7e6661d18..c62e1e291 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,5 +1,9 @@ { "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaVersion": "latest", + "sourceType": "module" + }, "plugins": ["import", "unused-imports"], "extends": [ "eslint:recommended", diff --git a/migration/1643962364050-seedProjectStatusreasons.ts b/migration/1643962364050-seedProjectStatusreasons.ts index 2241dc1e6..313518405 100644 --- a/migration/1643962364050-seedProjectStatusreasons.ts +++ b/migration/1643962364050-seedProjectStatusreasons.ts @@ -1,5 +1,5 @@ import { MigrationInterface, QueryRunner } from 'typeorm'; -import { ProjStatus } from '../src/entities/project'; +import { ProjStatus } from '../src/entities/project.js'; export class seedProjectStatusreasons1643962364050 implements MigrationInterface diff --git a/migration/1646303882607-seedTokes.ts b/migration/1646303882607-seedTokes.ts index 96dba53d5..fa1a2c313 100644 --- a/migration/1646303882607-seedTokes.ts +++ b/migration/1646303882607-seedTokes.ts @@ -1,7 +1,7 @@ import { MigrationInterface, QueryRunner } from 'typeorm'; -import { Token } from '../src/entities/token'; -import seedTokens from './data/seedTokens'; -import { ChainType } from '../src/types/network'; +import { Token } from '../src/entities/token.js'; +import seedTokens from './data/seedTokens.js'; +import { ChainType } from '../src/types/network.js'; export class seedTokes1646303882607 implements MigrationInterface { async up(queryRunner: QueryRunner): Promise { diff --git a/migration/1646305490859-seedOrganizations.ts b/migration/1646305490859-seedOrganizations.ts index 1ff391d95..5b841953f 100644 --- a/migration/1646305490859-seedOrganizations.ts +++ b/migration/1646305490859-seedOrganizations.ts @@ -1,5 +1,5 @@ import { MigrationInterface, QueryRunner } from 'typeorm'; -import { ORGANIZATION_LABELS } from '../src/entities/organization'; +import { ORGANIZATION_LABELS } from '../src/entities/organization.js'; const { GIVETH, TRACE, CHANGE } = ORGANIZATION_LABELS; diff --git a/migration/1647514950889-fixUpdatetAtOfProjects.ts b/migration/1647514950889-fixUpdatetAtOfProjects.ts index 2cbc3a482..f1173ead8 100644 --- a/migration/1647514950889-fixUpdatetAtOfProjects.ts +++ b/migration/1647514950889-fixUpdatetAtOfProjects.ts @@ -1,6 +1,5 @@ import { MigrationInterface, QueryRunner } from 'typeorm'; -// eslint-disable-next-line @typescript-eslint/no-var-requires -const moment = require('moment'); +import moment from 'moment'; export class fixUpdatetAtOfProjects1647514950889 implements MigrationInterface { async up(queryRunner: QueryRunner): Promise { diff --git a/migration/1648066794387-addChangeAcceptedtokens.ts b/migration/1648066794387-addChangeAcceptedtokens.ts index 0b2319d3e..97f2649c5 100644 --- a/migration/1648066794387-addChangeAcceptedtokens.ts +++ b/migration/1648066794387-addChangeAcceptedtokens.ts @@ -1,5 +1,5 @@ import { MigrationInterface, QueryRunner } from 'typeorm'; -import config from '../src/config'; +import config from '../src/config.js'; export class addChangeAcceptedtokens1648066794387 implements MigrationInterface diff --git a/migration/1648103938557-addSupportCustomTokensToOrganizations.ts b/migration/1648103938557-addSupportCustomTokensToOrganizations.ts index f4bb7528c..3387c2e54 100644 --- a/migration/1648103938557-addSupportCustomTokensToOrganizations.ts +++ b/migration/1648103938557-addSupportCustomTokensToOrganizations.ts @@ -1,5 +1,5 @@ import { MigrationInterface, QueryRunner } from 'typeorm'; -import { ORGANIZATION_LABELS } from '../src/entities/organization'; +import { ORGANIZATION_LABELS } from '../src/entities/organization.js'; export class addSupportCustomTokensToOrganizations1648103938557 implements MigrationInterface diff --git a/migration/1649133587608-relateGivingBlocksTokensToOrganization.ts b/migration/1649133587608-relateGivingBlocksTokensToOrganization.ts index d99f50e43..f98795eaf 100644 --- a/migration/1649133587608-relateGivingBlocksTokensToOrganization.ts +++ b/migration/1649133587608-relateGivingBlocksTokensToOrganization.ts @@ -1,5 +1,5 @@ import { MigrationInterface, QueryRunner } from 'typeorm'; -import config from '../src/config'; +import config from '../src/config.js'; // validated this list names from the frontend list manually // removed eth as this is related on another migration diff --git a/migration/1654415838996-fillRelatedAddressesFromProjectsTable.ts b/migration/1654415838996-fillRelatedAddressesFromProjectsTable.ts index 6edde95ef..812783ec8 100644 --- a/migration/1654415838996-fillRelatedAddressesFromProjectsTable.ts +++ b/migration/1654415838996-fillRelatedAddressesFromProjectsTable.ts @@ -1,7 +1,7 @@ import { MigrationInterface, QueryRunner } from 'typeorm'; -import { Project } from '../src/entities/project'; -import { NETWORK_IDS } from '../src/provider'; -import { ENVIRONMENTS } from '../src/utils/utils'; +import { Project } from '../src/entities/project.js'; +import { NETWORK_IDS } from '../src/provider.js'; +import { ENVIRONMENTS } from '../src/utils/utils.js'; const insertRelatedAddress = async (params: { queryRunner: QueryRunner; diff --git a/migration/1661116436720-addGoerliTokens.ts b/migration/1661116436720-addGoerliTokens.ts index 1057948c0..b510542c8 100644 --- a/migration/1661116436720-addGoerliTokens.ts +++ b/migration/1661116436720-addGoerliTokens.ts @@ -1,7 +1,7 @@ import { MigrationInterface, QueryRunner } from 'typeorm'; -import { Token } from '../src/entities/token'; -import seedTokens from './data/seedTokens'; -import config from '../src/config'; +import { Token } from '../src/entities/token.js'; +import seedTokens from './data/seedTokens.js'; +import config from '../src/config.js'; export class addGoerliTokens1661116436720 implements MigrationInterface { async up(queryRunner: QueryRunner): Promise { diff --git a/migration/1672836674875-createTestAdminUser.ts b/migration/1672836674875-createTestAdminUser.ts index bf54010f0..0b8969b2d 100644 --- a/migration/1672836674875-createTestAdminUser.ts +++ b/migration/1672836674875-createTestAdminUser.ts @@ -1,7 +1,6 @@ import { MigrationInterface, QueryRunner } from 'typeorm'; -import config from '../src/config'; -// eslint-disable-next-line @typescript-eslint/no-var-requires -const bcrypt = require('bcrypt'); +import bcrypt from 'bcrypt'; +import config from '../src/config.js'; export class createTestAdminUser1672836674875 implements MigrationInterface { async up(queryRunner: QueryRunner): Promise { diff --git a/migration/1676472760533-FillProjectDescriptionSummaryProjectUpdateContentSummary.ts b/migration/1676472760533-FillProjectDescriptionSummaryProjectUpdateContentSummary.ts index fd8e97c0c..d4be6a187 100644 --- a/migration/1676472760533-FillProjectDescriptionSummaryProjectUpdateContentSummary.ts +++ b/migration/1676472760533-FillProjectDescriptionSummaryProjectUpdateContentSummary.ts @@ -1,6 +1,6 @@ import { MigrationInterface, QueryRunner } from 'typeorm'; -import { Project, ProjectUpdate } from '../src/entities/project'; -import { getHtmlTextSummary } from '../src/utils/utils'; +import { Project, ProjectUpdate } from '../src/entities/project.js'; +import { getHtmlTextSummary } from '../src/utils/utils.js'; export class FillProjectDescriptionSummaryProjectUpdateContentSummary1676472760533 implements MigrationInterface diff --git a/migration/1677742523974-addPolygonTokens.ts b/migration/1677742523974-addPolygonTokens.ts index 383cc0182..79076da07 100644 --- a/migration/1677742523974-addPolygonTokens.ts +++ b/migration/1677742523974-addPolygonTokens.ts @@ -1,7 +1,7 @@ import { MigrationInterface, QueryRunner } from 'typeorm'; -import { Token } from '../src/entities/token'; -import seedTokens from './data/seedTokens'; -import { NETWORK_IDS } from '../src/provider'; +import { Token } from '../src/entities/token.js'; +import seedTokens from './data/seedTokens.js'; +import { NETWORK_IDS } from '../src/provider.js'; export class addGoerliTokens1677742523974 implements MigrationInterface { async up(queryRunner: QueryRunner): Promise { diff --git a/migration/1678950910841-insert_polygon_givback_eligible_tokens.ts b/migration/1678950910841-insert_polygon_givback_eligible_tokens.ts index 8e97a21a1..afeca1e32 100644 --- a/migration/1678950910841-insert_polygon_givback_eligible_tokens.ts +++ b/migration/1678950910841-insert_polygon_givback_eligible_tokens.ts @@ -1,6 +1,6 @@ import { MigrationInterface, QueryRunner } from 'typeorm'; -import { Token } from '../src/entities/token'; -import { NETWORK_IDS } from '../src/provider'; +import { Token } from '../src/entities/token.js'; +import { NETWORK_IDS } from '../src/provider.js'; const polygonTokens = [ { diff --git a/migration/1679383446020-addOptimisticNativeToken.ts b/migration/1679383446020-addOptimisticNativeToken.ts index a31de2e14..aa80c0ed4 100644 --- a/migration/1679383446020-addOptimisticNativeToken.ts +++ b/migration/1679383446020-addOptimisticNativeToken.ts @@ -1,6 +1,6 @@ import { MigrationInterface, QueryRunner } from 'typeorm'; -import { Token } from '../src/entities/token'; -import { NETWORK_IDS } from '../src/provider'; +import { Token } from '../src/entities/token.js'; +import { NETWORK_IDS } from '../src/provider.js'; const optimisticTokens = [ { diff --git a/migration/1680014857601-addCeloTokens.ts b/migration/1680014857601-addCeloTokens.ts index 0741a54b6..277d8ffa1 100644 --- a/migration/1680014857601-addCeloTokens.ts +++ b/migration/1680014857601-addCeloTokens.ts @@ -1,8 +1,8 @@ import { MigrationInterface, QueryRunner } from 'typeorm'; -import { Token } from '../src/entities/token'; -import seedTokens from './data/seedTokens'; -import config from '../src/config'; -import { NETWORK_IDS } from '../src/provider'; +import { Token } from '../src/entities/token.js'; +import seedTokens from './data/seedTokens.js'; +import config from '../src/config.js'; +import { NETWORK_IDS } from '../src/provider.js'; export class addCeloTokens1680014857601 implements MigrationInterface { async up(queryRunner: QueryRunner): Promise { diff --git a/migration/1680507337701-add_some_donations_to_db.ts b/migration/1680507337701-add_some_donations_to_db.ts index 64c84c1a9..0931c4ddc 100644 --- a/migration/1680507337701-add_some_donations_to_db.ts +++ b/migration/1680507337701-add_some_donations_to_db.ts @@ -1,8 +1,8 @@ import { MigrationInterface, QueryRunner } from 'typeorm'; import moment from 'moment'; -import config from '../src/config'; -import { Donation } from '../src/entities/donation'; -import { NETWORK_IDS } from '../src/provider'; +import config from '../src/config.js'; +import { Donation } from '../src/entities/donation.js'; +import { NETWORK_IDS } from '../src/provider.js'; // For seeing donations detail you can see this message ( if you have access to channel) // https://discord.com/channels/679428761438912522/928813033600475207/1089868809302724618 diff --git a/migration/1680539882510-TransformBase64ImagesToIpfs.ts b/migration/1680539882510-TransformBase64ImagesToIpfs.ts index 9a2960159..bce2f6683 100644 --- a/migration/1680539882510-TransformBase64ImagesToIpfs.ts +++ b/migration/1680539882510-TransformBase64ImagesToIpfs.ts @@ -1,6 +1,6 @@ import { Like, MigrationInterface, QueryRunner } from 'typeorm'; -import { Project, ProjectUpdate } from '../src/entities/project'; -import { changeBase64ToIpfsImageInHTML } from '../src/utils/documents'; +import { Project, ProjectUpdate } from '../src/entities/project.js'; +import { changeBase64ToIpfsImageInHTML } from '../src/utils/documents.js'; export class TransformBase64ImagesToIpfs1680539882510 implements MigrationInterface diff --git a/migration/1681125863016-create_some_test_admi_users.ts b/migration/1681125863016-create_some_test_admi_users.ts index 71e557f72..f0e016002 100644 --- a/migration/1681125863016-create_some_test_admi_users.ts +++ b/migration/1681125863016-create_some_test_admi_users.ts @@ -1,9 +1,8 @@ import { MigrationInterface, QueryRunner } from 'typeorm'; -import config from '../src/config'; -import { generateRandomEtheriumAddress } from '../test/testUtils'; -import { UserRole } from '../src/entities/user'; -// eslint-disable-next-line @typescript-eslint/no-var-requires -const bcrypt = require('bcrypt'); +import bcrypt from 'bcrypt'; +import config from '../src/config.js'; +import { generateRandomEtheriumAddress } from '../test/testUtils.js'; +import { UserRole } from '../src/entities/user.js'; export class createSomeTestAdmiUsers1681125863016 implements MigrationInterface diff --git a/migration/1683008685487-AddOptimisticTokens.ts b/migration/1683008685487-AddOptimisticTokens.ts index e8c70e1e6..f8fff3cd8 100644 --- a/migration/1683008685487-AddOptimisticTokens.ts +++ b/migration/1683008685487-AddOptimisticTokens.ts @@ -1,7 +1,7 @@ import { MigrationInterface, QueryRunner } from 'typeorm'; -import { Token } from '../src/entities/token'; -import seedTokens from './data/seedTokens'; -import { NETWORK_IDS } from '../src/provider'; +import { Token } from '../src/entities/token.js'; +import seedTokens from './data/seedTokens.js'; +import { NETWORK_IDS } from '../src/provider.js'; export class AddOptimisticTokens1683008685487 implements MigrationInterface { async up(queryRunner: QueryRunner): Promise { diff --git a/migration/1684654545845-add_some_mainnet_donations.ts b/migration/1684654545845-add_some_mainnet_donations.ts index c3d464467..eb40357d4 100644 --- a/migration/1684654545845-add_some_mainnet_donations.ts +++ b/migration/1684654545845-add_some_mainnet_donations.ts @@ -1,17 +1,17 @@ import moment from 'moment'; import { MigrationInterface, QueryRunner } from 'typeorm'; -import config from '../src/config'; -import { Donation } from '../src/entities/donation'; -import { NETWORK_IDS } from '../src/provider'; +import config from '../src/config.js'; +import { Donation } from '../src/entities/donation.js'; +import { NETWORK_IDS } from '../src/provider.js'; import { updateUserTotalDonated, updateUserTotalReceived, -} from '../src/services/userService'; -import { findProjectById } from '../src/repositories/projectRepository'; -import { Project } from '../src/entities/project'; -import { calculateGivbackFactor } from '../src/services/givbackService'; -import { AppDataSource } from '../src/orm'; -import { updateProjectStatistics } from '../src/services/projectService'; +} from '../src/services/userService.js'; +import { findProjectById } from '../src/repositories/projectRepository.js'; +import { Project } from '../src/entities/project.js'; +import { calculateGivbackFactor } from '../src/services/givbackService.js'; +import { AppDataSource } from '../src/orm.js'; +import { updateProjectStatistics } from '../src/services/projectService.js'; const fromWalletAddress = '0x6bed0ce7be8dc307b69cfdc100f87db51bc3823a'; const txHash = diff --git a/migration/1694635872128-AddEligibleNetworksToPreviousQfRounds.ts b/migration/1694635872128-AddEligibleNetworksToPreviousQfRounds.ts index 62049761d..5b2c4504b 100644 --- a/migration/1694635872128-AddEligibleNetworksToPreviousQfRounds.ts +++ b/migration/1694635872128-AddEligibleNetworksToPreviousQfRounds.ts @@ -1,5 +1,5 @@ import { MigrationInterface, QueryRunner } from 'typeorm'; -import config from '../src/config'; +import config from '../src/config.js'; export class AddEligibleNetworksToPreviousQfRounds1694635872128 implements MigrationInterface diff --git a/migration/1696421249294-Add_ETC_Tokens.ts b/migration/1696421249294-Add_ETC_Tokens.ts index b38615781..25b8edea3 100644 --- a/migration/1696421249294-Add_ETC_Tokens.ts +++ b/migration/1696421249294-Add_ETC_Tokens.ts @@ -1,7 +1,7 @@ import { MigrationInterface, QueryRunner } from 'typeorm'; -import { Token } from '../src/entities/token'; -import seedTokens from './data/seedTokens'; -import { NETWORK_IDS } from '../src/provider'; +import { Token } from '../src/entities/token.js'; +import seedTokens from './data/seedTokens.js'; +import { NETWORK_IDS } from '../src/provider.js'; export class AddETCTokens1696421249294 implements MigrationInterface { async up(queryRunner: QueryRunner): Promise { diff --git a/migration/1696842672748-add_glo_stable_coin_token.ts b/migration/1696842672748-add_glo_stable_coin_token.ts index 1b93ecbcc..c0dcd1987 100644 --- a/migration/1696842672748-add_glo_stable_coin_token.ts +++ b/migration/1696842672748-add_glo_stable_coin_token.ts @@ -1,6 +1,6 @@ import { MigrationInterface, QueryRunner } from 'typeorm'; -import { NETWORK_IDS } from '../src/provider'; -import { Token } from '../src/entities/token'; +import { NETWORK_IDS } from '../src/provider.js'; +import { Token } from '../src/entities/token.js'; const newTokens = [ { diff --git a/migration/1696918830123-add_octant_donations_to_db.ts b/migration/1696918830123-add_octant_donations_to_db.ts index 6a14d6eb0..0d5e89939 100644 --- a/migration/1696918830123-add_octant_donations_to_db.ts +++ b/migration/1696918830123-add_octant_donations_to_db.ts @@ -1,17 +1,17 @@ import { MigrationInterface, QueryRunner } from 'typeorm'; import moment from 'moment'; -import config from '../src/config'; -import { AppDataSource } from '../src/orm'; -import { findProjectById } from '../src/repositories/projectRepository'; -import { Project } from '../src/entities/project'; -import { calculateGivbackFactor } from '../src/services/givbackService'; +import config from '../src/config.js'; +import { AppDataSource } from '../src/orm.js'; +import { findProjectById } from '../src/repositories/projectRepository.js'; +import { Project } from '../src/entities/project.js'; +import { calculateGivbackFactor } from '../src/services/givbackService.js'; import { updateUserTotalDonated, updateUserTotalReceived, -} from '../src/services/userService'; -import { Donation } from '../src/entities/donation'; -import { NETWORK_IDS } from '../src/provider'; -import { updateProjectStatistics } from '../src/services/projectService'; +} from '../src/services/userService.js'; +import { Donation } from '../src/entities/donation.js'; +import { NETWORK_IDS } from '../src/provider.js'; +import { updateProjectStatistics } from '../src/services/projectService.js'; const octantDonationTxHash = '0xe70a8ee39511d3c186ea53c4bdd9fcd34f658d68ca7e1bbbc2b231630ac7fa3b'; diff --git a/migration/1697028245800-add_mordor_etc_testnet_tokens.ts b/migration/1697028245800-add_mordor_etc_testnet_tokens.ts index 54c75ffa2..9a80218bb 100644 --- a/migration/1697028245800-add_mordor_etc_testnet_tokens.ts +++ b/migration/1697028245800-add_mordor_etc_testnet_tokens.ts @@ -1,8 +1,8 @@ import { MigrationInterface, QueryRunner } from 'typeorm'; -import { Token } from '../src/entities/token'; -import seedTokens from './data/seedTokens'; -import { NETWORK_IDS } from '../src/provider'; -import config from '../src/config'; +import { Token } from '../src/entities/token.js'; +import seedTokens from './data/seedTokens.js'; +import { NETWORK_IDS } from '../src/provider.js'; +import config from '../src/config.js'; export class addMordorEtcTestnetTokens1697028245800 implements MigrationInterface diff --git a/migration/1703044586989-addSolanaToken.ts b/migration/1703044586989-addSolanaToken.ts index dd3fb8ddf..815dd2b59 100644 --- a/migration/1703044586989-addSolanaToken.ts +++ b/migration/1703044586989-addSolanaToken.ts @@ -1,10 +1,10 @@ import { MigrationInterface, QueryRunner } from 'typeorm'; -import seedTokens from './data/seedTokens'; -import { ChainType } from '../src/types/network'; -import { SOLANA_SYSTEM_PROGRAM } from '../src/utils/networks'; -import { ENVIRONMENTS } from '../src/utils/utils'; -import { NETWORK_IDS } from '../src/provider'; -import { Token } from '../src/entities/token'; +import seedTokens from './data/seedTokens.js'; +import { ChainType } from '../src/types/network.js'; +import { SOLANA_SYSTEM_PROGRAM } from '../src/utils/networks.js'; +import { ENVIRONMENTS } from '../src/utils/utils.js'; +import { NETWORK_IDS } from '../src/provider.js'; +import { Token } from '../src/entities/token.js'; export class addSolanaToken1703044586989 implements MigrationInterface { async up(queryRunner: QueryRunner): Promise { diff --git a/migration/1703398409668-add_missed_op_donations_to_db.ts b/migration/1703398409668-add_missed_op_donations_to_db.ts index 587fb8c38..f24574621 100644 --- a/migration/1703398409668-add_missed_op_donations_to_db.ts +++ b/migration/1703398409668-add_missed_op_donations_to_db.ts @@ -1,18 +1,18 @@ import { MigrationInterface, QueryRunner } from 'typeorm'; import moment from 'moment'; -import config from '../src/config'; -import { AppDataSource } from '../src/orm'; -import { findProjectById } from '../src/repositories/projectRepository'; -import { Project } from '../src/entities/project'; -import { calculateGivbackFactor } from '../src/services/givbackService'; +import config from '../src/config.js'; +import { AppDataSource } from '../src/orm.js'; +import { findProjectById } from '../src/repositories/projectRepository.js'; +import { Project } from '../src/entities/project.js'; +import { calculateGivbackFactor } from '../src/services/givbackService.js'; import { updateUserTotalDonated, updateUserTotalReceived, -} from '../src/services/userService'; -import { Donation } from '../src/entities/donation'; -import { NETWORK_IDS } from '../src/provider'; -import { refreshProjectEstimatedMatchingView } from '../src/services/projectViewsService'; -import { updateProjectStatistics } from '../src/services/projectService'; +} from '../src/services/userService.js'; +import { Donation } from '../src/entities/donation.js'; +import { NETWORK_IDS } from '../src/provider.js'; +import { refreshProjectEstimatedMatchingView } from '../src/services/projectViewsService.js'; +import { updateProjectStatistics } from '../src/services/projectService.js'; const QF_ROUND_ID = 5; const millisecondTimestampToDate = (timestamp: number): Date => { diff --git a/migration/1704487070444-addSolanaSplTokens.ts b/migration/1704487070444-addSolanaSplTokens.ts index 1168ce273..9dec8c3c9 100644 --- a/migration/1704487070444-addSolanaSplTokens.ts +++ b/migration/1704487070444-addSolanaSplTokens.ts @@ -1,10 +1,10 @@ import { MigrationInterface, QueryRunner } from 'typeorm'; -import { Token } from '../src/entities/token'; -import seedTokens from './data/seedTokens'; -import { NETWORK_IDS } from '../src/provider'; -import { ChainType } from '../src/types/network'; -import { SOLANA_SYSTEM_PROGRAM } from '../src/utils/networks'; -import { ENVIRONMENTS } from '../src/utils/utils'; +import { Token } from '../src/entities/token.js'; +import seedTokens from './data/seedTokens.js'; +import { NETWORK_IDS } from '../src/provider.js'; +import { ChainType } from '../src/types/network.js'; +import { SOLANA_SYSTEM_PROGRAM } from '../src/utils/networks.js'; +import { ENVIRONMENTS } from '../src/utils/utils.js'; export class addSolanaSplTokens1704487070444 implements MigrationInterface { async up(queryRunner: QueryRunner): Promise { diff --git a/migration/1706820821887-addmpEthToDatabaseTokens.ts b/migration/1706820821887-addmpEthToDatabaseTokens.ts index 080ba2a61..acad86c21 100644 --- a/migration/1706820821887-addmpEthToDatabaseTokens.ts +++ b/migration/1706820821887-addmpEthToDatabaseTokens.ts @@ -1,7 +1,7 @@ import { MigrationInterface, QueryRunner } from 'typeorm'; -import { NETWORK_IDS } from '../src/provider'; -import { ChainType } from '../src/types/network'; -import { Token } from '../src/entities/token'; +import { NETWORK_IDS } from '../src/provider.js'; +import { ChainType } from '../src/types/network.js'; +import { Token } from '../src/entities/token.js'; const mpEthTokens = [ { diff --git a/migration/1708279692128-addArbitrumTokens.ts b/migration/1708279692128-addArbitrumTokens.ts index 79dd234ee..14500addf 100644 --- a/migration/1708279692128-addArbitrumTokens.ts +++ b/migration/1708279692128-addArbitrumTokens.ts @@ -1,8 +1,8 @@ import { MigrationInterface, QueryRunner } from 'typeorm'; -import { Token } from '../src/entities/token'; -import seedTokens from './data/seedTokens'; -import config from '../src/config'; -import { NETWORK_IDS } from '../src/provider'; +import { Token } from '../src/entities/token.js'; +import seedTokens from './data/seedTokens.js'; +import config from '../src/config.js'; +import { NETWORK_IDS } from '../src/provider.js'; export class AddArbitrumTokens1708279692128 implements MigrationInterface { public async up(queryRunner: QueryRunner): Promise { diff --git a/migration/1708954413087-addOptimismSepoliaTokens.ts b/migration/1708954413087-addOptimismSepoliaTokens.ts index aa0ad931f..1d76b5d66 100644 --- a/migration/1708954413087-addOptimismSepoliaTokens.ts +++ b/migration/1708954413087-addOptimismSepoliaTokens.ts @@ -1,8 +1,9 @@ import { MigrationInterface, QueryRunner } from 'typeorm'; -import { Token } from '../src/entities/token'; -import seedTokens from './data/seedTokens'; -import { NETWORK_IDS } from '../src/provider'; -import config from '../src/config'; +import { Token } from '../src/entities/token.js'; +import seedTokens from './data/seedTokens.js'; +import { NETWORK_IDS } from '../src/provider.js'; +import config from '../src/config.js'; + export class AddOptimismSepoliaTokens1708954413087 implements MigrationInterface { diff --git a/migration/1709204568033-addCoingeckoId.ts b/migration/1709204568033-addCoingeckoId.ts index beddf31ad..5c8c926df 100644 --- a/migration/1709204568033-addCoingeckoId.ts +++ b/migration/1709204568033-addCoingeckoId.ts @@ -1,7 +1,7 @@ import { MigrationInterface, QueryRunner } from 'typeorm'; -import config from '../src/config'; -import { Token } from '../src/entities/token'; -import { ChainType } from '../src/types/network'; +import config from '../src/config.js'; +import { Token } from '../src/entities/token.js'; +import { ChainType } from '../src/types/network.js'; type TokenData = { networkId: number; diff --git a/migration/1716367359560-add_base_chain_tokens.ts b/migration/1716367359560-add_base_chain_tokens.ts index 4e5f0eb00..25f54226f 100644 --- a/migration/1716367359560-add_base_chain_tokens.ts +++ b/migration/1716367359560-add_base_chain_tokens.ts @@ -1,8 +1,8 @@ import { MigrationInterface, QueryRunner } from 'typeorm'; -import { Token } from '../src/entities/token'; -import seedTokens from './data/seedTokens'; -import config from '../src/config'; -import { NETWORK_IDS } from '../src/provider'; +import { Token } from '../src/entities/token.js'; +import seedTokens from './data/seedTokens.js'; +import config from '../src/config.js'; +import { NETWORK_IDS } from '../src/provider.js'; export class AddBaseChainTokens1716367359560 implements MigrationInterface { public async up(queryRunner: QueryRunner): Promise { diff --git a/migration/1716549958362-add_donations_mannually_to_db.ts b/migration/1716549958362-add_donations_mannually_to_db.ts index dc7551c55..6073e5d1e 100644 --- a/migration/1716549958362-add_donations_mannually_to_db.ts +++ b/migration/1716549958362-add_donations_mannually_to_db.ts @@ -1,18 +1,18 @@ import moment from 'moment'; import { MigrationInterface, QueryRunner } from 'typeorm'; -import { Donation } from '../src/entities/donation'; -import { NETWORK_IDS } from '../src/provider'; -import config from '../src/config'; -import { AppDataSource } from '../src/orm'; -import { findProjectById } from '../src/repositories/projectRepository'; -import { Project } from '../src/entities/project'; -import { calculateGivbackFactor } from '../src/services/givbackService'; +import { Donation } from '../src/entities/donation.js'; +import { NETWORK_IDS } from '../src/provider.js'; +import config from '../src/config.js'; +import { AppDataSource } from '../src/orm.js'; +import { findProjectById } from '../src/repositories/projectRepository.js'; +import { Project } from '../src/entities/project.js'; +import { calculateGivbackFactor } from '../src/services/givbackService.js'; import { updateUserTotalDonated, updateUserTotalReceived, -} from '../src/services/userService'; -import { refreshProjectEstimatedMatchingView } from '../src/services/projectViewsService'; -import { updateProjectStatistics } from '../src/services/projectService'; +} from '../src/services/userService.js'; +import { refreshProjectEstimatedMatchingView } from '../src/services/projectViewsService.js'; +import { updateProjectStatistics } from '../src/services/projectService.js'; const millisecondTimestampToDate = (timestamp: number): Date => { return new Date(timestamp); diff --git a/migration/1718177138564-add_polygon_zkevm_tokens.ts b/migration/1718177138564-add_polygon_zkevm_tokens.ts index 8f1a0f539..396a1e0c6 100644 --- a/migration/1718177138564-add_polygon_zkevm_tokens.ts +++ b/migration/1718177138564-add_polygon_zkevm_tokens.ts @@ -1,7 +1,7 @@ import { MigrationInterface, QueryRunner } from 'typeorm'; -import seedTokens from './data/seedTokens'; -import config from '../src/config'; -import { NETWORK_IDS } from '../src/provider'; +import seedTokens from './data/seedTokens.js'; +import config from '../src/config.js'; +import { NETWORK_IDS } from '../src/provider.js'; export class AddPolygonZkevmTokens1718177138564 implements MigrationInterface { public async up(queryRunner: QueryRunner): Promise { diff --git a/migration/1720634181001-fillUseDonationBoxAndRelevantTxHashInDonation.ts b/migration/1720634181001-fillUseDonationBoxAndRelevantTxHashInDonation.ts index 0e54b6be2..a4ae69820 100644 --- a/migration/1720634181001-fillUseDonationBoxAndRelevantTxHashInDonation.ts +++ b/migration/1720634181001-fillUseDonationBoxAndRelevantTxHashInDonation.ts @@ -1,5 +1,5 @@ import { MigrationInterface, QueryRunner } from 'typeorm'; -import config from '../src/config'; +import config from '../src/config.js'; interface DonationUpdate { id: number; diff --git a/migration/1720771952062-add_sponser_donations_to_givback_round_65.ts b/migration/1720771952062-add_sponser_donations_to_givback_round_65.ts index fe64ca3bc..5c2e2c33c 100644 --- a/migration/1720771952062-add_sponser_donations_to_givback_round_65.ts +++ b/migration/1720771952062-add_sponser_donations_to_givback_round_65.ts @@ -1,17 +1,17 @@ import moment from 'moment'; import { MigrationInterface, QueryRunner } from 'typeorm'; -import { Donation } from '../src/entities/donation'; -import { NETWORK_IDS } from '../src/provider'; -import config from '../src/config'; -import { AppDataSource } from '../src/orm'; -import { findProjectById } from '../src/repositories/projectRepository'; -import { Project } from '../src/entities/project'; -import { calculateGivbackFactor } from '../src/services/givbackService'; +import { Donation } from '../src/entities/donation.js'; +import { NETWORK_IDS } from '../src/provider.js'; +import config from '../src/config.js'; +import { AppDataSource } from '../src/orm.js'; +import { findProjectById } from '../src/repositories/projectRepository.js'; +import { Project } from '../src/entities/project.js'; +import { calculateGivbackFactor } from '../src/services/givbackService.js'; import { updateUserTotalDonated, updateUserTotalReceived, -} from '../src/services/userService'; -import { updateProjectStatistics } from '../src/services/projectService'; +} from '../src/services/userService.js'; +import { updateProjectStatistics } from '../src/services/projectService.js'; const millisecondTimestampToDate = (timestamp: number): Date => { return new Date(timestamp); diff --git a/migration/1720939399738-modify_amount_of_usdc_recurring_donations.ts b/migration/1720939399738-modify_amount_of_usdc_recurring_donations.ts index 21940bc7a..aefe93c87 100644 --- a/migration/1720939399738-modify_amount_of_usdc_recurring_donations.ts +++ b/migration/1720939399738-modify_amount_of_usdc_recurring_donations.ts @@ -1,5 +1,5 @@ import { MigrationInterface, QueryRunner } from 'typeorm'; -import { updateRecurringDonationFromTheStreamDonations } from '../src/repositories/recurringDonationRepository'; +import { updateRecurringDonationFromTheStreamDonations } from '../src/repositories/recurringDonationRepository.js'; export class ModifyAmountOfUsdcRecurringDonations1720939399738 implements MigrationInterface diff --git a/migration/1721261762331-fillDonationPercentageInDonation.ts b/migration/1721261762331-fillDonationPercentageInDonation.ts index 69cdf8663..ad2f67e7f 100644 --- a/migration/1721261762331-fillDonationPercentageInDonation.ts +++ b/migration/1721261762331-fillDonationPercentageInDonation.ts @@ -1,5 +1,5 @@ import { MigrationInterface, QueryRunner } from 'typeorm'; -import config from '../src/config'; +import config from '../src/config.js'; interface DonationUpdate { id: number; diff --git a/migration/data/seedTokens.ts b/migration/data/seedTokens.ts index 5e91d3e2f..4a863bb5e 100644 --- a/migration/data/seedTokens.ts +++ b/migration/data/seedTokens.ts @@ -1,7 +1,7 @@ -import { COINGECKO_TOKEN_IDS } from '../../src/adapters/price/CoingeckoPriceAdapter'; -import { NETWORK_IDS } from '../../src/provider'; -import { ChainType } from '../../src/types/network'; -import { SOLANA_SYSTEM_PROGRAM } from '../../src/utils/networks'; +import { COINGECKO_TOKEN_IDS } from '../../src/adapters/price/CoingeckoPriceAdapter.js'; +import { NETWORK_IDS } from '../../src/provider.js'; +import { ChainType } from '../../src/types/network.js'; +import { SOLANA_SYSTEM_PROGRAM } from '../../src/utils/networks.js'; interface ITokenData { name: string; diff --git a/migration/endaoment-migrations/1719740230650-add_endaoment_organization.ts b/migration/endaoment-migrations/1719740230650-add_endaoment_organization.ts index 7e8fdbe9a..887dabd5f 100644 --- a/migration/endaoment-migrations/1719740230650-add_endaoment_organization.ts +++ b/migration/endaoment-migrations/1719740230650-add_endaoment_organization.ts @@ -1,6 +1,6 @@ import { MigrationInterface, QueryRunner } from 'typeorm'; -import { ORGANIZATION_LABELS } from '../../src/entities/organization'; -import { NETWORK_IDS } from '../../src/provider'; +import { ORGANIZATION_LABELS } from '../../src/entities/organization.js'; +import { NETWORK_IDS } from '../../src/provider.js'; export class AddEndaomentOrganization1719740230650 implements MigrationInterface diff --git a/migration/endaoment-migrations/1719808494904-add_endaoment_projects.ts b/migration/endaoment-migrations/1719808494904-add_endaoment_projects.ts index f46c6bf10..710d14098 100644 --- a/migration/endaoment-migrations/1719808494904-add_endaoment_projects.ts +++ b/migration/endaoment-migrations/1719808494904-add_endaoment_projects.ts @@ -1,8 +1,8 @@ import { MigrationInterface, QueryRunner } from 'typeorm'; -import { endaomentProjectCategoryMapping } from '../data/endaomentProjectCategoryMapping'; -import { endaomentProjects } from '../data/importedEndaomentProjects'; -import { NETWORK_IDS } from '../../src/provider'; -import { ReviewStatus } from '../../src/entities/project'; +import { endaomentProjectCategoryMapping } from '../data/endaomentProjectCategoryMapping.js'; +import { endaomentProjects } from '../data/importedEndaomentProjects.js'; +import { NETWORK_IDS } from '../../src/provider.js'; +import { ReviewStatus } from '../../src/entities/project.js'; export class AddEndaomentsProjects1719808494904 implements MigrationInterface { public async up(queryRunner: QueryRunner): Promise { diff --git a/migration/endaoment-migrations/1721286322530-fill_description_summary_to_endaoment_projects.ts b/migration/endaoment-migrations/1721286322530-fill_description_summary_to_endaoment_projects.ts index 92aa093c2..36800d2d4 100644 --- a/migration/endaoment-migrations/1721286322530-fill_description_summary_to_endaoment_projects.ts +++ b/migration/endaoment-migrations/1721286322530-fill_description_summary_to_endaoment_projects.ts @@ -1,5 +1,5 @@ import { MigrationInterface, QueryRunner } from 'typeorm'; -import { ORGANIZATION_LABELS } from '../../src/entities/organization'; +import { ORGANIZATION_LABELS } from '../../src/entities/organization.js'; export class FillDescriptionSummaryToEndaomentProjects1721286322530 implements MigrationInterface diff --git a/migration/endaoment-migrations/1721290930117-remove_special_characters_from_endaoment_projects_slug.ts b/migration/endaoment-migrations/1721290930117-remove_special_characters_from_endaoment_projects_slug.ts index 23d3030a2..1e4272972 100644 --- a/migration/endaoment-migrations/1721290930117-remove_special_characters_from_endaoment_projects_slug.ts +++ b/migration/endaoment-migrations/1721290930117-remove_special_characters_from_endaoment_projects_slug.ts @@ -1,5 +1,5 @@ import { MigrationInterface, QueryRunner } from 'typeorm'; -import { ORGANIZATION_LABELS } from '../../src/entities/organization'; +import { ORGANIZATION_LABELS } from '../../src/entities/organization.js'; export class RemoveSpecialCharactersFromEndaomentProjectsSlug1721290930117 implements MigrationInterface diff --git a/migration/endaoment-migrations/1721300929435-modify_endaoment_categories.ts b/migration/endaoment-migrations/1721300929435-modify_endaoment_categories.ts index bf3a9305a..21e3f23a0 100644 --- a/migration/endaoment-migrations/1721300929435-modify_endaoment_categories.ts +++ b/migration/endaoment-migrations/1721300929435-modify_endaoment_categories.ts @@ -1,6 +1,6 @@ import { MigrationInterface, QueryRunner } from 'typeorm'; -import { endaomentProjectCategoryMapping } from '../data/endaomentProjectCategoryMapping'; -import { endaomentProjects } from '../data/importedEndaomentProjects'; +import { endaomentProjectCategoryMapping } from '../data/endaomentProjectCategoryMapping.js'; +import { endaomentProjects } from '../data/importedEndaomentProjects.js'; export class ModifyEndaomentCategories1721300929435 implements MigrationInterface diff --git a/migration/tests/1720939399738-modify_amount_of_usdc_recurring_donations.test.ts b/migration/tests/1720939399738-modify_amount_of_usdc_recurring_donations.test.ts index 7d48a87ce..e8eb1409b 100644 --- a/migration/tests/1720939399738-modify_amount_of_usdc_recurring_donations.test.ts +++ b/migration/tests/1720939399738-modify_amount_of_usdc_recurring_donations.test.ts @@ -1,6 +1,6 @@ import { assert } from 'chai'; -import { ModifyAmountOfUsdcRecurringDonations1720939399738 } from '../1720939399738-modify_amount_of_usdc_recurring_donations'; -import { AppDataSource } from '../../src/orm'; +import { ModifyAmountOfUsdcRecurringDonations1720939399738 } from '../1720939399738-modify_amount_of_usdc_recurring_donations.js'; +import { AppDataSource } from '../../src/orm.js'; import { createDonationData, createProjectData, @@ -10,20 +10,20 @@ import { saveProjectDirectlyToDb, saveRecurringDonationDirectlyToDb, saveUserDirectlyToDb, -} from '../../test/testUtils'; -import { addNewAnchorAddress } from '../../src/repositories/anchorContractAddressRepository'; -import { NETWORK_IDS } from '../../src/provider'; +} from '../../test/testUtils.js'; +import { addNewAnchorAddress } from '../../src/repositories/anchorContractAddressRepository.js'; +import { NETWORK_IDS } from '../../src/provider.js'; import { RECURRING_DONATION_STATUS, RecurringDonation, -} from '../../src/entities/recurringDonation'; -import { AnchorContractAddress } from '../../src/entities/anchorContractAddress'; -import { findDonationById } from '../../src/repositories/donationRepository'; -import { Donation } from '../../src/entities/donation'; +} from '../../src/entities/recurringDonation.js'; +import { AnchorContractAddress } from '../../src/entities/anchorContractAddress.js'; +import { findDonationById } from '../../src/repositories/donationRepository.js'; +import { Donation } from '../../src/entities/donation.js'; import { findRecurringDonationById, updateRecurringDonationFromTheStreamDonations, -} from '../../src/repositories/recurringDonationRepository'; +} from '../../src/repositories/recurringDonationRepository.js'; let queryRunner; describe('Modify amount of USDC recurring donations', async () => { diff --git a/package-lock.json b/package-lock.json index 211ae34bf..e885e5133 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "giveth-graphql-api", - "version": "1.24.0", + "version": "1.24.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "giveth-graphql-api", - "version": "1.24.0", + "version": "1.24.1", "hasInstallScript": true, "license": "ISC", "dependencies": { @@ -15,7 +15,7 @@ "@adminjs/typeorm": "4.0.0", "@apollo/server": "4.10.0", "@apollo/server-plugin-landing-page-graphql-playground": "^4.0.1", - "@chainvine/sdk": "1.1.10", + "@chainvine/sdk": "1.6.1", "@giveth/monoswap": "^1.3.4", "@pinata/sdk": "^2.1.0", "@safe-global/api-kit": "^2.0.0", @@ -38,14 +38,14 @@ "cookie-parser": "^1.4.5", "cors": "^2.8.5", "csvtojson": "^2.0.10", - "dotenv": "^8.2.0", + "dotenv": "16.4.5", "ethers": "^5.7.2", "express": "^4.19.2", "express-formidable": "^1.2.0", "express-rate-limit": "^7.1.5", "express-session": "^1.17.3", "form-data": "^3.0.1", - "google-spreadsheet": "^3.2.0", + "google-spreadsheet": "^4.1.2", "graphql": "16.8.1", "graphql-fields": "^2.0.3", "graphql-tag": "^2.12.6", @@ -60,7 +60,9 @@ "js-sha256": "^0.9.0", "json-stable-stringify": "^1.0.2", "jsonwebtoken": "^9.0.0", + "jsonwebtoken-esm": "^2.0.1", "lodash": "^4.17.21", + "lodash-es": "^4.17.21", "marked": "^4.2.5", "moment": "^2.29.4", "node-cron": "^3.0.2", @@ -68,7 +70,7 @@ "rate-limit-redis": "^4.2.0", "reflect-metadata": "^0.1.13", "siwe": "^1.1.6", - "slugify": "^1.4.7", + "slugify": "^1.6.6", "stripe": "^8.137.0", "threads": "^1.7.0", "twitter-api-sdk": "^1.0.9", @@ -78,20 +80,28 @@ }, "devDependencies": { "@types/axios": "^0.14.0", + "@types/bcrypt": "^5.0.2", + "@types/bcryptjs": "^2.4.6", "@types/bull": "^3.15.5", "@types/chai": "^4.2.15", "@types/connect-redis": "0.0.23", "@types/cors": "^2.8.10", "@types/dotenv": "^8.2.0", "@types/express": "^4.17.21", + "@types/google-spreadsheet": "^4.0.0", "@types/graphql-upload": "15.0.2", + "@types/html-pdf-node": "^1.0.2", "@types/html-to-text": "^9.0.0", - "@types/jsonwebtoken": "^8.5.0", + "@types/i18n": "^0.13.12", + "@types/json-stable-stringify": "^1.0.36", + "@types/jsonwebtoken": "^8.5.9", "@types/lodash": "^4.14.197", + "@types/lodash-es": "^4.17.12", "@types/marked": "^4.0.8", - "@types/mocha": "^8.2.1", + "@types/mocha": "^10.0.7", "@types/node": "^14.14.31", "@types/node-cron": "^3.0.0", + "@types/sinon": "^17.0.3", "@typescript-eslint/eslint-plugin": "^7.2.0", "@typescript-eslint/parser": "^7.2.0", "chai": "^4.3.0", @@ -102,7 +112,7 @@ "eslint-plugin-unused-imports": "^3.1.0", "husky": "^4.3.8", "lint-staged": "^10.5.4", - "mocha": "^10.2.0", + "mocha": "^10.7.0", "prettier": "^3.2.5", "sinon": "^13.0.1", "ts-node": "10.9.2", @@ -323,25 +333,6 @@ "node": ">=12" } }, - "node_modules/@apollo/server/node_modules/node-fetch": { - "version": "2.6.8", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.8.tgz", - "integrity": "sha512-RZ6dBYuj8dRSfxpUSu+NsdF1dpPpluJxwOp+6IoDp/sH2QNDSvurYsAa+F1WxY2RjA1iP93xhcsUoYbF2XBqVg==", - "dependencies": { - "whatwg-url": "^5.0.0" - }, - "engines": { - "node": "4.x || >=6.0.0" - }, - "peerDependencies": { - "encoding": "^0.1.0" - }, - "peerDependenciesMeta": { - "encoding": { - "optional": true - } - } - }, "node_modules/@apollo/server/node_modules/uuid": { "version": "9.0.0", "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.0.tgz", @@ -2374,12 +2365,12 @@ } }, "node_modules/@chainvine/sdk": { - "version": "1.1.10", - "resolved": "https://registry.npmjs.org/@chainvine/sdk/-/sdk-1.1.10.tgz", - "integrity": "sha512-rm0iJQVAmjIcKLP1xyCcUlTzuXlPZt+5oyZ7xDyGG4ABcqi7Q5+iIj90EJGDgWrxBDBLJ6e9S7bzlUDhaOVLoQ==", + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/@chainvine/sdk/-/sdk-1.6.1.tgz", + "integrity": "sha512-ltp05af5PO1Wk8IOEwiLJ9BTK2E9zIRZ5JiDVyNIzIWYqTD9FeXfQPfaq0eoec6mSJnfgZuAAg5JoCnT6WbKJQ==", "dependencies": { - "@types/express": "^4.17.15", - "cross-fetch": "^3.1.5", + "cls-hooked": "^4.2.2", + "cross-fetch": "^3.1.6", "js-cookie": "^3.0.1" } }, @@ -3480,6 +3471,14 @@ "honeyswap-sdk": "^1.0.0" } }, + "node_modules/@giveth/monoswap/node_modules/dotenv": { + "version": "8.6.0", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.6.0.tgz", + "integrity": "sha512-IrPdXQsk2BbzvCBGBOTmmSH5SodmqZNt4ERAZDmW4CT+tL8VtvinqywuANaFu4bOMWki16nqf0e4oC0QIaDr/g==", + "engines": { + "node": ">=10" + } + }, "node_modules/@graphql-tools/merge": { "version": "8.3.15", "resolved": "https://registry.npmjs.org/@graphql-tools/merge/-/merge-8.3.15.tgz", @@ -4695,25 +4694,6 @@ "node": ">=14.0.0" } }, - "node_modules/@safe-global/api-kit/node_modules/node-fetch": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", - "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", - "dependencies": { - "whatwg-url": "^5.0.0" - }, - "engines": { - "node": "4.x || >=6.0.0" - }, - "peerDependencies": { - "encoding": "^0.1.0" - }, - "peerDependenciesMeta": { - "encoding": { - "optional": true - } - } - }, "node_modules/@safe-global/api-kit/node_modules/tslib": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz", @@ -5469,25 +5449,6 @@ "ieee754": "^1.2.1" } }, - "node_modules/@solana/web3.js/node_modules/node-fetch": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", - "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", - "dependencies": { - "whatwg-url": "^5.0.0" - }, - "engines": { - "node": "4.x || >=6.0.0" - }, - "peerDependencies": { - "encoding": "^0.1.0" - }, - "peerDependenciesMeta": { - "encoding": { - "optional": true - } - } - }, "node_modules/@spruceid/siwe-parser": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/@spruceid/siwe-parser/-/siwe-parser-1.1.3.tgz", @@ -6226,6 +6187,21 @@ "@types/babel-types": "*" } }, + "node_modules/@types/bcrypt": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@types/bcrypt/-/bcrypt-5.0.2.tgz", + "integrity": "sha512-6atioO8Y75fNcbmj0G7UjI9lXN2pQ/IGJ2FWT4a/btd0Lk9lQalHLKhkgKVZ3r+spnmWUKfbMi1GEe9wyHQfNQ==", + "dev": true, + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/bcryptjs": { + "version": "2.4.6", + "resolved": "https://registry.npmjs.org/@types/bcryptjs/-/bcryptjs-2.4.6.tgz", + "integrity": "sha512-9xlo6R2qDs5uixm0bcIqCeMCE6HiQsIyel9KQySStiyqNl2tnj2mP3DX1Nf56MD6KMenNNlBBsy3LJ7gUEQPXQ==", + "dev": true + }, "node_modules/@types/bn.js": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/@types/bn.js/-/bn.js-5.1.1.tgz", @@ -6381,6 +6357,16 @@ "@types/node": "*" } }, + "node_modules/@types/google-spreadsheet": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@types/google-spreadsheet/-/google-spreadsheet-4.0.0.tgz", + "integrity": "sha512-GdfhBRQcN1KhpZGbhOEu/Cj2LimDLUW7hVB/GD552F4IY4FuYFwYwIz1TIB7rRqMVnMy99RdwpgXPX0G5Uu+7g==", + "deprecated": "This is a stub types definition. google-spreadsheet provides its own type definitions, so you do not need this installed.", + "dev": true, + "dependencies": { + "google-spreadsheet": "*" + } + }, "node_modules/@types/graphql-upload": { "version": "15.0.2", "resolved": "https://registry.npmjs.org/@types/graphql-upload/-/graphql-upload-15.0.2.tgz", @@ -6402,6 +6388,15 @@ "hoist-non-react-statics": "^3.3.0" } }, + "node_modules/@types/html-pdf-node": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@types/html-pdf-node/-/html-pdf-node-1.0.2.tgz", + "integrity": "sha512-faAOCGPJNHlMxrTYDFfLPmWp0xu1z8+VrzspaWRXMjrI4jquKRrQ263/tr7Dygv/cJSvZQHYhvMcj4btdQUdFg==", + "dev": true, + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@types/html-to-text": { "version": "9.0.0", "resolved": "https://registry.npmjs.org/@types/html-to-text/-/html-to-text-9.0.0.tgz", @@ -6425,6 +6420,12 @@ "integrity": "sha512-/K3ds8TRAfBvi5vfjuz8y6+GiAYBZ0x4tXv1Av6CWBWn0IlADc+ZX9pMq7oU0fNQPnBwIZl3rmeLp6SBApbxSQ==", "devOptional": true }, + "node_modules/@types/i18n": { + "version": "0.13.12", + "resolved": "https://registry.npmjs.org/@types/i18n/-/i18n-0.13.12.tgz", + "integrity": "sha512-iAd2QjKh+0ToBXocmCS3m38GskiaGzmSV1MTQz2GaOraqSqBiLf46J7u3EGINl+st+Uk4lO3OL7QyIjTJlrWIg==", + "dev": true + }, "node_modules/@types/ioredis": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/@types/ioredis/-/ioredis-5.0.0.tgz", @@ -6441,6 +6442,12 @@ "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", "dev": true }, + "node_modules/@types/json-stable-stringify": { + "version": "1.0.36", + "resolved": "https://registry.npmjs.org/@types/json-stable-stringify/-/json-stable-stringify-1.0.36.tgz", + "integrity": "sha512-b7bq23s4fgBB76n34m2b3RBf6M369B0Z9uRR8aHTMd8kZISRkmDEpPD8hhpYvDFzr3bJCPES96cm3Q6qRNDbQw==", + "dev": true + }, "node_modules/@types/json5": { "version": "0.0.29", "resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz", @@ -6501,6 +6508,15 @@ "integrity": "sha512-OvlIYQK9tNneDlS0VN54LLd5uiPCBOp7gS5Z0f1mjoJYBrtStzgmJBxONW3U6OZqdtNzZPmn9BS/7WI7BFFcFQ==", "dev": true }, + "node_modules/@types/lodash-es": { + "version": "4.17.12", + "resolved": "https://registry.npmjs.org/@types/lodash-es/-/lodash-es-4.17.12.tgz", + "integrity": "sha512-0NgftHUcV4v34VhXm8QBSftKVXtbkBG3ViCjs6+eJ5a6y6Mi/jiFGPc1sC7QK+9BFhWrURE3EOggmWaSxL9OzQ==", + "dev": true, + "dependencies": { + "@types/lodash": "*" + } + }, "node_modules/@types/long": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/@types/long/-/long-4.0.2.tgz", @@ -6529,9 +6545,9 @@ "integrity": "sha512-K0VQKziLUWkVKiRVrx4a40iPaxTUefQmjtkQofBkYRcoaaL/8rhwDWww9qWbrgicNOgnpIsMxyNIUM4+n6dUIA==" }, "node_modules/@types/mocha": { - "version": "8.2.3", - "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-8.2.3.tgz", - "integrity": "sha512-ekGvFhFgrc2zYQoX4JeZPmVzZxw6Dtllga7iGHzfbYIYkAMUx/sAFP2GdFpLff+vdHXu5fl7WX9AT+TtqYcsyw==", + "version": "10.0.7", + "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-10.0.7.tgz", + "integrity": "sha512-GN8yJ1mNTcFcah/wKEFIJckJx9iJLoMSzWcfRRuxz/Jk+U6KQNnml+etbtxFK8lPjzOw3zp4Ha/kjSst9fsHYw==", "dev": true }, "node_modules/@types/node": { @@ -6681,6 +6697,21 @@ "@types/node": "*" } }, + "node_modules/@types/sinon": { + "version": "17.0.3", + "resolved": "https://registry.npmjs.org/@types/sinon/-/sinon-17.0.3.tgz", + "integrity": "sha512-j3uovdn8ewky9kRBG19bOwaZbexJu/XjtkHyjvUgt4xfPFz18dcORIMqnYh66Fx3Powhcr85NT5+er3+oViapw==", + "dev": true, + "dependencies": { + "@types/sinonjs__fake-timers": "*" + } + }, + "node_modules/@types/sinonjs__fake-timers": { + "version": "8.1.5", + "resolved": "https://registry.npmjs.org/@types/sinonjs__fake-timers/-/sinonjs__fake-timers-8.1.5.tgz", + "integrity": "sha512-mQkU2jY8jJEF7YHjHvsQO8+3ughTL1mcnn96igfhONmR+fUPSKIkefQYpSe8bsly2Ep7oQbn/6VG5/9/0qcArQ==", + "dev": true + }, "node_modules/@types/strip-bom": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/@types/strip-bom/-/strip-bom-3.0.0.tgz", @@ -7769,14 +7800,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/arrify": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/arrify/-/arrify-2.0.1.tgz", - "integrity": "sha512-3duEwti880xqi4eAMN8AyR4a0ByT90zoYdLlevfrvU43vb0YZwZVfxOgxWrLXXXpyugL0hNZc9G6BiB5B3nUug==", - "engines": { - "node": ">=8" - } - }, "node_modules/asap": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", @@ -7850,6 +7873,17 @@ "lodash": "^4.17.14" } }, + "node_modules/async-hook-jl": { + "version": "1.7.6", + "resolved": "https://registry.npmjs.org/async-hook-jl/-/async-hook-jl-1.7.6.tgz", + "integrity": "sha512-gFaHkFfSxTjvoxDMYqDuGHlcRyUuamF8s+ZTtJdDzqjws4mCt7v0vuV79/E2Wr2/riMQgtG4/yUtXWs1gZ7JMg==", + "dependencies": { + "stack-chain": "^1.3.7" + }, + "engines": { + "node": "^4.7 || >=6.9 || >=7.3" + } + }, "node_modules/async-limiter": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.1.tgz", @@ -8950,6 +8984,27 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/cls-hooked": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/cls-hooked/-/cls-hooked-4.2.2.tgz", + "integrity": "sha512-J4Xj5f5wq/4jAvcdgoGsL3G103BtWpZrMo8NEinRltN+xpTZdI+M38pyQqhuFU/P792xkMFvnKSf+Lm81U1bxw==", + "dependencies": { + "async-hook-jl": "^1.7.6", + "emitter-listener": "^1.0.1", + "semver": "^5.4.1" + }, + "engines": { + "node": "^4.7 || >=6.9 || >=7.3 || >=8.2.1" + } + }, + "node_modules/cls-hooked/node_modules/semver": { + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", + "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", + "bin": { + "semver": "bin/semver" + } + }, "node_modules/cluster-key-slot": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/cluster-key-slot/-/cluster-key-slot-1.1.2.tgz", @@ -9262,11 +9317,11 @@ } }, "node_modules/cross-fetch": { - "version": "3.1.5", - "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.5.tgz", - "integrity": "sha512-lvb1SBsI0Z7GDwmuid+mU3kWVBwTVUbe7S0H52yaaAdQOXq2YktTCZdlAcNKFzE6QtRz0snpw9bNiPeOIkkQvw==", + "version": "3.1.8", + "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.8.tgz", + "integrity": "sha512-cvA+JwZoU0Xq+h6WkMvAUqPEYy92Obet6UdKLfW60qn99ftItKjB5T+BkyWOFWe2pUyfQ+IJHmpOTznqk1M6Kg==", "dependencies": { - "node-fetch": "2.6.7" + "node-fetch": "^2.6.12" } }, "node_modules/cross-spawn": { @@ -9428,9 +9483,9 @@ "integrity": "sha512-vjAczensTgRcqDERK0SR2XMwsF/tSvnvlv6VcF2GIhg6Sx4yOIt/irsr1RDJsKiIyBzJDpCoXiWWq28MqH2cnQ==" }, "node_modules/debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "version": "4.3.6", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.6.tgz", + "integrity": "sha512-O/09Bd4Z1fBrU4VzkhFqVgpPzaGbw6Sm9FEkBT1A/YBXQFGuuSxa1dN2nxgxS34JmKXqYx8CZAwEVoJFImUXIg==", "dependencies": { "ms": "2.1.2" }, @@ -9666,9 +9721,9 @@ } }, "node_modules/diff": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz", - "integrity": "sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==", + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-5.2.0.tgz", + "integrity": "sha512-uIFDxqpRZGZ6ThOk84hEfqWoHx2devRFvpTZcTHur85vImfaxUbTW9Ryh4CpCuDnToOP1CEtXKIgytHBPVff5A==", "engines": { "node": ">=0.3.1" } @@ -9743,11 +9798,14 @@ } }, "node_modules/dotenv": { - "version": "8.6.0", - "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.6.0.tgz", - "integrity": "sha512-IrPdXQsk2BbzvCBGBOTmmSH5SodmqZNt4ERAZDmW4CT+tL8VtvinqywuANaFu4bOMWki16nqf0e4oC0QIaDr/g==", + "version": "16.4.5", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz", + "integrity": "sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==", "engines": { - "node": ">=10" + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" } }, "node_modules/dtrace-provider": { @@ -9823,6 +9881,14 @@ "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==" }, + "node_modules/emitter-listener": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/emitter-listener/-/emitter-listener-1.1.2.tgz", + "integrity": "sha512-Bt1sBAGFHY9DKY+4/2cV6izcKJUf5T7/gkdmkxzX/qv9CcGH8xSwVRW5mtX03SWJtRTWSOpzCuWN9rBFYZepZQ==", + "dependencies": { + "shimmer": "^1.2.0" + } + }, "node_modules/emoji-regex": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", @@ -11116,11 +11182,6 @@ "resolved": "https://registry.npmjs.org/fast-stable-stringify/-/fast-stable-stringify-1.0.0.tgz", "integrity": "sha512-wpYMUmFu5f00Sm0cj2pfivpmawLZ0NKdviQ4w9zJeR8JVtOpOxHmLaJuj0vxvGqMJQWyP/COUkF75/57OKyRag==" }, - "node_modules/fast-text-encoding": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/fast-text-encoding/-/fast-text-encoding-1.0.6.tgz", - "integrity": "sha512-VhXlQgj9ioXCqGstD37E/HBeqEGV/qOD/kmbVG8h5xKBYvM1L3lR1Zn4555cQ8GkYbJa8aJSipLPndE1k6zK2w==" - }, "node_modules/fastq": { "version": "1.17.1", "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.17.1.tgz", @@ -11577,33 +11638,6 @@ "node": ">=10" } }, - "node_modules/gaxios": { - "version": "4.3.3", - "resolved": "https://registry.npmjs.org/gaxios/-/gaxios-4.3.3.tgz", - "integrity": "sha512-gSaYYIO1Y3wUtdfHmjDUZ8LWaxJQpiavzbF5Kq53akSzvmVg0RfyOcFDbO1KJ/KCGRFz2qG+lS81F0nkr7cRJA==", - "dependencies": { - "abort-controller": "^3.0.0", - "extend": "^3.0.2", - "https-proxy-agent": "^5.0.0", - "is-stream": "^2.0.0", - "node-fetch": "^2.6.7" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/gcp-metadata": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/gcp-metadata/-/gcp-metadata-4.3.1.tgz", - "integrity": "sha512-x850LS5N7V1F3UcV7PoupzGsyD6iVwTVvsh3tbXfkctZnBnjW5yu5z1/3k3SehF7TyoTIe78rJs02GMMy+LF+A==", - "dependencies": { - "gaxios": "^4.0.0", - "json-bigint": "^1.0.0" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/gensync": { "version": "1.0.0-beta.2", "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", @@ -11818,74 +11852,21 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/google-auth-library": { - "version": "6.1.6", - "resolved": "https://registry.npmjs.org/google-auth-library/-/google-auth-library-6.1.6.tgz", - "integrity": "sha512-Q+ZjUEvLQj/lrVHF/IQwRo6p3s8Nc44Zk/DALsN+ac3T4HY/g/3rrufkgtl+nZ1TW7DNAw5cTChdVp4apUXVgQ==", - "dependencies": { - "arrify": "^2.0.0", - "base64-js": "^1.3.0", - "ecdsa-sig-formatter": "^1.0.11", - "fast-text-encoding": "^1.0.0", - "gaxios": "^4.0.0", - "gcp-metadata": "^4.2.0", - "gtoken": "^5.0.4", - "jws": "^4.0.0", - "lru-cache": "^6.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/google-auth-library/node_modules/lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/google-auth-library/node_modules/yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" - }, - "node_modules/google-p12-pem": { - "version": "3.1.4", - "resolved": "https://registry.npmjs.org/google-p12-pem/-/google-p12-pem-3.1.4.tgz", - "integrity": "sha512-HHuHmkLgwjdmVRngf5+gSmpkyaRI6QmOg77J8tkNBHhNEI62sGHyw4/+UkgyZEI7h84NbWprXDJ+sa3xOYFvTg==", - "dependencies": { - "node-forge": "^1.3.1" - }, - "bin": { - "gp12-pem": "build/src/bin/gp12-pem.js" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/google-spreadsheet": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/google-spreadsheet/-/google-spreadsheet-3.3.0.tgz", - "integrity": "sha512-ahmRNh14s1i3phfvbF2mxen1lohWJpUaFWgsU6P6bXu7QrmxMaim1Ys/7BU4W5yucWCzphoIrHMbrbeIR5K9mw==", + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/google-spreadsheet/-/google-spreadsheet-4.1.2.tgz", + "integrity": "sha512-HFBweDAkOcyC2qO9kmWESKbNuOcn+R7UzZN/tj5LLNxVv8FHmg113u0Ow+yaKwwIOt/NnDtPLuptAhaxTs0FYw==", "dependencies": { - "axios": "^0.21.4", - "google-auth-library": "^6.1.3", + "axios": "^1.4.0", "lodash": "^4.17.21" }, - "engines": { - "node": ">=0.8.0" - } - }, - "node_modules/google-spreadsheet/node_modules/axios": { - "version": "0.21.4", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz", - "integrity": "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==", - "dependencies": { - "follow-redirects": "^1.14.0" + "peerDependencies": { + "google-auth-library": "^8.8.0 || ^9.0.0" + }, + "peerDependenciesMeta": { + "google-auth-library": { + "optional": true + } } }, "node_modules/gopd": { @@ -12026,19 +12007,6 @@ "node": ">=10" } }, - "node_modules/gtoken": { - "version": "5.3.2", - "resolved": "https://registry.npmjs.org/gtoken/-/gtoken-5.3.2.tgz", - "integrity": "sha512-gkvEKREW7dXWF8NV8pVrKfW7WqReAmjjkMBh6lNCCGOM4ucS0r0YyXXl0r/9Yj8wcW/32ISkfc8h5mPTDbtifQ==", - "dependencies": { - "gaxios": "^4.0.0", - "google-p12-pem": "^3.1.3", - "jws": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/gud": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/gud/-/gud-1.0.0.tgz", @@ -13594,6 +13562,7 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", + "dev": true, "engines": { "node": ">=8" }, @@ -13868,14 +13837,6 @@ "node": ">=4" } }, - "node_modules/json-bigint": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/json-bigint/-/json-bigint-1.0.0.tgz", - "integrity": "sha512-SiPv/8VpZuWbvLSMtTDU8hEfrZWg/mH/nV/b4o0CYbSxu1UIQPLdwKOCIyLQX+VIPO5vrLX3i8qtqFyhdPSUSQ==", - "dependencies": { - "bignumber.js": "^9.0.0" - } - }, "node_modules/json-buffer": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", @@ -13983,6 +13944,14 @@ "npm": ">=6" } }, + "node_modules/jsonwebtoken-esm": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/jsonwebtoken-esm/-/jsonwebtoken-esm-2.0.1.tgz", + "integrity": "sha512-uZwq66J1WgwevzBheW8AMj8STn9QLXHLtY5cI52ztzip8VFPwoqaz/RQmgfNMivt+yD2Lfi4YS4uYHoKz0Fw9g==", + "engines": { + "node": ">=14.18" + } + }, "node_modules/jsonwebtoken/node_modules/jwa": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/jwa/-/jwa-1.4.1.tgz", @@ -14057,25 +14026,6 @@ "resolved": "https://registry.npmjs.org/jw-paginate/-/jw-paginate-1.0.4.tgz", "integrity": "sha512-W0bv782exgCoynUL/egbRpaYwf/r6T6e02H870H5u3hfSgEYrxgz5POwmFF5aApS6iPi6yhZ0VF8IbafNFsntA==" }, - "node_modules/jwa": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/jwa/-/jwa-2.0.0.tgz", - "integrity": "sha512-jrZ2Qx916EA+fq9cEAeCROWPTfCwi1IVHqT2tapuqLEVVDKFDENFw1oL+MwrTvH6msKxsd1YTDVw6uKEcsrLEA==", - "dependencies": { - "buffer-equal-constant-time": "1.0.1", - "ecdsa-sig-formatter": "1.0.11", - "safe-buffer": "^5.0.1" - } - }, - "node_modules/jws": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/jws/-/jws-4.0.0.tgz", - "integrity": "sha512-KDncfTmOZoOMTFG4mBlG0qUIOlc03fmzH+ru6RgYVZhPkyiy/92Owlt/8UEN+a4TXR1FQetfIpJE8ApdvdVxTg==", - "dependencies": { - "jwa": "^2.0.0", - "safe-buffer": "^5.0.1" - } - }, "node_modules/keccak": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/keccak/-/keccak-3.0.3.tgz", @@ -14472,6 +14422,11 @@ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" }, + "node_modules/lodash-es": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.21.tgz", + "integrity": "sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==" + }, "node_modules/lodash.assignin": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/lodash.assignin/-/lodash.assignin-4.2.0.tgz", @@ -15009,31 +14964,30 @@ } }, "node_modules/mocha": { - "version": "10.2.0", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.2.0.tgz", - "integrity": "sha512-IDY7fl/BecMwFHzoqF2sg/SHHANeBoMMXFlS9r0OXKDssYE1M5O43wUY/9BVPeIvfH2zmEbBfseqN9gBQZzXkg==", - "dependencies": { - "ansi-colors": "4.1.1", - "browser-stdout": "1.3.1", - "chokidar": "3.5.3", - "debug": "4.3.4", - "diff": "5.0.0", - "escape-string-regexp": "4.0.0", - "find-up": "5.0.0", - "glob": "7.2.0", - "he": "1.2.0", - "js-yaml": "4.1.0", - "log-symbols": "4.1.0", - "minimatch": "5.0.1", - "ms": "2.1.3", - "nanoid": "3.3.3", - "serialize-javascript": "6.0.0", - "strip-json-comments": "3.1.1", - "supports-color": "8.1.1", - "workerpool": "6.2.1", - "yargs": "16.2.0", - "yargs-parser": "20.2.4", - "yargs-unparser": "2.0.0" + "version": "10.7.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.7.0.tgz", + "integrity": "sha512-v8/rBWr2VO5YkspYINnvu81inSz2y3ODJrhO175/Exzor1RcEZZkizgE2A+w/CAXXoESS8Kys5E62dOHGHzULA==", + "dependencies": { + "ansi-colors": "^4.1.3", + "browser-stdout": "^1.3.1", + "chokidar": "^3.5.3", + "debug": "^4.3.5", + "diff": "^5.2.0", + "escape-string-regexp": "^4.0.0", + "find-up": "^5.0.0", + "glob": "^8.1.0", + "he": "^1.2.0", + "js-yaml": "^4.1.0", + "log-symbols": "^4.1.0", + "minimatch": "^5.1.6", + "ms": "^2.1.3", + "serialize-javascript": "^6.0.2", + "strip-json-comments": "^3.1.1", + "supports-color": "^8.1.1", + "workerpool": "^6.5.1", + "yargs": "^16.2.0", + "yargs-parser": "^20.2.9", + "yargs-unparser": "^2.0.0" }, "bin": { "_mocha": "bin/_mocha", @@ -15041,70 +14995,27 @@ }, "engines": { "node": ">= 14.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/mochajs" - } - }, - "node_modules/mocha/node_modules/ansi-colors": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", - "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==", - "engines": { - "node": ">=6" } }, "node_modules/mocha/node_modules/glob": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", - "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz", + "integrity": "sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==", + "deprecated": "Glob versions prior to v9 are no longer supported", "dependencies": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" + "minimatch": "^5.0.1", + "once": "^1.3.0" }, "engines": { - "node": "*" + "node": ">=12" }, "funding": { "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/mocha/node_modules/glob/node_modules/brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dependencies": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "node_modules/mocha/node_modules/glob/node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, - "node_modules/mocha/node_modules/minimatch": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz", - "integrity": "sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g==", - "dependencies": { - "brace-expansion": "^2.0.1" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/mock-fs": { "version": "4.14.0", "resolved": "https://registry.npmjs.org/mock-fs/-/mock-fs-4.14.0.tgz", @@ -15403,17 +15314,6 @@ "resolved": "https://registry.npmjs.org/nano-json-stream-parser/-/nano-json-stream-parser-0.1.2.tgz", "integrity": "sha512-9MqxMH/BSJC7dnLsEMPyfN5Dvoo49IsPFYMcHw3Bcfc2kN0lpHRBSzlMSVx4HGyJ7s9B31CyBTVehWJoQ8Ctew==" }, - "node_modules/nanoid": { - "version": "3.3.3", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.3.tgz", - "integrity": "sha512-p1sjXuopFs0xg+fPASzQ28agW1oHD7xDsd9Xkf3T15H3c/cifrFHVwrh74PdoklAPi+i7MdRsE47vm2r6JoB+w==", - "bin": { - "nanoid": "bin/nanoid.cjs" - }, - "engines": { - "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" - } - }, "node_modules/napi-macros": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/napi-macros/-/napi-macros-2.0.0.tgz", @@ -15528,9 +15428,9 @@ } }, "node_modules/node-fetch": { - "version": "2.6.7", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz", - "integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==", + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", + "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", "dependencies": { "whatwg-url": "^5.0.0" }, @@ -15546,14 +15446,6 @@ } } }, - "node_modules/node-forge": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-1.3.1.tgz", - "integrity": "sha512-dPEtOeMvF9VMcYV/1Wb8CPoVAXtp6MKMlcbAt4ddqmGqUJ6fQZFXkNZNkNlfevtNkGtaSoXf/vNNNSvgrdXwtA==", - "engines": { - "node": ">= 6.13.0" - } - }, "node_modules/node-gyp-build": { "version": "4.5.0", "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.5.0.tgz", @@ -18124,9 +18016,9 @@ "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" }, "node_modules/serialize-javascript": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.0.tgz", - "integrity": "sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag==", + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.2.tgz", + "integrity": "sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g==", "dependencies": { "randombytes": "^2.1.0" } @@ -18253,6 +18145,11 @@ "node": ">=8" } }, + "node_modules/shimmer": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/shimmer/-/shimmer-1.2.1.tgz", + "integrity": "sha512-sQTKC1Re/rM6XyFM6fIAGHRPVGvyXfgzIDvzoq608vM+jeyVD0Tu1E6Np0Kc2zAIFWIj963V2800iF/9LPieQw==" + }, "node_modules/side-channel": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz", @@ -18385,9 +18282,9 @@ } }, "node_modules/slugify": { - "version": "1.6.5", - "resolved": "https://registry.npmjs.org/slugify/-/slugify-1.6.5.tgz", - "integrity": "sha512-8mo9bslnBO3tr5PEVFzMPIWwWnipGS0xVbYf65zxDqfNwmzYn1LpiKNrR6DlClusuvo+hDHd1zKpmfAe83NQSQ==", + "version": "1.6.6", + "resolved": "https://registry.npmjs.org/slugify/-/slugify-1.6.6.tgz", + "integrity": "sha512-h+z7HKHYXj6wJU+AnS/+IH8Uh9fdcX1Lrhg1/VMdf9PwoBQXFcXiAdsy2tSK0P6gKwJLXp02r90ahUCqHk9rrw==", "engines": { "node": ">=8.0.0" } @@ -18574,6 +18471,11 @@ "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", "integrity": "sha512-KXXFFdAbFXY4geFIwoyNK+f5Z1b7swfXABfL7HXCmoIWMKU3dmS26672A4EeQtDzLKy7SXmfBu51JolvEKwtGA==" }, + "node_modules/stack-chain": { + "version": "1.3.7", + "resolved": "https://registry.npmjs.org/stack-chain/-/stack-chain-1.3.7.tgz", + "integrity": "sha512-D8cWtWVdIe/jBA7v5p5Hwl5yOSOrmZPWDPe2KxQ5UAGD+nxbxU0lKXA4h85Ta6+qgdKVL3vUxsbIZjc1kBG7ug==" + }, "node_modules/stacktrace-parser": { "version": "0.1.10", "resolved": "https://registry.npmjs.org/stacktrace-parser/-/stacktrace-parser-0.1.10.tgz", @@ -20022,14 +19924,6 @@ "node": ">=12" } }, - "node_modules/typeorm/node_modules/dotenv": { - "version": "16.0.3", - "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz", - "integrity": "sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ==", - "engines": { - "node": ">=12" - } - }, "node_modules/typeorm/node_modules/glob": { "version": "10.3.10", "resolved": "https://registry.npmjs.org/glob/-/glob-10.3.10.tgz", @@ -20792,25 +20686,6 @@ "node-fetch": "^2.6.12" } }, - "node_modules/web3-providers-http/node_modules/node-fetch": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", - "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", - "dependencies": { - "whatwg-url": "^5.0.0" - }, - "engines": { - "node": "4.x || >=6.0.0" - }, - "peerDependencies": { - "encoding": "^0.1.0" - }, - "peerDependenciesMeta": { - "encoding": { - "optional": true - } - } - }, "node_modules/web3-providers-ipc": { "version": "1.10.4", "resolved": "https://registry.npmjs.org/web3-providers-ipc/-/web3-providers-ipc-1.10.4.tgz", @@ -21101,9 +20976,9 @@ "integrity": "sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q==" }, "node_modules/workerpool": { - "version": "6.2.1", - "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.2.1.tgz", - "integrity": "sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw==" + "version": "6.5.1", + "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.5.1.tgz", + "integrity": "sha512-Fs4dNYcsdpYSAfVxhnl1L5zTksjvOJxtC5hzMNl+1t9B8hTJTdKDyZ5ju7ztgPy+ft9tBFXoOlDNiOT9WUXZlA==" }, "node_modules/wrap-ansi": { "version": "7.0.0", @@ -21279,9 +21154,9 @@ } }, "node_modules/yargs-parser": { - "version": "20.2.4", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.4.tgz", - "integrity": "sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA==", + "version": "20.2.9", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz", + "integrity": "sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==", "engines": { "node": ">=10" } diff --git a/package.json b/package.json index 95392122a..af06f2739 100644 --- a/package.json +++ b/package.json @@ -2,14 +2,15 @@ "name": "giveth-graphql-api", "version": "1.24.1", "description": "Backend GraphQL server for Giveth originally forked from Topia", - "main": "./dist/index.js", + "type": "module", + "exports": "./src/index.ts", "dependencies": { "@adminjs/design-system": "3.1.5", "@adminjs/express": "5.0.1", "@adminjs/typeorm": "4.0.0", "@apollo/server": "4.10.0", "@apollo/server-plugin-landing-page-graphql-playground": "^4.0.1", - "@chainvine/sdk": "1.1.10", + "@chainvine/sdk": "1.6.1", "@giveth/monoswap": "^1.3.4", "@pinata/sdk": "^2.1.0", "@safe-global/api-kit": "^2.0.0", @@ -32,14 +33,14 @@ "cookie-parser": "^1.4.5", "cors": "^2.8.5", "csvtojson": "^2.0.10", - "dotenv": "^8.2.0", + "dotenv": "16.4.5", "ethers": "^5.7.2", "express": "^4.19.2", "express-formidable": "^1.2.0", "express-rate-limit": "^7.1.5", "express-session": "^1.17.3", "form-data": "^3.0.1", - "google-spreadsheet": "^3.2.0", + "google-spreadsheet": "^4.1.2", "graphql": "16.8.1", "graphql-fields": "^2.0.3", "graphql-tag": "^2.12.6", @@ -54,7 +55,9 @@ "js-sha256": "^0.9.0", "json-stable-stringify": "^1.0.2", "jsonwebtoken": "^9.0.0", + "jsonwebtoken-esm": "^2.0.1", "lodash": "^4.17.21", + "lodash-es": "^4.17.21", "marked": "^4.2.5", "moment": "^2.29.4", "node-cron": "^3.0.2", @@ -62,7 +65,7 @@ "rate-limit-redis": "^4.2.0", "reflect-metadata": "^0.1.13", "siwe": "^1.1.6", - "slugify": "^1.4.7", + "slugify": "^1.6.6", "stripe": "^8.137.0", "threads": "^1.7.0", "twitter-api-sdk": "^1.0.9", @@ -79,20 +82,28 @@ }, "devDependencies": { "@types/axios": "^0.14.0", + "@types/bcrypt": "^5.0.2", + "@types/bcryptjs": "^2.4.6", "@types/bull": "^3.15.5", "@types/chai": "^4.2.15", "@types/connect-redis": "0.0.23", "@types/cors": "^2.8.10", "@types/dotenv": "^8.2.0", "@types/express": "^4.17.21", + "@types/google-spreadsheet": "^4.0.0", "@types/graphql-upload": "15.0.2", + "@types/html-pdf-node": "^1.0.2", "@types/html-to-text": "^9.0.0", - "@types/jsonwebtoken": "^8.5.0", + "@types/i18n": "^0.13.12", + "@types/json-stable-stringify": "^1.0.36", + "@types/jsonwebtoken": "^8.5.9", "@types/lodash": "^4.14.197", + "@types/lodash-es": "^4.17.12", "@types/marked": "^4.0.8", - "@types/mocha": "^8.2.1", + "@types/mocha": "^10.0.7", "@types/node": "^14.14.31", "@types/node-cron": "^3.0.0", + "@types/sinon": "^17.0.3", "@typescript-eslint/eslint-plugin": "^7.2.0", "@typescript-eslint/parser": "^7.2.0", "chai": "^4.3.0", @@ -103,7 +114,7 @@ "eslint-plugin-unused-imports": "^3.1.0", "husky": "^4.3.8", "lint-staged": "^10.5.4", - "mocha": "^10.2.0", + "mocha": "^10.7.0", "prettier": "^3.2.5", "sinon": "^13.0.1", "ts-node": "10.9.2", @@ -113,11 +124,11 @@ "scripts": { "eslint": "eslint {src,test,migration}/**/*.ts", "eslint:fix": "eslint --fix {src,test,migration}/**/*.ts", - "test": "NODE_ENV=test mocha --config ./.mocharc.all-test.json", + "test": "NODE_ENV=test node --no-warnings=ExperimentalWarning --loader ts-node/esm ./node_modules/mocha/bin/mocha --config ./.mocharc.all-test.json", "test:syncProjectsRequiredForListing": "NODE_ENV=test mocha ./test/pre-test-scripts.ts ./src/services/cronJobs/syncProjectsRequiredForListing.test.ts", "test:migrations": "NODE_ENV=test mocha ./test/pre-test-scripts.ts migration/tests/*.ts", "test:backupDonationImport": "NODE_ENV=test mocha ./test/pre-test-scripts.ts ./src/services/cronJobs/backupDonationImport.test.ts", - "test:projectEntity": "NODE_ENV=test mocha ./test/pre-test-scripts.ts ./src/entities/project.test.ts", + "test:projectEntity": "NODE_ENV=test node --no-warnings=ExperimentalWarning --loader ts-node/esm ./node_modules/mocha/bin/mocha ./test/pre-test-scripts.ts ./src/entities/project.test.ts", "test:projectValidators": "NODE_ENV=test mocha ./test/pre-test-scripts.ts ./src/utils/validators/projectValidator.test.ts", "test:onramperWebhook": "NODE_ENV=test mocha ./test/pre-test-scripts.ts ./src/services/onramper/webhookHandler.test.ts", "test:powerSnapshotRepository": "NODE_ENV=test mocha ./test/pre-test-scripts.ts ./src/repositories/powerSnapshotRepository.test.ts", @@ -201,21 +212,21 @@ "test:sybilTab": "NODE_ENV=test mocha ./test/pre-test-scripts.ts ./src/server/adminJs/tabs/sybilTab.test.ts ", "test:projectFraudTab": "NODE_ENV=test mocha ./test/pre-test-scripts.ts ./src/server/adminJs/tabs/projectFraudTab.test.ts", "test:poignArt": "NODE_ENV=test mocha ./test/pre-test-scripts.ts ./src/services/poignArt/api.test.ts", - "test:bootstrap": "NODE_ENV=test mocha ./test/pre-test-scripts.ts ./src/server/bootstrap.test.ts", + "test:bootstrap": "NODE_ENV=test node --no-warnings=ExperimentalWarning --loader ts-node/esm ./node_modules/mocha/bin/mocha ./test/pre-test-scripts.ts ./src/server/bootstrap.test.ts", "test:utils": "NODE_ENV=test mocha ./src/utils/utils.test.ts", - "start": "NODE_ENV=development ts-node-dev --project ./tsconfig.json --respawn ./src/index.ts", - "start:test": "NODE_ENV=development ts-node-dev --project ./tsconfig.json --respawn ./test.ts", + "start": "NODE_ENV=development node --no-warnings=ExperimentalWarning --loader ts-node/esm ./src/index.ts", + "start:test": "NODE_ENV=development node --no-warnings=ExperimentalWarning --loader ts-node/esm ./src/test.ts", "serve": "pm2 startOrRestart ecosystem.config.js --node-args='--max-old-space-size=8192'", - "db:migrate:run:test": "NODE_ENV=test npx typeorm-ts-node-commonjs migration:run -d ./src/ormconfig.ts", - "db:migrate:revert:test": "NODE_ENV=test npx typeorm-ts-node-commonjs migration:revert -d ./src/ormconfig.ts", - "db:migrate:run:local": "NODE_ENV=development npx typeorm-ts-node-commonjs migration:run -d ./src/ormconfig.ts", - "db:migrate:revert:local": "NODE_ENV=development npx typeorm-ts-node-commonjs migration:revert -d ./src/ormconfig.ts", - "db:migrate:run:production": "NODE_ENV=production npx typeorm-ts-node-commonjs migration:run -d ./src/ormconfig.ts", - "db:migrate:rever:productiont": "NODE_ENV=production npx typeorm-ts-node-commonjs migration:revert -d ./src/ormconfig.ts", + "db:migrate:run:test": "NODE_ENV=test npx typeorm-ts-node-esm migration:run -d ./src/ormconfig.ts", + "db:migrate:revert:test": "NODE_ENV=test npx typeorm-ts-node-esm migration:revert -d ./src/ormconfig.ts", + "db:migrate:run:local": "NODE_ENV=development npx typeorm-ts-node-esm migration:run -d ./src/migration.config.ts", + "db:migrate:revert:local": "NODE_ENV=development npx typeorm-ts-node-esm migration:revert -d ./src/ormconfig.ts", + "db:migrate:run:production": "NODE_ENV=production npx typeorm-ts-node-esm migration:run -d ./src/ormconfig.ts", + "db:migrate:rever:productiont": "NODE_ENV=production npx typeorm-ts-node-esm migration:revert -d ./src/ormconfig.ts", "prettify": "prettier --write '**/*.ts*' '**/*.test.ts*'", "db:migrate:seedToken:run": "NODE_ENV=development ts-node ./node_modules/typeorm/cli -f ./src/seedToken-ormconfig.ts migration:run", "db:migrate:seedToken:revert": "NODE_ENV=development ts-node ./node_modules/typeorm/cli -f ./src/seedToken-ormconfig.ts migration:revert", - "build": "rm -rf ./build && tsc && mkdir ./build/config && mkdir ./build/src/server/adminJs/tabs/components && cp -r src/server/adminJs/tabs/components/* ./build/src/server/adminJs/tabs/components/ && mkdir ./build/src/utils/locales && cp -r ./src/utils/locales/* ./build/src/utils/locales/ && cp -r ./src/abi build/src/abi ", + "build": "rm -rf ./build && tsc && mkdir -p ./build/config && mkdir -p ./build/src/server/adminJs/tabs/components && cp -r src/server/adminJs/tabs/components/* ./build/src/server/adminJs/tabs/components/ && mkdir -p ./build/src/utils/locales && cp -r ./src/utils/locales/* ./build/src/utils/locales/ && cp -r ./src/abi build/src/abi", "dev": "NODE_ENV=development node ./build/src/index.js", "production": "NODE_ENV=production node ./build/src/index.js", "start:docker:server": "npm run db:migrate:run:production && npm run production", diff --git a/src/adapters/adaptersFactory.ts b/src/adapters/adaptersFactory.ts index 7c5964527..70ad84f59 100644 --- a/src/adapters/adaptersFactory.ts +++ b/src/adapters/adaptersFactory.ts @@ -1,27 +1,26 @@ -import { SocialNetworkOauth2AdapterInterface } from './oauth2/SocialNetworkOauth2AdapterInterface'; -import { DiscordAdapter } from './oauth2/discordAdapter'; -import { SOCIAL_NETWORKS } from '../entities/socialProfile'; -import { i18n, translationErrorMessagesKeys } from '../utils/errorMessages'; -import { GoogleAdapter } from './oauth2/googleAdapter'; -import { LinkedinAdapter } from './oauth2/linkedinAdapter'; -import { TwitterAdapter } from './oauth2/twitterAdapter'; -import { NotificationAdapterInterface } from './notifications/NotificationAdapterInterface'; -import { NotificationCenterAdapter } from './notifications/NotificationCenterAdapter'; -import { MockNotificationAdapter } from './notifications/MockNotificationAdapter'; -import { GivPowerSubgraphAdapter } from './givpowerSubgraph/givPowerSubgraphAdapter'; -import { GivPowerSubgraphAdapterMock } from './givpowerSubgraph/givPowerSubgraphAdapterMock'; -import { ChainvineAdapter } from './chainvine/chainvineAdapter'; -import { ChainvineMockAdapter } from './chainvine/chainvineMockAdapter'; -import { IGivPowerSubgraphAdapter } from './givpowerSubgraph/IGivPowerSubgraphAdapter'; -import { GitcoinAdapter } from './gitcoin/gitcoinAdapter'; -import { GitcoinMockAdapter } from './gitcoin/gitcoinMockAdapter'; -import { GivPowerBalanceAggregatorAdapter } from './givPowerBalanceAggregator/givPowerBalanceAggregatorAdapter'; -import { GivPowerBalanceAggregatorAdapterMock } from './givPowerBalanceAggregator/givPowerBalanceAggregatorAdapterMock'; -import { DonationSaveBackupAdapter } from './donationSaveBackup/donationSaveBackupAdapter'; -import { DonationSaveBackupMockAdapter } from './donationSaveBackup/DonationSaveBackupMockAdapter'; -import { SuperFluidAdapter } from './superFluid/superFluidAdapter'; -import { SuperFluidMockAdapter } from './superFluid/superFluidMockAdapter'; -import { SuperFluidAdapterInterface } from './superFluid/superFluidAdapterInterface'; +import { SocialNetworkOauth2AdapterInterface } from './oauth2/SocialNetworkOauth2AdapterInterface.js'; +import { DiscordAdapter } from './oauth2/discordAdapter.js'; +import { SOCIAL_NETWORKS } from '../entities/socialProfile.js'; +import { i18n, translationErrorMessagesKeys } from '../utils/errorMessages.js'; +import { GoogleAdapter } from './oauth2/googleAdapter.js'; +import { LinkedinAdapter } from './oauth2/linkedinAdapter.js'; +import { TwitterAdapter } from './oauth2/twitterAdapter.js'; +import { NotificationAdapterInterface } from './notifications/NotificationAdapterInterface.js'; +import { NotificationCenterAdapter } from './notifications/NotificationCenterAdapter.js'; +import { MockNotificationAdapter } from './notifications/MockNotificationAdapter.js'; +import { GivPowerSubgraphAdapter } from './givpowerSubgraph/givPowerSubgraphAdapter.js'; +import { GivPowerSubgraphAdapterMock } from './givpowerSubgraph/givPowerSubgraphAdapterMock.js'; +import { ChainvineMockAdapter } from './chainvine/chainvineMockAdapter.js'; +import { IGivPowerSubgraphAdapter } from './givpowerSubgraph/IGivPowerSubgraphAdapter.js'; +import { GitcoinAdapter } from './gitcoin/gitcoinAdapter.js'; +import { GitcoinMockAdapter } from './gitcoin/gitcoinMockAdapter.js'; +import { GivPowerBalanceAggregatorAdapter } from './givPowerBalanceAggregator/givPowerBalanceAggregatorAdapter.js'; +import { GivPowerBalanceAggregatorAdapterMock } from './givPowerBalanceAggregator/givPowerBalanceAggregatorAdapterMock.js'; +import { DonationSaveBackupAdapter } from './donationSaveBackup/donationSaveBackupAdapter.js'; +import { DonationSaveBackupMockAdapter } from './donationSaveBackup/DonationSaveBackupMockAdapter.js'; +import { SuperFluidAdapter } from './superFluid/superFluidAdapter.js'; +import { SuperFluidMockAdapter } from './superFluid/superFluidMockAdapter.js'; +import { SuperFluidAdapterInterface } from './superFluid/superFluidAdapterInterface.js'; const discordAdapter = new DiscordAdapter(); const googleAdapter = new GoogleAdapter(); @@ -77,13 +76,12 @@ export const getGivPowerSubgraphAdapter = (): IGivPowerSubgraphAdapter => { } }; -const chainvineAdapter = new ChainvineAdapter(); const mockChainvineAdapter = new ChainvineMockAdapter(); export const getChainvineAdapter = () => { switch (process.env.CHAINVINE_ADAPTER) { case 'chainvine': - return chainvineAdapter; + return mockChainvineAdapter; case 'mock': return mockChainvineAdapter; default: diff --git a/src/adapters/chainvine/chainvineAdapter.ts b/src/adapters/chainvine/chainvineAdapter.ts index 0c52d6bc0..9e5dbfc20 100644 --- a/src/adapters/chainvine/chainvineAdapter.ts +++ b/src/adapters/chainvine/chainvineAdapter.ts @@ -4,9 +4,9 @@ import { ChainvineAdapterInterface, LinkDonorToChainvineReferrerType, NotifyChainVineInputType, -} from './chainvineAdapterInterface'; -import { errorMessages } from '../../utils/errorMessages'; -import { logger } from '../../utils/logger'; +} from './chainvineAdapterInterface.js'; +import { errorMessages } from '../../utils/errorMessages.js'; +import { logger } from '../../utils/logger.js'; export interface ChainvineRetrieveWalletResponse extends Response { wallet_address?: string; diff --git a/src/adapters/chainvine/chainvineMockAdapter.ts b/src/adapters/chainvine/chainvineMockAdapter.ts index 318603074..ba6cc546c 100644 --- a/src/adapters/chainvine/chainvineMockAdapter.ts +++ b/src/adapters/chainvine/chainvineMockAdapter.ts @@ -1,8 +1,8 @@ -import { ChainvineAdapterInterface } from './chainvineAdapterInterface'; +import { ChainvineAdapterInterface } from './chainvineAdapterInterface.js'; import { generateRandomEtheriumAddress, generateHexNumber, -} from '../../../test/testUtils'; +} from '../../../test/testUtils.js'; export const cachedReferralIds = {}; diff --git a/src/adapters/donationSaveBackup/DonationSaveBackupMockAdapter.ts b/src/adapters/donationSaveBackup/DonationSaveBackupMockAdapter.ts index 29ff72d5d..b6073b0c9 100644 --- a/src/adapters/donationSaveBackup/DonationSaveBackupMockAdapter.ts +++ b/src/adapters/donationSaveBackup/DonationSaveBackupMockAdapter.ts @@ -1,7 +1,7 @@ import { DonationSaveBackupInterface, FetchedSavedFailDonationInterface, -} from './DonationSaveBackupInterface'; +} from './DonationSaveBackupInterface.js'; export class DonationSaveBackupMockAdapter implements DonationSaveBackupInterface diff --git a/src/adapters/donationSaveBackup/donationSaveBackupAdapter.ts b/src/adapters/donationSaveBackup/donationSaveBackupAdapter.ts index c4bd380f4..7f13ac07f 100644 --- a/src/adapters/donationSaveBackup/donationSaveBackupAdapter.ts +++ b/src/adapters/donationSaveBackup/donationSaveBackupAdapter.ts @@ -3,12 +3,12 @@ // also must support pagination import axios from 'axios'; -import { logger } from '../../utils/logger'; -import config from '../../config'; +import { logger } from '../../utils/logger.js'; +import config from '../../config.js'; import { DonationSaveBackupInterface, FetchedSavedFailDonationInterface, -} from './DonationSaveBackupInterface'; +} from './DonationSaveBackupInterface.js'; const DONATION_SAVE_BACKUP_API_URL = config.get( 'DONATION_SAVE_BACKUP_API_URL', diff --git a/src/adapters/gitcoin/gitcoinAdapter.ts b/src/adapters/gitcoin/gitcoinAdapter.ts index 2aa3cd419..1ce8b7965 100644 --- a/src/adapters/gitcoin/gitcoinAdapter.ts +++ b/src/adapters/gitcoin/gitcoinAdapter.ts @@ -6,9 +6,12 @@ import { SubmittedPassportResponse, SubmittedPassportsResponse, GetPassportStampsResponse, -} from './gitcoinAdapterInterface'; -import { logger } from '../../utils/logger'; -import { i18n, translationErrorMessagesKeys } from '../../utils/errorMessages'; +} from './gitcoinAdapterInterface.js'; +import { logger } from '../../utils/logger.js'; +import { + i18n, + translationErrorMessagesKeys, +} from '../../utils/errorMessages.js'; const GITCOIN_API_BASE_URL = 'https://api.scorer.gitcoin.co'; diff --git a/src/adapters/gitcoin/gitcoinMockAdapter.ts b/src/adapters/gitcoin/gitcoinMockAdapter.ts index 9e7c88ae7..30961f3a4 100644 --- a/src/adapters/gitcoin/gitcoinMockAdapter.ts +++ b/src/adapters/gitcoin/gitcoinMockAdapter.ts @@ -5,7 +5,7 @@ import { SubmittedPassportResponse, SubmittedPassportsResponse, GetPassportStampsResponse, -} from './gitcoinAdapterInterface'; +} from './gitcoinAdapterInterface.js'; export const cachedReferralAddresses = {}; diff --git a/src/adapters/givPowerBalanceAggregator/givPowerBalanceAggregatorAdapter.ts b/src/adapters/givPowerBalanceAggregator/givPowerBalanceAggregatorAdapter.ts index 69c2e4df1..587219434 100644 --- a/src/adapters/givPowerBalanceAggregator/givPowerBalanceAggregatorAdapter.ts +++ b/src/adapters/givPowerBalanceAggregator/givPowerBalanceAggregatorAdapter.ts @@ -6,9 +6,9 @@ import { LatestBalanceInputParams, NetworksInputParams, IGivPowerBalanceAggregator, -} from '../../types/GivPowerBalanceAggregator'; -import { logger } from '../../utils/logger'; -import { formatGivPowerBalance } from '../givpowerSubgraph/givPowerSubgraphAdapter'; +} from '../../types/GivPowerBalanceAggregator.js'; +import { logger } from '../../utils/logger.js'; +import { formatGivPowerBalance } from '../givpowerSubgraph/givPowerSubgraphAdapter.js'; const formatResponse = (balance: { address: string; diff --git a/src/adapters/givPowerBalanceAggregator/givPowerBalanceAggregatorAdapterMock.ts b/src/adapters/givPowerBalanceAggregator/givPowerBalanceAggregatorAdapterMock.ts index 8af86f797..cd34417e8 100644 --- a/src/adapters/givPowerBalanceAggregator/givPowerBalanceAggregatorAdapterMock.ts +++ b/src/adapters/givPowerBalanceAggregator/givPowerBalanceAggregatorAdapterMock.ts @@ -4,8 +4,8 @@ import { BalanceResponse, LatestBalanceInputParams, IGivPowerBalanceAggregator, -} from '../../types/GivPowerBalanceAggregator'; -import { convertTimeStampToSeconds } from '../../utils/utils'; +} from '../../types/GivPowerBalanceAggregator.js'; +import { convertTimeStampToSeconds } from '../../utils/utils.js'; export class GivPowerBalanceAggregatorAdapterMock implements IGivPowerBalanceAggregator diff --git a/src/adapters/givpowerSubgraph/givPowerSubgraphAdapter.test.ts b/src/adapters/givpowerSubgraph/givPowerSubgraphAdapter.test.ts index bcdd7accd..2ca2cd423 100644 --- a/src/adapters/givpowerSubgraph/givPowerSubgraphAdapter.test.ts +++ b/src/adapters/givpowerSubgraph/givPowerSubgraphAdapter.test.ts @@ -1,7 +1,7 @@ import { assert } from 'chai'; -import { formatGivPowerBalance } from './givPowerSubgraphAdapter'; -import { generateRandomEtheriumAddress } from '../../../test/testUtils'; -import { givPowerSubgraphAdapter } from '../adaptersFactory'; +import { formatGivPowerBalance } from './givPowerSubgraphAdapter.js'; +import { generateRandomEtheriumAddress } from '../../../test/testUtils.js'; +import { givPowerSubgraphAdapter } from '../adaptersFactory.js'; describe( 'getUserPowerBalanceInBlockNumber() test cases', diff --git a/src/adapters/givpowerSubgraph/givPowerSubgraphAdapter.ts b/src/adapters/givpowerSubgraph/givPowerSubgraphAdapter.ts index 4e340e0b5..8a00e0e5e 100644 --- a/src/adapters/givpowerSubgraph/givPowerSubgraphAdapter.ts +++ b/src/adapters/givpowerSubgraph/givPowerSubgraphAdapter.ts @@ -4,8 +4,9 @@ import { BlockInfo, IGivPowerSubgraphAdapter, UnipoolBalance, -} from './IGivPowerSubgraphAdapter'; +} from './IGivPowerSubgraphAdapter.js'; +// @ts-expect-error migrate to ESM const _toBN = (n: string | number) => new BigNumber(n); export const formatGivPowerBalance = (balance: string | number): number => Number( diff --git a/src/adapters/givpowerSubgraph/givPowerSubgraphAdapterMock.ts b/src/adapters/givpowerSubgraph/givPowerSubgraphAdapterMock.ts index fb4a17e1a..40f890ce6 100644 --- a/src/adapters/givpowerSubgraph/givPowerSubgraphAdapterMock.ts +++ b/src/adapters/givpowerSubgraph/givPowerSubgraphAdapterMock.ts @@ -2,8 +2,8 @@ import { IGivPowerSubgraphAdapter, BlockInfo, UnipoolBalance, -} from './IGivPowerSubgraphAdapter'; -import { sleep } from '../../utils/utils'; +} from './IGivPowerSubgraphAdapter.js'; +import { sleep } from '../../utils/utils.js'; export class GivPowerSubgraphAdapterMock implements IGivPowerSubgraphAdapter { nextCallResult: any = null; diff --git a/src/adapters/notifications/MockNotificationAdapter.ts b/src/adapters/notifications/MockNotificationAdapter.ts index e47a3825c..ce7aa3dba 100644 --- a/src/adapters/notifications/MockNotificationAdapter.ts +++ b/src/adapters/notifications/MockNotificationAdapter.ts @@ -3,12 +3,12 @@ import { NotificationAdapterInterface, OrttoPerson, ProjectsHaveNewRankingInputParam, -} from './NotificationAdapterInterface'; -import { Donation } from '../../entities/donation'; -import { Project } from '../../entities/project'; -import { User } from '../../entities/user'; -import { logger } from '../../utils/logger'; -import { RecurringDonation } from '../../entities/recurringDonation'; +} from './NotificationAdapterInterface.js'; +import { Donation } from '../../entities/donation.js'; +import { Project } from '../../entities/project.js'; +import { User } from '../../entities/user.js'; +import { logger } from '../../utils/logger.js'; +import { RecurringDonation } from '../../entities/recurringDonation.js'; export class MockNotificationAdapter implements NotificationAdapterInterface { async subscribeOnboarding(params: { email: string }): Promise { diff --git a/src/adapters/notifications/NotificationAdapterInterface.ts b/src/adapters/notifications/NotificationAdapterInterface.ts index 7e19aaacb..2167f309c 100644 --- a/src/adapters/notifications/NotificationAdapterInterface.ts +++ b/src/adapters/notifications/NotificationAdapterInterface.ts @@ -1,7 +1,7 @@ -import { Donation } from '../../entities/donation'; -import { Project } from '../../entities/project'; -import { UserStreamBalanceWarning, User } from '../../entities/user'; -import { RecurringDonation } from '../../entities/recurringDonation'; +import { Donation } from '../../entities/donation.js'; +import { Project } from '../../entities/project.js'; +import { UserStreamBalanceWarning, User } from '../../entities/user.js'; +import { RecurringDonation } from '../../entities/recurringDonation.js'; export interface BroadCastNotificationInputParams { broadCastNotificationId: number; diff --git a/src/adapters/notifications/NotificationCenterAdapter.ts b/src/adapters/notifications/NotificationCenterAdapter.ts index 840c46866..43782c9ca 100644 --- a/src/adapters/notifications/NotificationCenterAdapter.ts +++ b/src/adapters/notifications/NotificationCenterAdapter.ts @@ -5,28 +5,28 @@ import { NotificationAdapterInterface, OrttoPerson, ProjectsHaveNewRankingInputParam, -} from './NotificationAdapterInterface'; -import { Donation } from '../../entities/donation'; -import { Project } from '../../entities/project'; -import { UserStreamBalanceWarning, User } from '../../entities/user'; -import { createBasicAuthentication, isProduction } from '../../utils/utils'; -import { logger } from '../../utils/logger'; -import { NOTIFICATIONS_EVENT_NAMES } from '../../analytics/analytics'; -import { redisConfig } from '../../redis'; -import config from '../../config'; -import { findProjectById } from '../../repositories/projectRepository'; +} from './NotificationAdapterInterface.js'; +import { Donation } from '../../entities/donation.js'; +import { Project } from '../../entities/project.js'; +import { UserStreamBalanceWarning, User } from '../../entities/user.js'; +import { createBasicAuthentication, isProduction } from '../../utils/utils.js'; +import { logger } from '../../utils/logger.js'; +import { NOTIFICATIONS_EVENT_NAMES } from '../../analytics/analytics.js'; +import { redisConfig } from '../../redis.js'; +import config from '../../config.js'; +import { findProjectById } from '../../repositories/projectRepository.js'; import { findAllUsers, findUserById, findUsersWhoSupportProject, -} from '../../repositories/userRepository'; -import { buildProjectLink } from './NotificationCenterUtils'; -import { buildTxLink } from '../../utils/networks'; -import { RecurringDonation } from '../../entities/recurringDonation'; -import { getTokenPrice } from '../../services/priceService'; -import { Token } from '../../entities/token'; -import { toFixNumber } from '../../services/donationService'; -import { findOrganizationById } from '../../repositories/organizationRepository'; +} from '../../repositories/userRepository.js'; +import { buildProjectLink } from './NotificationCenterUtils.js'; +import { buildTxLink } from '../../utils/networks.js'; +import { RecurringDonation } from '../../entities/recurringDonation.js'; +import { getTokenPrice } from '../../services/priceService.js'; +import { Token } from '../../entities/token.js'; +import { toFixNumber } from '../../services/donationService.js'; +import { findOrganizationById } from '../../repositories/organizationRepository.js'; const notificationCenterUsername = process.env.NOTIFICATION_CENTER_USERNAME; const notificationCenterPassword = process.env.NOTIFICATION_CENTER_PASSWORD; const notificationCenterBaseUrl = process.env.NOTIFICATION_CENTER_BASE_URL; diff --git a/src/adapters/notifications/NotificationCenterUtils.ts b/src/adapters/notifications/NotificationCenterUtils.ts index 14b787d7b..1e7235c86 100644 --- a/src/adapters/notifications/NotificationCenterUtils.ts +++ b/src/adapters/notifications/NotificationCenterUtils.ts @@ -1,4 +1,4 @@ -import { NOTIFICATIONS_EVENT_NAMES } from '../../analytics/analytics'; +import { NOTIFICATIONS_EVENT_NAMES } from '../../analytics/analytics.js'; export const buildProjectLink = ( eventName: NOTIFICATIONS_EVENT_NAMES, diff --git a/src/adapters/oauth2/discordAdapter.ts b/src/adapters/oauth2/discordAdapter.ts index 181affc26..c6f016bf9 100644 --- a/src/adapters/oauth2/discordAdapter.ts +++ b/src/adapters/oauth2/discordAdapter.ts @@ -2,8 +2,8 @@ import axios from 'axios'; import { GetUserInfoByOauth2Output, SocialNetworkOauth2AdapterInterface, -} from './SocialNetworkOauth2AdapterInterface'; -import { logger } from '../../utils/logger'; +} from './SocialNetworkOauth2AdapterInterface.js'; +import { logger } from '../../utils/logger.js'; export class DiscordAdapter implements SocialNetworkOauth2AdapterInterface { // https://discordjs.guide/oauth2/#getting-an-oauth2-url diff --git a/src/adapters/oauth2/googleAdapter.ts b/src/adapters/oauth2/googleAdapter.ts index 87df5305a..fd3d39f25 100644 --- a/src/adapters/oauth2/googleAdapter.ts +++ b/src/adapters/oauth2/googleAdapter.ts @@ -1,12 +1,15 @@ import { stringify } from 'querystring'; import axios from 'axios'; -import { decode, JwtPayload } from 'jsonwebtoken'; +import { decode, JwtPayload } from 'jsonwebtoken-esm'; import { GetUserInfoByOauth2Output, SocialNetworkOauth2AdapterInterface, -} from './SocialNetworkOauth2AdapterInterface'; -import { logger } from '../../utils/logger'; -import { i18n, translationErrorMessagesKeys } from '../../utils/errorMessages'; +} from './SocialNetworkOauth2AdapterInterface.js'; +import { logger } from '../../utils/logger.js'; +import { + i18n, + translationErrorMessagesKeys, +} from '../../utils/errorMessages.js'; const clientId = process.env.GOOGLE_CLIENT_ID; const clientSecret = process.env.GOOGLE_CLIENT_SECRET; diff --git a/src/adapters/oauth2/linkedinAdapter.ts b/src/adapters/oauth2/linkedinAdapter.ts index d063226c8..22be6b2fa 100644 --- a/src/adapters/oauth2/linkedinAdapter.ts +++ b/src/adapters/oauth2/linkedinAdapter.ts @@ -3,9 +3,12 @@ import axios from 'axios'; import { GetUserInfoByOauth2Output, SocialNetworkOauth2AdapterInterface, -} from './SocialNetworkOauth2AdapterInterface'; -import { logger } from '../../utils/logger'; -import { i18n, translationErrorMessagesKeys } from '../../utils/errorMessages'; +} from './SocialNetworkOauth2AdapterInterface.js'; +import { logger } from '../../utils/logger.js'; +import { + i18n, + translationErrorMessagesKeys, +} from '../../utils/errorMessages.js'; const clientId = process.env.LINKEDIN_CLIENT_ID; const clientSecret = process.env.LINKEDIN_CLIENT_SECRET; diff --git a/src/adapters/oauth2/mockOauth2Adapter.ts b/src/adapters/oauth2/mockOauth2Adapter.ts index b44992154..ae4cd7620 100644 --- a/src/adapters/oauth2/mockOauth2Adapter.ts +++ b/src/adapters/oauth2/mockOauth2Adapter.ts @@ -1,8 +1,11 @@ import { GetUserInfoByOauth2Output, SocialNetworkOauth2AdapterInterface, -} from './SocialNetworkOauth2AdapterInterface'; -import { i18n, translationErrorMessagesKeys } from '../../utils/errorMessages'; +} from './SocialNetworkOauth2AdapterInterface.js'; +import { + i18n, + translationErrorMessagesKeys, +} from '../../utils/errorMessages.js'; export class MockOauth2Adapter implements SocialNetworkOauth2AdapterInterface { async getAuthUrl(): Promise { diff --git a/src/adapters/oauth2/twitterAdapter.ts b/src/adapters/oauth2/twitterAdapter.ts index ba43e147d..14c09d8e9 100644 --- a/src/adapters/oauth2/twitterAdapter.ts +++ b/src/adapters/oauth2/twitterAdapter.ts @@ -1,11 +1,12 @@ import { auth } from 'twitter-api-sdk'; +// @ts-expect-error migrate to ESM import { OAuth2User } from 'twitter-api-sdk/dist/OAuth2User'; import axios from 'axios'; -import { logger } from '../../utils/logger'; +import { logger } from '../../utils/logger.js'; import { GetUserInfoByOauth2Output, SocialNetworkOauth2AdapterInterface, -} from './SocialNetworkOauth2AdapterInterface'; +} from './SocialNetworkOauth2AdapterInterface.js'; export class TwitterAdapter implements SocialNetworkOauth2AdapterInterface { private authClient: OAuth2User; diff --git a/src/adapters/price/CoingeckoPriceAdapter.ts b/src/adapters/price/CoingeckoPriceAdapter.ts index c13925468..c21777d66 100644 --- a/src/adapters/price/CoingeckoPriceAdapter.ts +++ b/src/adapters/price/CoingeckoPriceAdapter.ts @@ -3,9 +3,9 @@ import { GetTokenPriceAtDateParams, GetTokenPriceParams, PriceAdapterInterface, -} from './PriceAdapterInterface'; -import { getRedisObject, setObjectInRedis } from '../../redis'; -import { logger } from '../../utils/logger'; +} from './PriceAdapterInterface.js'; +import { getRedisObject, setObjectInRedis } from '../../redis.js'; +import { logger } from '../../utils/logger.js'; const coingeckoCacheExpirationInSeconds = Number(process.env.COINGECKO_CACHE_EXPIRATION_IN_SECONDS) || 60 * 60 * 24; // 1 hour diff --git a/src/adapters/price/CryptoComparePriceAdapter.ts b/src/adapters/price/CryptoComparePriceAdapter.ts index 240e3eba5..9a568b137 100644 --- a/src/adapters/price/CryptoComparePriceAdapter.ts +++ b/src/adapters/price/CryptoComparePriceAdapter.ts @@ -2,9 +2,9 @@ import axios from 'axios'; import { GetTokenPriceParams, PriceAdapterInterface, -} from './PriceAdapterInterface'; -import { getRedisObject, setObjectInRedis } from '../../redis'; -import { logger } from '../../utils/logger'; +} from './PriceAdapterInterface.js'; +import { getRedisObject, setObjectInRedis } from '../../redis.js'; +import { logger } from '../../utils/logger.js'; const cryptoCompareCacheExpirationInSeconds = Number(process.env.COINGECKO_CACHE_EXPIRATION_IN_SECONDS) || 60 * 60 * 24 * 7; // 1 hour diff --git a/src/adapters/price/MonoswapPriceAdapter.ts b/src/adapters/price/MonoswapPriceAdapter.ts index ff12b202e..deaef4733 100644 --- a/src/adapters/price/MonoswapPriceAdapter.ts +++ b/src/adapters/price/MonoswapPriceAdapter.ts @@ -1,10 +1,11 @@ +// @ts-expect-error migrate to ESM import { CHAIN_ID } from '@giveth/monoswap/dist/src/sdk/sdkFactory'; import { GetTokenPriceParams, PriceAdapterInterface, -} from './PriceAdapterInterface'; -import { getMonoSwapTokenPrices } from '../../services/donationService'; -import { logger } from '../../utils/logger'; +} from './PriceAdapterInterface.js'; +import { getMonoSwapTokenPrices } from '../../services/donationService.js'; +import { logger } from '../../utils/logger.js'; export class MonoswapPriceAdapter implements PriceAdapterInterface { async getTokenPrice(params: GetTokenPriceParams): Promise { diff --git a/src/adapters/superFluid/superFluidAdapter.ts b/src/adapters/superFluid/superFluidAdapter.ts index 39a684a7f..e466587a8 100644 --- a/src/adapters/superFluid/superFluidAdapter.ts +++ b/src/adapters/superFluid/superFluidAdapter.ts @@ -1,10 +1,10 @@ import axios from 'axios'; -import { logger } from '../../utils/logger'; -import { isProduction } from '../../utils/utils'; +import { logger } from '../../utils/logger.js'; +import { isProduction } from '../../utils/utils.js'; import { FlowUpdatedEvent, SuperFluidAdapterInterface, -} from './superFluidAdapterInterface'; +} from './superFluidAdapterInterface.js'; const superFluidGraphqlUrl = 'https://subgraph-endpoints.superfluid.dev/optimism-mainnet/protocol-v1'; diff --git a/src/adapters/superFluid/superFluidMockAdapter.ts b/src/adapters/superFluid/superFluidMockAdapter.ts index bd99190f8..c90e14b93 100644 --- a/src/adapters/superFluid/superFluidMockAdapter.ts +++ b/src/adapters/superFluid/superFluidMockAdapter.ts @@ -1,7 +1,7 @@ import { FlowUpdatedEvent, SuperFluidAdapterInterface, -} from './superFluidAdapterInterface'; +} from './superFluidAdapterInterface.js'; export class SuperFluidMockAdapter implements SuperFluidAdapterInterface { async streamPeriods() { diff --git a/src/auth/userCheck.ts b/src/auth/userCheck.ts index 296d9a1ab..e99f7c470 100644 --- a/src/auth/userCheck.ts +++ b/src/auth/userCheck.ts @@ -1,5 +1,5 @@ import { AuthChecker } from 'type-graphql'; -import { Context } from '../context'; +import { Context } from '../context.js'; export const userCheck: AuthChecker = () => { // here we can read the user from context diff --git a/src/config.ts b/src/config.ts index be3f52e62..53018479d 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1,23 +1,18 @@ import path from 'path'; -import * as dotenv from 'dotenv'; +import { fileURLToPath } from 'url'; +import dotenv from 'dotenv'; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); const configPath = path.resolve( __dirname, `../config/${process.env.NODE_ENV || ''}.env`, ); -const loadConfigResult = dotenv.config({ +dotenv.config({ path: configPath, }); -if (loadConfigResult.error) { - // eslint-disable-next-line no-console - console.log('Load process.env error', { - path: configPath, - error: loadConfigResult.error, - }); - throw loadConfigResult.error; -} - const envVars = [ 'JWT_SECRET', 'JWT_MAX_AGE', diff --git a/src/context.ts b/src/context.ts index 3ce619507..897514bda 100644 --- a/src/context.ts +++ b/src/context.ts @@ -1,4 +1,4 @@ -import { User } from './entities/user'; +import { User } from './entities/user.js'; export interface Context { user: User; diff --git a/src/entities/ProjectActualMatchingView.ts b/src/entities/ProjectActualMatchingView.ts index d6c1bee50..914b84406 100644 --- a/src/entities/ProjectActualMatchingView.ts +++ b/src/entities/ProjectActualMatchingView.ts @@ -7,8 +7,9 @@ import { ManyToOne, ViewColumn, JoinColumn, + Relation, } from 'typeorm'; -import { Project } from './project'; +import { Project } from './project.js'; @ViewEntity('project_actual_matching_view', { synchronize: false }) @ObjectType() @@ -16,7 +17,7 @@ export class ProjectActualMatchingView extends BaseEntity { @Field(_type => Project) @ManyToOne(_type => Project, project => project.projectEstimatedMatchingView) @JoinColumn({ referencedColumnName: 'id' }) - project: Project; + project: Relation; @Field() @ViewColumn() diff --git a/src/entities/ProjectEstimatedMatchingView.ts b/src/entities/ProjectEstimatedMatchingView.ts index 4583d7b7b..348adda07 100644 --- a/src/entities/ProjectEstimatedMatchingView.ts +++ b/src/entities/ProjectEstimatedMatchingView.ts @@ -8,8 +8,9 @@ import { ManyToOne, ViewColumn, JoinColumn, + Relation, } from 'typeorm'; -import { Project } from './project'; +import { Project } from './project.js'; @ViewEntity('project_estimated_matching_view', { synchronize: false }) @Index('project_estimated_matching_view_project_id_qfround_id', [ @@ -22,7 +23,7 @@ export class ProjectEstimatedMatchingView extends BaseEntity { @Field(_type => Project) @ManyToOne(_type => Project, project => project.projectEstimatedMatchingView) @JoinColumn({ referencedColumnName: 'id' }) - project: Project; + project: Relation; @Field() @ViewColumn() diff --git a/src/entities/accountVerification.ts b/src/entities/accountVerification.ts index f3ff44eb3..e6845aa01 100644 --- a/src/entities/accountVerification.ts +++ b/src/entities/accountVerification.ts @@ -9,8 +9,9 @@ import { Index, CreateDateColumn, UpdateDateColumn, + Relation, } from 'typeorm'; -import { User } from './user'; +import { User } from './user.js'; @Entity() @ObjectType() @@ -43,7 +44,7 @@ export class AccountVerification extends BaseEntity { @Index() @Field(_type => User) @ManyToOne(_type => User, { eager: true }) - user: User; + user: Relation; @RelationId( (accountVerification: AccountVerification) => accountVerification.user, diff --git a/src/entities/anchorContractAddress.ts b/src/entities/anchorContractAddress.ts index 68484cc5d..d6a07c27e 100644 --- a/src/entities/anchorContractAddress.ts +++ b/src/entities/anchorContractAddress.ts @@ -6,13 +6,14 @@ import { Index, ManyToOne, PrimaryGeneratedColumn, + Relation, RelationId, Unique, UpdateDateColumn, } from 'typeorm'; import { Field, ID, ObjectType } from 'type-graphql'; -import { Project } from './project'; -import { User } from './user'; +import { Project } from './project.js'; +import { User } from './user.js'; @Entity() @ObjectType() @@ -43,7 +44,7 @@ export class AnchorContractAddress extends BaseEntity { @Index() @Field(_type => Project) @ManyToOne(_type => Project) - project: Project; + project: Relation; @RelationId((relatedAddress: AnchorContractAddress) => relatedAddress.project) @Column({ nullable: true }) @@ -52,7 +53,7 @@ export class AnchorContractAddress extends BaseEntity { @Index() @Field(_type => User, { nullable: true }) @ManyToOne(_type => User, { eager: true, nullable: true }) - creator: User; + creator: Relation; @RelationId( (anchorContractAddress: AnchorContractAddress) => @@ -64,7 +65,7 @@ export class AnchorContractAddress extends BaseEntity { @Index() @Field(_type => User, { nullable: true }) @ManyToOne(_type => User, { eager: true, nullable: true }) - owner: User; + owner: Relation; @RelationId( (anchorContractAddress: AnchorContractAddress) => diff --git a/src/entities/broadcastNotification.ts b/src/entities/broadcastNotification.ts index 1c046943b..53c7f750c 100644 --- a/src/entities/broadcastNotification.ts +++ b/src/entities/broadcastNotification.ts @@ -6,9 +6,10 @@ import { Entity, ManyToOne, PrimaryGeneratedColumn, + Relation, RelationId, } from 'typeorm'; -import { User } from './user'; +import { User } from './user.js'; export enum BROAD_CAST_NOTIFICATION_STATUS { PENDING = 'pending', @@ -32,7 +33,8 @@ export default class BroadcastNotification extends BaseEntity { @Field(_type => User, { nullable: true }) @ManyToOne(_type => User, { eager: true, nullable: true }) - adminUser: User; + adminUser: Relation; + @RelationId( (broadcastNotification: BroadcastNotification) => broadcastNotification.adminUser, diff --git a/src/entities/campaign.ts b/src/entities/campaign.ts index 744d48d02..282c94cde 100644 --- a/src/entities/campaign.ts +++ b/src/entities/campaign.ts @@ -7,7 +7,7 @@ import { UpdateDateColumn, CreateDateColumn, } from 'typeorm'; -import { Project } from './project'; +import { Project } from './project.js'; // Copied from projects enums export enum CampaignSortingField { diff --git a/src/entities/category.ts b/src/entities/category.ts index c906389e5..af8d62cbc 100644 --- a/src/entities/category.ts +++ b/src/entities/category.ts @@ -8,8 +8,8 @@ import { ManyToOne, RelationId, } from 'typeorm'; -import { Project } from './project'; -import { MainCategory } from './mainCategory'; +import { Project } from './project.js'; +import { MainCategory } from './mainCategory.js'; export const CATEGORY_NAMES = { // There are lots of categories but I put the ones that I use here diff --git a/src/entities/donation.ts b/src/entities/donation.ts index 1cf3b028b..513ce5bc8 100644 --- a/src/entities/donation.ts +++ b/src/entities/donation.ts @@ -7,12 +7,13 @@ import { ManyToOne, RelationId, Index, + Relation, } from 'typeorm'; -import { Project } from './project'; -import { User } from './user'; -import { QfRound } from './qfRound'; -import { ChainType } from '../types/network'; -import { RecurringDonation } from './recurringDonation'; +import { Project } from './project.js'; +import { User } from './user.js'; +import { QfRound } from './qfRound.js'; +import { ChainType } from '../types/network.js'; +import { RecurringDonation } from './recurringDonation.js'; export const DONATION_STATUS = { PENDING: 'pending', @@ -170,7 +171,7 @@ export class Donation extends BaseEntity { @Index() @Field(_type => Project) @ManyToOne(_type => Project, { eager: true }) - project: Project; + project: Relation; @RelationId((donation: Donation) => donation.project) @Column({ nullable: true }) diff --git a/src/entities/draftDonation.ts b/src/entities/draftDonation.ts index 9fc0e1f3f..aa801b5c9 100644 --- a/src/entities/draftDonation.ts +++ b/src/entities/draftDonation.ts @@ -7,7 +7,7 @@ import { Index, CreateDateColumn, } from 'typeorm'; -import { ChainType } from '../types/network'; +import { ChainType } from '../types/network.js'; export const DRAFT_DONATION_STATUS = { PENDING: 'pending', diff --git a/src/entities/draftRecurringDonation.ts b/src/entities/draftRecurringDonation.ts index f96140198..b8164227d 100644 --- a/src/entities/draftRecurringDonation.ts +++ b/src/entities/draftRecurringDonation.ts @@ -7,7 +7,7 @@ import { Index, CreateDateColumn, } from 'typeorm'; -import { ChainType } from '../types/network'; +import { ChainType } from '../types/network.js'; export const DRAFT_RECURRING_DONATION_STATUS = { PENDING: 'pending', diff --git a/src/entities/entities.ts b/src/entities/entities.ts index feeb0d0f6..623c80220 100644 --- a/src/entities/entities.ts +++ b/src/entities/entities.ts @@ -1,56 +1,56 @@ import { DataSourceOptions } from 'typeorm'; -import { Organization } from './organization'; -import { Category } from './category'; -import { Token } from './token'; -import { Donation } from './donation'; -import { Wallet } from './wallet'; -import { ProjectStatus } from './projectStatus'; -import { ProjectImage } from './projectImage'; -import { BankAccount, StripeTransaction } from './bankAccount'; -import { AccountVerification } from './accountVerification'; -import { ProjectStatusReason } from './projectStatusReason'; -import { ProjectStatusHistory } from './projectStatusHistory'; -import { ThirdPartyProjectImport } from './thirdPartyProjectImport'; -import { ProjectVerificationForm } from './projectVerificationForm'; -import { ProjectAddress } from './projectAddress'; -import { SocialProfile } from './socialProfile'; -import { MainCategory } from './mainCategory'; -import { PowerBoosting } from './powerBoosting'; -import { UserProjectPowerView } from '../views/userProjectPowerView'; -import { ProjectUserInstantPowerView } from '../views/projectUserInstantPowerView'; -import { PowerRound } from './powerRound'; -import { ProjectPowerView } from '../views/projectPowerView'; -import { PowerSnapshot } from './powerSnapshot'; -import { PowerBalanceSnapshot } from './powerBalanceSnapshot'; -import { PowerBoostingSnapshot } from './powerBoostingSnapshot'; -import { ProjectFuturePowerView } from '../views/projectFuturePowerView'; -import { PowerSnapshotHistory } from './powerSnapshotHistory'; -import { PowerBalanceSnapshotHistory } from './powerBalanceSnapshotHistory'; -import { PowerBoostingSnapshotHistory } from './powerBoostingSnapshotHistory'; -import { LastSnapshotProjectPowerView } from '../views/lastSnapshotProjectPowerView'; -import { User } from './user'; -import { Project, ProjectUpdate } from './project'; -import { Reaction } from './reaction'; -import BroadcastNotification from './broadcastNotification'; -import { FeaturedUpdate } from './featuredUpdate'; -import { Campaign } from './campaign'; -import { PreviousRoundRank } from './previousRoundRank'; -import { InstantPowerBalance } from './instantPowerBalance'; -import { InstantPowerFetchState } from './instantPowerFetchState'; -import { ProjectInstantPowerView } from '../views/projectInstantPowerView'; -import { QfRound } from './qfRound'; -import { ReferredEvent } from './referredEvent'; -import { QfRoundHistory } from './qfRoundHistory'; -import { ProjectEstimatedMatchingView } from './ProjectEstimatedMatchingView'; -import { AnchorContractAddress } from './anchorContractAddress'; -import { RecurringDonation } from './recurringDonation'; -import { Sybil } from './sybil'; -import { DraftDonation } from './draftDonation'; -import { ProjectFraud } from './projectFraud'; -import { ProjectActualMatchingView } from './ProjectActualMatchingView'; -import { ProjectSocialMedia } from './projectSocialMedia'; -import { DraftRecurringDonation } from './draftRecurringDonation'; -import { UserQfRoundModelScore } from './userQfRoundModelScore'; +import { Category } from './category.js'; +import { Token } from './token.js'; +import { Donation } from './donation.js'; +import { Wallet } from './wallet.js'; +import { ProjectStatus } from './projectStatus.js'; +import { ProjectImage } from './projectImage.js'; +import { BankAccount, StripeTransaction } from './bankAccount.js'; +import { AccountVerification } from './accountVerification.js'; +import { ProjectStatusReason } from './projectStatusReason.js'; +import { ProjectStatusHistory } from './projectStatusHistory.js'; +import { ThirdPartyProjectImport } from './thirdPartyProjectImport.js'; +import { ProjectVerificationForm } from './projectVerificationForm.js'; +import { ProjectAddress } from './projectAddress.js'; +import { SocialProfile } from './socialProfile.js'; +import { MainCategory } from './mainCategory.js'; +import { PowerBoosting } from './powerBoosting.js'; +import { UserProjectPowerView } from '../views/userProjectPowerView.js'; +import { ProjectUserInstantPowerView } from '../views/projectUserInstantPowerView.js'; +import { PowerRound } from './powerRound.js'; +import { ProjectPowerView } from '../views/projectPowerView.js'; +import { PowerSnapshot } from './powerSnapshot.js'; +import { PowerBalanceSnapshot } from './powerBalanceSnapshot.js'; +import { PowerBoostingSnapshot } from './powerBoostingSnapshot.js'; +import { ProjectFuturePowerView } from '../views/projectFuturePowerView.js'; +import { PowerSnapshotHistory } from './powerSnapshotHistory.js'; +import { PowerBalanceSnapshotHistory } from './powerBalanceSnapshotHistory.js'; +import { PowerBoostingSnapshotHistory } from './powerBoostingSnapshotHistory.js'; +import { LastSnapshotProjectPowerView } from '../views/lastSnapshotProjectPowerView.js'; +import { User } from './user.js'; +import { Project, ProjectUpdate } from './project.js'; +import { Reaction } from './reaction.js'; +import BroadcastNotification from './broadcastNotification.js'; +import { FeaturedUpdate } from './featuredUpdate.js'; +import { Campaign } from './campaign.js'; +import { PreviousRoundRank } from './previousRoundRank.js'; +import { InstantPowerBalance } from './instantPowerBalance.js'; +import { InstantPowerFetchState } from './instantPowerFetchState.js'; +import { ProjectInstantPowerView } from '../views/projectInstantPowerView.js'; +import { QfRound } from './qfRound.js'; +import { ReferredEvent } from './referredEvent.js'; +import { QfRoundHistory } from './qfRoundHistory.js'; +import { ProjectEstimatedMatchingView } from './ProjectEstimatedMatchingView.js'; +import { AnchorContractAddress } from './anchorContractAddress.js'; +import { RecurringDonation } from './recurringDonation.js'; +import { Sybil } from './sybil.js'; +import { DraftDonation } from './draftDonation.js'; +import { ProjectFraud } from './projectFraud.js'; +import { ProjectActualMatchingView } from './ProjectActualMatchingView.js'; +import { ProjectSocialMedia } from './projectSocialMedia.js'; +import { DraftRecurringDonation } from './draftRecurringDonation.js'; +import { UserQfRoundModelScore } from './userQfRoundModelScore.js'; +import { Organization } from './organization.js'; export const getEntities = (): DataSourceOptions['entities'] => { return [ diff --git a/src/entities/featuredUpdate.ts b/src/entities/featuredUpdate.ts index 5b815d464..c99d4851a 100644 --- a/src/entities/featuredUpdate.ts +++ b/src/entities/featuredUpdate.ts @@ -1,4 +1,4 @@ -import { Field, ID, ObjectType } from 'type-graphql'; +import { Field, ID, ObjectType, Int } from 'type-graphql'; import { BaseEntity, Column, @@ -8,11 +8,11 @@ import { JoinColumn, OneToOne, PrimaryGeneratedColumn, + Relation, RelationId, UpdateDateColumn, } from 'typeorm'; -import { Int } from 'type-graphql/dist/scalars/aliases'; -import { Project, ProjectUpdate } from './project'; +import { Project, ProjectUpdate } from './project.js'; @Entity() @ObjectType() @@ -25,7 +25,7 @@ export class FeaturedUpdate extends BaseEntity { @Field(_type => Project) @OneToOne(_type => Project) @JoinColumn() - project: Project; + project: Relation; @RelationId((featuredUpdate: FeaturedUpdate) => featuredUpdate.project) @Column({ nullable: true }) @@ -35,7 +35,7 @@ export class FeaturedUpdate extends BaseEntity { @Field(_type => ProjectUpdate) @OneToOne(_type => ProjectUpdate) @JoinColumn() - projectUpdate: ProjectUpdate; + projectUpdate: Relation; @RelationId((featuredUpdate: FeaturedUpdate) => featuredUpdate.projectUpdate) @Column({ nullable: true }) diff --git a/src/entities/instantPowerFetchState.ts b/src/entities/instantPowerFetchState.ts index 31d4e0b5c..56c40c5cd 100644 --- a/src/entities/instantPowerFetchState.ts +++ b/src/entities/instantPowerFetchState.ts @@ -1,6 +1,6 @@ import { BaseEntity, Check, Column, Entity, PrimaryColumn } from 'typeorm'; import { Field, ObjectType } from 'type-graphql'; -import { ColumnBigIntTransformer } from '../utils/entities'; +import { ColumnBigIntTransformer } from '../utils/entities.js'; @Entity() @ObjectType() diff --git a/src/entities/mainCategory.ts b/src/entities/mainCategory.ts index 35bbf6529..34d8af447 100644 --- a/src/entities/mainCategory.ts +++ b/src/entities/mainCategory.ts @@ -6,7 +6,7 @@ import { OneToMany, PrimaryGeneratedColumn, } from 'typeorm'; -import { Category } from './category'; +import { Category } from './category.js'; @Entity() @ObjectType() diff --git a/src/entities/organization.ts b/src/entities/organization.ts index dbd7acfc7..2837b1c10 100644 --- a/src/entities/organization.ts +++ b/src/entities/organization.ts @@ -7,9 +7,10 @@ import { ManyToMany, OneToMany, JoinTable, + Relation, } from 'typeorm'; -import { Project } from './project'; -import { Token } from './token'; +import { Project } from './project.js'; +import { Token } from './token.js'; @Entity() @ObjectType() @@ -49,12 +50,12 @@ export class Organization extends BaseEntity { @Field(_type => [Project], { nullable: true }) @OneToMany(_type => Project, project => project.organization) - projects?: Project[]; + projects?: Relation[]; @Field(_type => [Token], { nullable: true }) @ManyToMany(_type => Token, token => token.organizations) @JoinTable() - tokens: Token[]; + tokens: Relation[]; } export const ORGANIZATION_LABELS = { diff --git a/src/entities/powerBalanceSnapshot.ts b/src/entities/powerBalanceSnapshot.ts index 84750b46d..d8d4e99b4 100644 --- a/src/entities/powerBalanceSnapshot.ts +++ b/src/entities/powerBalanceSnapshot.ts @@ -7,8 +7,9 @@ import { Index, RelationId, ManyToOne, + Relation, } from 'typeorm'; -import { PowerSnapshot } from './powerSnapshot'; +import { PowerSnapshot } from './powerSnapshot.js'; @Entity() @ObjectType() @@ -38,5 +39,5 @@ export class PowerBalanceSnapshot extends BaseEntity { @Field(_type => PowerSnapshot, { nullable: false }) @ManyToOne(_type => PowerSnapshot, { nullable: false }) - powerSnapshot: PowerSnapshot; + powerSnapshot: Relation; } diff --git a/src/entities/powerBoosting.ts b/src/entities/powerBoosting.ts index 932916e1c..e2b77d7ce 100644 --- a/src/entities/powerBoosting.ts +++ b/src/entities/powerBoosting.ts @@ -6,14 +6,15 @@ import { Index, ManyToOne, PrimaryGeneratedColumn, + Relation, RelationId, UpdateDateColumn, } from 'typeorm'; import { Field, Float, ID, ObjectType } from 'type-graphql'; import { Max, Min, IsNumber } from 'class-validator'; -import { Project } from './project'; -import { User } from './user'; -import { ColumnNumericTransformer } from '../utils/entities'; +import { Project } from './project.js'; +import { User } from './user.js'; +import { ColumnNumericTransformer } from '../utils/entities.js'; @Entity() @ObjectType() @@ -25,7 +26,7 @@ export class PowerBoosting extends BaseEntity { @Field(_type => Project) @ManyToOne(_type => Project, { eager: true }) - project: Project; + project: Relation; @Index() @RelationId((powerBoosting: PowerBoosting) => powerBoosting.project) @@ -34,7 +35,7 @@ export class PowerBoosting extends BaseEntity { @Field(_type => User) @ManyToOne(_type => User, { eager: true }) - user: User; + user: Relation; @Index() @RelationId((powerBoosting: PowerBoosting) => powerBoosting.user) diff --git a/src/entities/powerBoostingSnapshot.ts b/src/entities/powerBoostingSnapshot.ts index b033caaf2..5b7d65f7e 100644 --- a/src/entities/powerBoostingSnapshot.ts +++ b/src/entities/powerBoostingSnapshot.ts @@ -5,12 +5,13 @@ import { Index, ManyToOne, PrimaryGeneratedColumn, + Relation, RelationId, } from 'typeorm'; import { Field, Float, ID, ObjectType } from 'type-graphql'; -import { User } from './user'; -import { ColumnNumericTransformer } from '../utils/entities'; -import { PowerSnapshot } from './powerSnapshot'; +import { User } from './user.js'; +import { ColumnNumericTransformer } from '../utils/entities.js'; +import { PowerSnapshot } from './powerSnapshot.js'; @Entity() @ObjectType() @@ -30,7 +31,7 @@ export class PowerBoostingSnapshot extends BaseEntity { @Field(_type => User, { nullable: false }) @ManyToOne(_type => User, { nullable: false }) - user: User; + user: Relation; @Field(_type => ID) @Column() diff --git a/src/entities/powerBoostingSnapshotHistory.ts b/src/entities/powerBoostingSnapshotHistory.ts index bfb5f2bd7..33008f57a 100644 --- a/src/entities/powerBoostingSnapshotHistory.ts +++ b/src/entities/powerBoostingSnapshotHistory.ts @@ -1,6 +1,6 @@ import { BaseEntity, Column, Entity, PrimaryColumn } from 'typeorm'; import { Field, Float, ID, ObjectType } from 'type-graphql'; -import { ColumnNumericTransformer } from '../utils/entities'; +import { ColumnNumericTransformer } from '../utils/entities.js'; @Entity() @ObjectType() diff --git a/src/entities/powerSnapshot.ts b/src/entities/powerSnapshot.ts index 332e9c7ef..88962ff50 100644 --- a/src/entities/powerSnapshot.ts +++ b/src/entities/powerSnapshot.ts @@ -7,9 +7,9 @@ import { Index, OneToMany, } from 'typeorm'; -import { PowerBoostingSnapshot } from './powerBoostingSnapshot'; -import { PowerBalanceSnapshot } from './powerBalanceSnapshot'; -import { ColumnDateTransformer } from '../utils/entities'; +import { PowerBoostingSnapshot } from './powerBoostingSnapshot.js'; +import { PowerBalanceSnapshot } from './powerBalanceSnapshot.js'; +import { ColumnDateTransformer } from '../utils/entities.js'; @Entity() @ObjectType() diff --git a/src/entities/previousRoundRank.ts b/src/entities/previousRoundRank.ts index 5402e846c..b2dbdc749 100644 --- a/src/entities/previousRoundRank.ts +++ b/src/entities/previousRoundRank.ts @@ -6,12 +6,13 @@ import { Index, ManyToOne, PrimaryGeneratedColumn, + Relation, RelationId, Unique, UpdateDateColumn, } from 'typeorm'; import { Field, ID, ObjectType } from 'type-graphql'; -import { Project } from './project'; +import { Project } from './project.js'; @Entity() @ObjectType() @@ -24,7 +25,7 @@ export class PreviousRoundRank extends BaseEntity { @Index() @Field(_type => Project) @ManyToOne(_type => Project) - project: Project; + project: Relation; @RelationId( (previousRoundRank: PreviousRoundRank) => previousRoundRank.project, diff --git a/src/entities/project.test.ts b/src/entities/project.test.ts index 76d63b5bd..4fe6a4846 100644 --- a/src/entities/project.test.ts +++ b/src/entities/project.test.ts @@ -1,13 +1,13 @@ import { assert } from 'chai'; -import { Project, ProjectUpdate, ProjStatus } from './project'; +import { Project, ProjectUpdate, ProjStatus } from './project.js'; import { createProjectData, saveProjectDirectlyToDb, SEED_DATA, -} from '../../test/testUtils'; -import { ProjectStatus } from './projectStatus'; -import { ProjectStatusReason } from './projectStatusReason'; -import { findOneProjectStatusHistoryByProjectId } from '../repositories/projectSatusHistoryRepository'; +} from '../../test/testUtils.js'; +import { ProjectStatus } from './projectStatus.js'; +import { ProjectStatusReason } from './projectStatusReason.js'; +import { findOneProjectStatusHistoryByProjectId } from '../repositories/projectSatusHistoryRepository.js'; describe( 'addProjectStatusHistoryRecord() test cases', diff --git a/src/entities/project.ts b/src/entities/project.ts index 83adb224c..5ac22ddf8 100644 --- a/src/entities/project.ts +++ b/src/entities/project.ts @@ -1,4 +1,4 @@ -import { Field, Float, ID, ObjectType } from 'type-graphql'; +import { Field, Float, ID, ObjectType, Int } from 'type-graphql'; import { AfterInsert, AfterUpdate, @@ -19,39 +19,37 @@ import { JoinTable, } from 'typeorm'; -import { Int } from 'type-graphql/dist/scalars/aliases'; -import { Donation } from './donation'; -import { Reaction } from './reaction'; -import { User } from './user'; -import { ProjectStatus } from './projectStatus'; -import { ProjectStatusHistory } from './projectStatusHistory'; -import { ProjectStatusReason } from './projectStatusReason'; -import { i18n, translationErrorMessagesKeys } from '../utils/errorMessages'; -import { Organization } from './organization'; -import { findUserById } from '../repositories/userRepository'; -import { SocialProfile } from './socialProfile'; -import { ProjectVerificationForm } from './projectVerificationForm'; -import { ProjectAddress } from './projectAddress'; -import { ProjectContacts } from './projectVerificationForm'; -import { ProjectPowerView } from '../views/projectPowerView'; -import { ProjectFuturePowerView } from '../views/projectFuturePowerView'; -import { ProjectInstantPowerView } from '../views/projectInstantPowerView'; -import { Category } from './category'; -import { FeaturedUpdate } from './featuredUpdate'; -import { getHtmlTextSummary } from '../utils/utils'; -import { QfRound } from './qfRound'; +import moment from 'moment'; +import { Donation } from './donation.js'; +import { Reaction } from './reaction.js'; +import { User } from './user.js'; +import { ProjectStatus } from './projectStatus.js'; +import { ProjectStatusHistory } from './projectStatusHistory.js'; +import { ProjectStatusReason } from './projectStatusReason.js'; +import { i18n, translationErrorMessagesKeys } from '../utils/errorMessages.js'; +import { Organization } from './organization.js'; +import { findUserById } from '../repositories/userRepository.js'; +import { SocialProfile } from './socialProfile.js'; +import { ProjectVerificationForm } from './projectVerificationForm.js'; +import { ProjectAddress } from './projectAddress.js'; +import { ProjectContacts } from './projectVerificationForm.js'; +import { ProjectPowerView } from '../views/projectPowerView.js'; +import { ProjectFuturePowerView } from '../views/projectFuturePowerView.js'; +import { ProjectInstantPowerView } from '../views/projectInstantPowerView.js'; +import { Category } from './category.js'; +import { FeaturedUpdate } from './featuredUpdate.js'; +import { getHtmlTextSummary } from '../utils/utils.js'; +import { QfRound } from './qfRound.js'; import { getQfRoundTotalSqrtRootSumSquared, getProjectDonationsSqrtRootSum, findActiveQfRound, -} from '../repositories/qfRoundRepository'; -import { EstimatedMatching } from '../types/qfTypes'; -import { Campaign } from './campaign'; -import { ProjectEstimatedMatchingView } from './ProjectEstimatedMatchingView'; -import { AnchorContractAddress } from './anchorContractAddress'; -import { ProjectSocialMedia } from './projectSocialMedia'; -// eslint-disable-next-line @typescript-eslint/no-var-requires -const moment = require('moment'); +} from '../repositories/qfRoundRepository.js'; +import { EstimatedMatching } from '../types/qfTypes.js'; +import { Campaign } from './campaign.js'; +import { ProjectEstimatedMatchingView } from './ProjectEstimatedMatchingView.js'; +import { AnchorContractAddress } from './anchorContractAddress.js'; +import { ProjectSocialMedia } from './projectSocialMedia.js'; export enum ProjStatus { rejected = 1, diff --git a/src/entities/projectAddress.ts b/src/entities/projectAddress.ts index 02134207e..80f8bb322 100644 --- a/src/entities/projectAddress.ts +++ b/src/entities/projectAddress.ts @@ -6,14 +6,15 @@ import { Index, ManyToOne, PrimaryGeneratedColumn, + Relation, RelationId, Unique, UpdateDateColumn, } from 'typeorm'; import { Field, ID, ObjectType } from 'type-graphql'; -import { Project } from './project'; -import { User } from './user'; -import { ChainType } from '../types/network'; +import { Project } from './project.js'; +import { User } from './user.js'; +import { ChainType } from '../types/network.js'; @Entity() @ObjectType() @@ -48,7 +49,7 @@ export class ProjectAddress extends BaseEntity { @Index() @Field(_type => Project) @ManyToOne(_type => Project) - project: Project; + project: Relation; @RelationId((relatedAddress: ProjectAddress) => relatedAddress.project) @Column({ nullable: true }) @@ -57,7 +58,7 @@ export class ProjectAddress extends BaseEntity { @Index() @Field(_type => User, { nullable: true }) @ManyToOne(_type => User, { eager: true, nullable: true }) - user: User; + user: Relation; @RelationId((relatedAddress: ProjectAddress) => relatedAddress.user) @Column({ nullable: true }) diff --git a/src/entities/projectFraud.ts b/src/entities/projectFraud.ts index 9042827a5..2f1932e61 100644 --- a/src/entities/projectFraud.ts +++ b/src/entities/projectFraud.ts @@ -7,9 +7,10 @@ import { RelationId, BaseEntity, Unique, + Relation, } from 'typeorm'; -import { Project } from './project'; -import { QfRound } from './qfRound'; +import { Project } from './project.js'; +import { QfRound } from './qfRound.js'; @ObjectType() @Entity() @@ -21,7 +22,7 @@ export class ProjectFraud extends BaseEntity { @Field(_type => Project) @ManyToOne(_type => Project, { eager: true }) - project: Project; + project: Relation; @RelationId((projectFraud: ProjectFraud) => projectFraud.project) @Column() diff --git a/src/entities/projectImage.ts b/src/entities/projectImage.ts index e344b267b..62d67a781 100644 --- a/src/entities/projectImage.ts +++ b/src/entities/projectImage.ts @@ -6,8 +6,9 @@ import { BaseEntity, ManyToOne, RelationId, + Relation, } from 'typeorm'; -import { Project } from './project'; +import { Project } from './project.js'; @Entity() @ObjectType() @@ -18,7 +19,7 @@ export class ProjectImage extends BaseEntity { @Field(_type => Project) @ManyToOne(_type => Project, { eager: true }) - project: Project; + project: Relation; @RelationId((projectImage: ProjectImage) => projectImage.project) @Column({ nullable: true }) diff --git a/src/entities/projectSocialMedia.ts b/src/entities/projectSocialMedia.ts index 8516a17ab..0a9d2d0aa 100644 --- a/src/entities/projectSocialMedia.ts +++ b/src/entities/projectSocialMedia.ts @@ -5,12 +5,13 @@ import { Index, ManyToOne, PrimaryGeneratedColumn, + Relation, RelationId, } from 'typeorm'; import { Field, ID, ObjectType } from 'type-graphql'; -import { Project } from './project'; -import { User } from './user'; -import { ProjectSocialMediaType } from '../types/projectSocialMediaType'; +import { Project } from './project.js'; +import { User } from './user.js'; +import { ProjectSocialMediaType } from '../types/projectSocialMediaType.js'; @Entity() @ObjectType() @@ -34,7 +35,7 @@ export class ProjectSocialMedia extends BaseEntity { @Index() @Field(_type => Project) @ManyToOne(_type => Project) - project: Project; + project: Relation; @RelationId((relatedAddress: ProjectSocialMedia) => relatedAddress.project) @Column({ nullable: true }) @@ -43,7 +44,7 @@ export class ProjectSocialMedia extends BaseEntity { @Index() @Field(_type => User, { nullable: true }) @ManyToOne(_type => User, { eager: true, nullable: true }) - user: User; + user: Relation; @RelationId((relatedAddress: ProjectSocialMedia) => relatedAddress.user) @Column({ nullable: true }) diff --git a/src/entities/projectStatus.ts b/src/entities/projectStatus.ts index f3a63a654..a60d045e2 100644 --- a/src/entities/projectStatus.ts +++ b/src/entities/projectStatus.ts @@ -7,8 +7,8 @@ import { OneToMany, Index, } from 'typeorm'; -import { Project } from './project'; -import { ProjectStatusReason } from './projectStatusReason'; +import { Project } from './project.js'; +import { ProjectStatusReason } from './projectStatusReason.js'; @Entity() @ObjectType() diff --git a/src/entities/projectStatusHistory.ts b/src/entities/projectStatusHistory.ts index 0f0cdb587..daad18e89 100644 --- a/src/entities/projectStatusHistory.ts +++ b/src/entities/projectStatusHistory.ts @@ -6,11 +6,12 @@ import { BaseEntity, ManyToOne, RelationId, + Relation, } from 'typeorm'; -import { Project } from './project'; -import { ProjectStatus } from './projectStatus'; -import { ProjectStatusReason } from './projectStatusReason'; -import { User } from './user'; +import { Project } from './project.js'; +import { ProjectStatus } from './projectStatus.js'; +import { ProjectStatusReason } from './projectStatusReason.js'; +import { User } from './user.js'; export const HISTORY_DESCRIPTIONS = { CHANGED_TO_VERIFIED: 'Changed to verified', @@ -30,7 +31,7 @@ export class ProjectStatusHistory extends BaseEntity { @Field(_type => Project) @ManyToOne(_type => Project) - project: Project; + project: Relation; @RelationId( (projectStatusHistory: ProjectStatusHistory) => @@ -72,7 +73,7 @@ export class ProjectStatusHistory extends BaseEntity { @Field(_type => User) @ManyToOne(_type => User) - user?: User; + user?: Relation; @RelationId( (projectStatusHistory: ProjectStatusHistory) => projectStatusHistory.user, diff --git a/src/entities/projectStatusReason.ts b/src/entities/projectStatusReason.ts index 376d5031c..9537a00ab 100644 --- a/src/entities/projectStatusReason.ts +++ b/src/entities/projectStatusReason.ts @@ -6,8 +6,9 @@ import { BaseEntity, ManyToOne, RelationId, + Relation, } from 'typeorm'; -import { ProjectStatus } from './projectStatus'; +import { ProjectStatus } from './projectStatus.js'; @Entity() @ObjectType() @@ -20,9 +21,8 @@ export class ProjectStatusReason extends BaseEntity { @Column({ nullable: true }) description: string; - @Field(_type => ProjectStatus) @ManyToOne(_type => ProjectStatus) - status: ProjectStatus; + status: Relation; @RelationId( (projectStatusReason: ProjectStatusReason) => projectStatusReason.status, diff --git a/src/entities/projectVerificationForm.ts b/src/entities/projectVerificationForm.ts index acaf0eebb..83249d883 100644 --- a/src/entities/projectVerificationForm.ts +++ b/src/entities/projectVerificationForm.ts @@ -9,14 +9,15 @@ import { OneToMany, OneToOne, PrimaryGeneratedColumn, + Relation, RelationId, UpdateDateColumn, } from 'typeorm'; import { Field, ID, ObjectType } from 'type-graphql'; -import { Project } from './project'; -import { User } from './user'; -import { SocialProfile } from './socialProfile'; -import { ChainType } from '../types/network'; +import { Project } from './project.js'; +import { User } from './user.js'; +import { SocialProfile } from './socialProfile.js'; +import { ChainType } from '../types/network.js'; export enum PROJECT_VERIFICATION_STATUSES { VERIFIED = 'verified', @@ -141,7 +142,7 @@ export class ProjectVerificationForm extends BaseEntity { @Field(_type => Project) @OneToOne(_type => Project) @JoinColumn() - project: Project; + project: Relation; @RelationId( (projectVerificationForm: ProjectVerificationForm) => @@ -153,7 +154,7 @@ export class ProjectVerificationForm extends BaseEntity { @Index() @Field(_type => User, { nullable: true }) @ManyToOne(_type => User, { eager: true }) - reviewer?: User; + reviewer?: Relation; @RelationId( (projectVerificationForm: ProjectVerificationForm) => @@ -165,7 +166,7 @@ export class ProjectVerificationForm extends BaseEntity { @Index() @Field(_type => User, { nullable: true }) @ManyToOne(_type => User, { eager: true, nullable: true }) - user: User; + user: Relation; @RelationId( (projectVerificationForm: ProjectVerificationForm) => diff --git a/src/entities/qfRound.ts b/src/entities/qfRound.ts index c71d0a263..d029116bc 100644 --- a/src/entities/qfRound.ts +++ b/src/entities/qfRound.ts @@ -10,8 +10,8 @@ import { Index, OneToMany, } from 'typeorm'; -import { Project } from './project'; -import { Donation } from './donation'; +import { Project } from './project.js'; +import { Donation } from './donation.js'; @Entity() @ObjectType() diff --git a/src/entities/qfRoundHistory.ts b/src/entities/qfRoundHistory.ts index 2ac072ce3..6736d1171 100644 --- a/src/entities/qfRoundHistory.ts +++ b/src/entities/qfRoundHistory.ts @@ -10,15 +10,16 @@ import { CreateDateColumn, Index, Unique, + Relation, } from 'typeorm'; -import { Project } from './project'; -import { QfRound } from './qfRound'; +import { Project } from './project.js'; +import { QfRound } from './qfRound.js'; import { findQfRoundById, getQfRoundTotalSqrtRootSumSquared, getProjectDonationsSqrtRootSum, -} from '../repositories/qfRoundRepository'; -import { EstimatedMatching } from '../types/qfTypes'; +} from '../repositories/qfRoundRepository.js'; +import { EstimatedMatching } from '../types/qfTypes.js'; @Entity() @ObjectType() @@ -30,7 +31,7 @@ export class QfRoundHistory extends BaseEntity { id: number; @ManyToOne(_type => Project) - project: Project; + project: Relation; @Index() @Field(_type => ID, { nullable: true }) diff --git a/src/entities/reaction.ts b/src/entities/reaction.ts index 4a9632d91..5f084b03f 100644 --- a/src/entities/reaction.ts +++ b/src/entities/reaction.ts @@ -7,9 +7,10 @@ import { RelationId, ManyToOne, Index, + Relation, } from 'typeorm'; -import { Project, ProjectUpdate } from './project'; -import { User } from './user'; +import { Project, ProjectUpdate } from './project.js'; +import { User } from './user.js'; @Entity() @ObjectType() @@ -21,7 +22,7 @@ export class Reaction extends BaseEntity { readonly id: number; @ManyToOne(_type => ProjectUpdate) - projectUpdate: ProjectUpdate; + projectUpdate: Relation; @Index() @RelationId((reaction: Reaction) => reaction.projectUpdate) @@ -41,7 +42,7 @@ export class Reaction extends BaseEntity { reaction: string; @ManyToOne(_type => Project) - project: Project; + project: Relation; @Index() @Field(_type => ID, { nullable: true }) diff --git a/src/entities/recurringDonation.ts b/src/entities/recurringDonation.ts index af58e3c1e..284314b59 100644 --- a/src/entities/recurringDonation.ts +++ b/src/entities/recurringDonation.ts @@ -7,15 +7,16 @@ import { ManyToOne, OneToMany, PrimaryGeneratedColumn, + Relation, RelationId, Unique, UpdateDateColumn, } from 'typeorm'; import { Field, ID, ObjectType } from 'type-graphql'; -import { Project } from './project'; -import { User } from './user'; -import { AnchorContractAddress } from './anchorContractAddress'; -import { Donation } from './donation'; +import { Project } from './project.js'; +import { User } from './user.js'; +import { AnchorContractAddress } from './anchorContractAddress.js'; +import { Donation } from './donation.js'; export const RECURRING_DONATION_STATUS = { PENDING: 'pending', @@ -69,7 +70,7 @@ export class RecurringDonation extends BaseEntity { @Index() @Field(_type => Project) @ManyToOne(_type => Project) - project: Project; + project: Relation; @RelationId( (recurringDonation: RecurringDonation) => recurringDonation.project, @@ -112,7 +113,7 @@ export class RecurringDonation extends BaseEntity { @Index() @Field(_type => User, { nullable: true }) @ManyToOne(_type => User, { eager: true, nullable: true }) - donor: User; + donor: Relation; @RelationId((recurringDonation: RecurringDonation) => recurringDonation.donor) @Column({ nullable: true }) diff --git a/src/entities/referredEvent.ts b/src/entities/referredEvent.ts index 45d612848..cfec0103c 100644 --- a/src/entities/referredEvent.ts +++ b/src/entities/referredEvent.ts @@ -9,8 +9,9 @@ import { UpdateDateColumn, CreateDateColumn, JoinColumn, + Relation, } from 'typeorm'; -import { User } from './user'; +import { User } from './user.js'; @Entity() @ObjectType() @@ -38,7 +39,7 @@ export class ReferredEvent extends BaseEntity { @Field(_type => User, { nullable: true }) @OneToOne(_type => User, { nullable: true }) @JoinColumn() - user: User; + user: Relation; @Field(_type => ID, { nullable: true }) @RelationId((referredEvent: ReferredEvent) => referredEvent.user) diff --git a/src/entities/socialProfile.ts b/src/entities/socialProfile.ts index 97954c525..af09aec02 100644 --- a/src/entities/socialProfile.ts +++ b/src/entities/socialProfile.ts @@ -6,13 +6,14 @@ import { Index, ManyToOne, PrimaryGeneratedColumn, + Relation, RelationId, UpdateDateColumn, } from 'typeorm'; import { Field, ID, ObjectType } from 'type-graphql'; -import { Project } from './project'; -import { User } from './user'; -import { ProjectVerificationForm } from './projectVerificationForm'; +import { Project } from './project.js'; +import { User } from './user.js'; +import { ProjectVerificationForm } from './projectVerificationForm.js'; export const SOCIAL_NETWORKS = { FACEBOOK: 'facebook', @@ -39,7 +40,7 @@ export class SocialProfile extends BaseEntity { @Index() @Field(_type => Project) @ManyToOne(_type => Project, { eager: true }) - project: Project; + project: Relation; @RelationId((socialProfile: SocialProfile) => socialProfile.project) @Column({ nullable: true }) @@ -48,14 +49,16 @@ export class SocialProfile extends BaseEntity { @Index() @Field(_type => User, { nullable: true }) @ManyToOne(_type => User, { eager: true, nullable: true }) - user: User; + user: Relation; + @RelationId((socialProfile: SocialProfile) => socialProfile.user) userId: number; @Index() @Field(_type => ProjectVerificationForm) @ManyToOne(_type => ProjectVerificationForm) - projectVerificationForm: ProjectVerificationForm; + projectVerificationForm: Relation; + @RelationId( (socialProfile: SocialProfile) => socialProfile.projectVerificationForm, ) diff --git a/src/entities/sybil.ts b/src/entities/sybil.ts index 5dce81090..47d289a03 100644 --- a/src/entities/sybil.ts +++ b/src/entities/sybil.ts @@ -7,9 +7,10 @@ import { RelationId, BaseEntity, Unique, + Relation, } from 'typeorm'; -import { User } from './user'; -import { QfRound } from './qfRound'; +import { User } from './user.js'; +import { QfRound } from './qfRound.js'; @ObjectType() @Entity() @@ -21,7 +22,7 @@ export class Sybil extends BaseEntity { @Field(_type => User) @ManyToOne(_type => User, { eager: true }) - user: User; + user: Relation; @RelationId((sybil: Sybil) => sybil.user) @Column() diff --git a/src/entities/thirdPartyProjectImport.ts b/src/entities/thirdPartyProjectImport.ts index bf14ac06a..5fdc3dca7 100644 --- a/src/entities/thirdPartyProjectImport.ts +++ b/src/entities/thirdPartyProjectImport.ts @@ -6,9 +6,10 @@ import { PrimaryGeneratedColumn, ManyToOne, RelationId, + Relation, } from 'typeorm'; -import { Project } from './project'; -import { User } from './user'; +import { Project } from './project.js'; +import { User } from './user.js'; // only purpose of this entity is to serve as a custom page in AdminJs @Entity() @@ -32,7 +33,7 @@ export class ThirdPartyProjectImport extends BaseEntity { // History of who exported @Field(_type => User) @ManyToOne(_type => User) - user?: User; + user?: Relation; @RelationId( (thirdPartyProjectImport: ThirdPartyProjectImport) => @@ -43,7 +44,7 @@ export class ThirdPartyProjectImport extends BaseEntity { // Link to project @Field(_type => Project) @ManyToOne(_type => Project) - project?: Project; + project?: Relation; @RelationId( (thirdPartyProjectImport: ThirdPartyProjectImport) => diff --git a/src/entities/token.ts b/src/entities/token.ts index ceefec96b..fe4cfe554 100644 --- a/src/entities/token.ts +++ b/src/entities/token.ts @@ -7,8 +7,8 @@ import { ManyToMany, Index, } from 'typeorm'; -import { Organization } from './organization'; -import { ChainType } from '../types/network'; +import { Organization } from './organization.js'; +import { ChainType } from '../types/network.js'; @Entity() @ObjectType() diff --git a/src/entities/user.ts b/src/entities/user.ts index 12ca19950..ffa85903a 100644 --- a/src/entities/user.ts +++ b/src/entities/user.ts @@ -10,17 +10,17 @@ import { PrimaryGeneratedColumn, UpdateDateColumn, } from 'typeorm'; -import { ProjStatus, ReviewStatus } from './project'; -import { Donation, DONATION_STATUS } from './donation'; -import { Reaction } from './reaction'; -import { AccountVerification } from './accountVerification'; -import { ProjectStatusHistory } from './projectStatusHistory'; -import { ProjectVerificationForm } from './projectVerificationForm'; -import { PowerBoosting } from './powerBoosting'; -import { findPowerBoostingsCountByUserId } from '../repositories/powerBoostingRepository'; -import { ReferredEvent } from './referredEvent'; -import { RecurringDonation } from './recurringDonation'; -import { NOTIFICATIONS_EVENT_NAMES } from '../analytics/analytics'; +import { ProjStatus, ReviewStatus } from './project.js'; +import { Donation, DONATION_STATUS } from './donation.js'; +import { Reaction } from './reaction.js'; +import { AccountVerification } from './accountVerification.js'; +import { ProjectStatusHistory } from './projectStatusHistory.js'; +import { ProjectVerificationForm } from './projectVerificationForm.js'; +import { PowerBoosting } from './powerBoosting.js'; +import { findPowerBoostingsCountByUserId } from '../repositories/powerBoostingRepository.js'; +import { ReferredEvent } from './referredEvent.js'; +import { RecurringDonation } from './recurringDonation.js'; +import { NOTIFICATIONS_EVENT_NAMES } from '../analytics/analytics.js'; export const publicSelectionFields = [ 'user.id', diff --git a/src/entities/wallet.ts b/src/entities/wallet.ts index 58d6e60bb..4cea89552 100644 --- a/src/entities/wallet.ts +++ b/src/entities/wallet.ts @@ -6,8 +6,9 @@ import { ManyToOne, RelationId, BaseEntity, + Relation, } from 'typeorm'; -import { User } from './user'; +import { User } from './user.js'; @ObjectType() @Entity() @@ -22,7 +23,8 @@ export class Wallet extends BaseEntity { @Field(_type => User) @ManyToOne(_type => User, { eager: true }) - user: User; + user: Relation; + @RelationId((donation: Wallet) => donation.user) @Column() userId: number; diff --git a/src/index.ts b/src/index.ts index 8eb1124f8..d137e8d16 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,4 @@ import 'reflect-metadata'; -import { bootstrap } from './server/bootstrap'; +import { bootstrap } from './server/bootstrap.js'; bootstrap(); diff --git a/src/middleware/apiGivAuthentication.ts b/src/middleware/apiGivAuthentication.ts index 19d83236c..26aa3b7b9 100644 --- a/src/middleware/apiGivAuthentication.ts +++ b/src/middleware/apiGivAuthentication.ts @@ -1,11 +1,11 @@ import { NextFunction, Request, Response } from 'express'; -import { i18n, translationErrorMessagesKeys } from '../utils/errorMessages'; -import { decodeBasicAuthentication } from '../utils/utils'; -import { logger } from '../utils/logger'; +import { i18n, translationErrorMessagesKeys } from '../utils/errorMessages.js'; +import { decodeBasicAuthentication } from '../utils/utils.js'; +import { logger } from '../utils/logger.js'; import { ApiGivStandardError, handleExpressError, -} from '../routers/standardError'; +} from '../routers/standardError.js'; export const apiGivAuthentication = ( req: Request, diff --git a/src/middleware/pinataUtils.ts b/src/middleware/pinataUtils.ts index 8505944a0..13d8ece0e 100644 --- a/src/middleware/pinataUtils.ts +++ b/src/middleware/pinataUtils.ts @@ -3,13 +3,16 @@ */ import pinataSDK, { PinataPinResponse } from '@pinata/sdk'; -import config from '../config'; +import config from '../config.js'; import ReadableStream = NodeJS.ReadableStream; +// @ts-expect-error migrate to ESM let _pinata: pinataSDK; +// @ts-expect-error migrate to ESM export const getPinata = (): pinataSDK => { if (!_pinata) { + // @ts-expect-error migrate to ESM _pinata = new pinataSDK({ pinataApiKey: config.get('PINATA_API_KEY') as string, pinataSecretApiKey: config.get('PINATA_SECRET_API_KEY') as string, diff --git a/src/migration.config.ts b/src/migration.config.ts new file mode 100644 index 000000000..13470c30b --- /dev/null +++ b/src/migration.config.ts @@ -0,0 +1,6 @@ +import { DataSource } from 'typeorm'; +import ormConfig from './ormconfig.js'; + +const datasource = new DataSource(ormConfig); +datasource.initialize(); +export default datasource; diff --git a/src/orm.ts b/src/orm.ts index 7961e434e..13f967854 100644 --- a/src/orm.ts +++ b/src/orm.ts @@ -1,9 +1,8 @@ import { DataSource } from 'typeorm'; -import { PostgresConnectionCredentialsOptions } from 'typeorm/driver/postgres/PostgresConnectionCredentialsOptions'; -import config from './config'; -import { CronJob } from './entities/CronJob'; -import { getEntities } from './entities/entities'; -import { redisConfig } from './redis'; +import config from './config.js'; +import { CronJob } from './entities/CronJob.js'; +import { getEntities } from './entities/entities.js'; +import { redisConfig } from './redis.js'; export class AppDataSource { private static datasource: DataSource; @@ -15,7 +14,7 @@ export class AppDataSource { const synchronize = (config.get('ENVIRONMENT') as string) === 'test'; const entities = getEntities(); const poolSize = Number(process.env.TYPEORM_DATABASE_POOL_SIZE) || 10; // 10 is the default value - const slaves: PostgresConnectionCredentialsOptions[] = []; + const slaves: any[] = []; if (config.get('TYPEORM_DATABASE_HOST_READONLY')) { slaves.push({ database: config.get('TYPEORM_DATABASE_NAME_READONLY') as string, diff --git a/src/ormconfig.ts b/src/ormconfig.ts index bfb4c35d1..36bc3298f 100644 --- a/src/ormconfig.ts +++ b/src/ormconfig.ts @@ -1,26 +1,20 @@ +import { fileURLToPath } from 'url'; import * as path from 'path'; -import * as dotenv from 'dotenv'; +import { DataSource, DataSourceOptions } from 'typeorm'; +import dotenv from 'dotenv'; +import { getEntities } from './entities/entities.js'; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); const configPath = path.resolve( __dirname, `../config/${process.env.NODE_ENV || ''}.env`, ); -const loadConfigResult = dotenv.config({ +dotenv.config({ path: configPath, }); -if (loadConfigResult.error) { - // eslint-disable-next-line no-console - console.log('Load process.env error', { - path: configPath, - error: loadConfigResult.error, - }); - throw loadConfigResult.error; -} - -import { DataSource, DataSourceOptions } from 'typeorm'; -import { getEntities } from './entities/entities'; - const ormConfig: DataSourceOptions = { type: 'postgres', host: process.env.TYPEORM_DATABASE_HOST, @@ -37,4 +31,4 @@ const ormConfig: DataSourceOptions = { export const AppDataSource = new DataSource(ormConfig); -exports = ormConfig; +export default ormConfig; diff --git a/src/provider.ts b/src/provider.ts index 3d0cc269b..ea0f119b9 100644 --- a/src/provider.ts +++ b/src/provider.ts @@ -1,7 +1,7 @@ import { ethers } from 'ethers'; -import config from './config'; -import { i18n, translationErrorMessagesKeys } from './utils/errorMessages'; -import { logger } from './utils/logger'; +import config from './config.js'; +import { i18n, translationErrorMessagesKeys } from './utils/errorMessages.js'; +import { logger } from './utils/logger.js'; const INFURA_ID = config.get('INFURA_ID'); diff --git a/src/repositories/accountVerificationRepository.ts b/src/repositories/accountVerificationRepository.ts index 6393d5327..177752731 100644 --- a/src/repositories/accountVerificationRepository.ts +++ b/src/repositories/accountVerificationRepository.ts @@ -1,4 +1,4 @@ -import { AccountVerification } from '../entities/accountVerification'; +import { AccountVerification } from '../entities/accountVerification.js'; export const createNewAccountVerification = async ( associatedVerifications, diff --git a/src/repositories/anchorContractAddressRepository.test.ts b/src/repositories/anchorContractAddressRepository.test.ts index 49e6f369c..6fb406089 100644 --- a/src/repositories/anchorContractAddressRepository.test.ts +++ b/src/repositories/anchorContractAddressRepository.test.ts @@ -1,13 +1,13 @@ import { assert } from 'chai'; -import { addNewAnchorAddress } from './anchorContractAddressRepository'; +import { addNewAnchorAddress } from './anchorContractAddressRepository.js'; import { createProjectData, generateRandomEtheriumAddress, generateRandomEvmTxHash, saveProjectDirectlyToDb, saveUserDirectlyToDb, -} from '../../test/testUtils'; -import { NETWORK_IDS } from '../provider'; +} from '../../test/testUtils.js'; +import { NETWORK_IDS } from '../provider.js'; describe('addNewAnchorAddressTestCases', addNewAnchorAddressTestCases); diff --git a/src/repositories/anchorContractAddressRepository.ts b/src/repositories/anchorContractAddressRepository.ts index abf4749ab..16753bedf 100644 --- a/src/repositories/anchorContractAddressRepository.ts +++ b/src/repositories/anchorContractAddressRepository.ts @@ -1,6 +1,6 @@ -import { AnchorContractAddress } from '../entities/anchorContractAddress'; -import { Project } from '../entities/project'; -import { User } from '../entities/user'; +import { AnchorContractAddress } from '../entities/anchorContractAddress.js'; +import { Project } from '../entities/project.js'; +import { User } from '../entities/user.js'; export const addNewAnchorAddress = async (params: { project: Project; diff --git a/src/repositories/broadcastNotificationRepository.test.ts b/src/repositories/broadcastNotificationRepository.test.ts index 41e8c5304..130014020 100644 --- a/src/repositories/broadcastNotificationRepository.test.ts +++ b/src/repositories/broadcastNotificationRepository.test.ts @@ -1,11 +1,11 @@ import { assert } from 'chai'; import BroadcastNotification, { BROAD_CAST_NOTIFICATION_STATUS, -} from '../entities/broadcastNotification'; +} from '../entities/broadcastNotification.js'; import { updateBroadcastNotificationStatus, findBroadcastNotificationById, -} from './broadcastNotificationRepository'; +} from './broadcastNotificationRepository.js'; describe( 'updateBroadcastNotificationStatus test cases', diff --git a/src/repositories/broadcastNotificationRepository.ts b/src/repositories/broadcastNotificationRepository.ts index 0d8479308..739dff8f1 100644 --- a/src/repositories/broadcastNotificationRepository.ts +++ b/src/repositories/broadcastNotificationRepository.ts @@ -1,4 +1,4 @@ -import BroadcastNotification from '../entities/broadcastNotification'; +import BroadcastNotification from '../entities/broadcastNotification.js'; export const updateBroadcastNotificationStatus = async ( id: number, diff --git a/src/repositories/campaignRepository.test.ts b/src/repositories/campaignRepository.test.ts index 3213eb21e..c1118fbdf 100644 --- a/src/repositories/campaignRepository.test.ts +++ b/src/repositories/campaignRepository.test.ts @@ -1,14 +1,14 @@ import { assert } from 'chai'; -import { Campaign, CampaignType } from '../entities/campaign'; +import { Campaign, CampaignType } from '../entities/campaign.js'; import { findAllActiveCampaigns, findCampaignBySlug, findFeaturedCampaign, -} from './campaignRepository'; -import { findProjectById } from './projectRepository'; -import { SEED_DATA } from '../../test/testUtils'; -import { Project } from '../entities/project'; -import { generateRandomString } from '../utils/utils'; +} from './campaignRepository.js'; +import { findProjectById } from './projectRepository.js'; +import { SEED_DATA } from '../../test/testUtils.js'; +import { Project } from '../entities/project.js'; +import { generateRandomString } from '../utils/utils.js'; describe('findAllActiveCampaigns test cases', findAllActiveCampaignsTestCases); describe('findCampaignBySlug test cases', findCampaignBySlugTestCases); diff --git a/src/repositories/campaignRepository.ts b/src/repositories/campaignRepository.ts index e6fd0c5fe..c0dac29d8 100644 --- a/src/repositories/campaignRepository.ts +++ b/src/repositories/campaignRepository.ts @@ -1,4 +1,4 @@ -import { Campaign } from '../entities/campaign'; +import { Campaign } from '../entities/campaign.js'; export const findAllActiveCampaigns = async (): Promise => { return Campaign.createQueryBuilder('campaign') diff --git a/src/repositories/dbCronRepository.test.ts b/src/repositories/dbCronRepository.test.ts index 2aab73df9..073d22c61 100644 --- a/src/repositories/dbCronRepository.test.ts +++ b/src/repositories/dbCronRepository.test.ts @@ -8,29 +8,29 @@ import { schedulePowerBoostingSnapshot, setupPgCronExtension, unSchedulePowerBoostingSnapshot, -} from './dbCronRepository'; -import config from '../config'; +} from './dbCronRepository.js'; +import config from '../config.js'; import { createProjectData, generateRandomEtheriumAddress, saveProjectDirectlyToDb, saveUserDirectlyToDb, sleep, -} from '../../test/testUtils'; -import { PowerSnapshot } from '../entities/powerSnapshot'; -import { PowerBoosting } from '../entities/powerBoosting'; -import { PowerBoostingSnapshot } from '../entities/powerBoostingSnapshot'; +} from '../../test/testUtils.js'; +import { PowerSnapshot } from '../entities/powerSnapshot.js'; +import { PowerBoosting } from '../entities/powerBoosting.js'; +import { PowerBoostingSnapshot } from '../entities/powerBoostingSnapshot.js'; import { insertSinglePowerBoosting, takePowerBoostingSnapshot, -} from './powerBoostingRepository'; -import { PowerBalanceSnapshot } from '../entities/powerBalanceSnapshot'; -import { setPowerRound } from './powerRoundRepository'; -import { PowerSnapshotHistory } from '../entities/powerSnapshotHistory'; -import { PowerBoostingSnapshotHistory } from '../entities/powerBoostingSnapshotHistory'; -import { PowerBalanceSnapshotHistory } from '../entities/powerBalanceSnapshotHistory'; -import { AppDataSource } from '../orm'; -import { addOrUpdatePowerSnapshotBalances } from './powerBalanceSnapshotRepository'; +} from './powerBoostingRepository.js'; +import { PowerBalanceSnapshot } from '../entities/powerBalanceSnapshot.js'; +import { setPowerRound } from './powerRoundRepository.js'; +import { PowerSnapshotHistory } from '../entities/powerSnapshotHistory.js'; +import { PowerBoostingSnapshotHistory } from '../entities/powerBoostingSnapshotHistory.js'; +import { PowerBalanceSnapshotHistory } from '../entities/powerBalanceSnapshotHistory.js'; +import { AppDataSource } from '../orm.js'; +import { addOrUpdatePowerSnapshotBalances } from './powerBalanceSnapshotRepository.js'; describe( 'db cron job historic procedures tests cases', diff --git a/src/repositories/dbCronRepository.ts b/src/repositories/dbCronRepository.ts index b000a3a2d..9a2d8b05c 100644 --- a/src/repositories/dbCronRepository.ts +++ b/src/repositories/dbCronRepository.ts @@ -1,6 +1,6 @@ -import { CronJob } from '../entities/CronJob'; -import { logger } from '../utils/logger'; -import { AppDataSource, CronDataSource } from '../orm'; +import { CronJob } from '../entities/CronJob.js'; +import { logger } from '../utils/logger.js'; +import { AppDataSource, CronDataSource } from '../orm.js'; export const POWER_BOOSTING_SNAPSHOT_TASK_NAME = 'take givpower boosting snapshot'; diff --git a/src/repositories/donationRepository.test.ts b/src/repositories/donationRepository.test.ts index bdbe07598..3dd72b231 100644 --- a/src/repositories/donationRepository.test.ts +++ b/src/repositories/donationRepository.test.ts @@ -10,8 +10,8 @@ import { saveProjectDirectlyToDb, saveUserDirectlyToDb, SEED_DATA, -} from '../../test/testUtils'; -import { User, UserRole } from '../entities/user'; +} from '../../test/testUtils.js'; +import { User, UserRole } from '../entities/user.js'; import { countUniqueDonorsAndSumDonationValueUsd, createDonation, @@ -22,12 +22,12 @@ import { getPendingDonationsIds, getProjectQfRoundStats, isVerifiedDonationExistsInQfRound, -} from './donationRepository'; -import { Donation, DONATION_STATUS } from '../entities/donation'; -import { QfRound } from '../entities/qfRound'; -import { Project } from '../entities/project'; -import { refreshProjectEstimatedMatchingView } from '../services/projectViewsService'; -import { calculateEstimateMatchingForProjectById } from '../utils/qfUtils'; +} from './donationRepository.js'; +import { Donation, DONATION_STATUS } from '../entities/donation.js'; +import { QfRound } from '../entities/qfRound.js'; +import { Project } from '../entities/project.js'; +import { refreshProjectEstimatedMatchingView } from '../services/projectViewsService.js'; +import { calculateEstimateMatchingForProjectById } from '../utils/qfUtils.js'; describe('createDonation test cases', createDonationTestCases); diff --git a/src/repositories/donationRepository.ts b/src/repositories/donationRepository.ts index 9ffa7af3a..598975b86 100644 --- a/src/repositories/donationRepository.ts +++ b/src/repositories/donationRepository.ts @@ -1,10 +1,10 @@ import { Between, MoreThan } from 'typeorm'; import moment from 'moment'; -import { Project } from '../entities/project'; -import { Donation, DONATION_STATUS } from '../entities/donation'; -import { ResourcesTotalPerMonthAndYear } from '../resolvers/donationResolver'; -import { logger } from '../utils/logger'; -import { QfRound } from '../entities/qfRound'; +import { Project } from '../entities/project.js'; +import { Donation, DONATION_STATUS } from '../entities/donation.js'; +import { ResourcesTotalPerMonthAndYear } from '../resolvers/donationResolver.js'; +import { logger } from '../utils/logger.js'; +import { QfRound } from '../entities/qfRound.js'; export const fillQfRoundDonationsUserScores = async (): Promise => { await Donation.query(` diff --git a/src/repositories/draftDonationRepository.test.ts b/src/repositories/draftDonationRepository.test.ts index dedf19c07..837d53db6 100644 --- a/src/repositories/draftDonationRepository.test.ts +++ b/src/repositories/draftDonationRepository.test.ts @@ -1,16 +1,16 @@ // Create a draft donation import { assert, expect } from 'chai'; -import { generateRandomEtheriumAddress } from '../../test/testUtils'; +import { generateRandomEtheriumAddress } from '../../test/testUtils.js'; import { DRAFT_DONATION_STATUS, DraftDonation, -} from '../entities/draftDonation'; +} from '../entities/draftDonation.js'; import { countPendingDraftDonations, delecteExpiredDraftDonations, markDraftDonationStatusMatched, -} from './draftDonationRepository'; +} from './draftDonationRepository.js'; // Mark the draft donation as matched describe('draftDonationRepository', () => { diff --git a/src/repositories/draftDonationRepository.ts b/src/repositories/draftDonationRepository.ts index ff4dc4ae7..d85e6ee1e 100644 --- a/src/repositories/draftDonationRepository.ts +++ b/src/repositories/draftDonationRepository.ts @@ -1,9 +1,9 @@ import { DRAFT_DONATION_STATUS, DraftDonation, -} from '../entities/draftDonation'; -import { logger } from '../utils/logger'; -import { AppDataSource } from '../orm'; +} from '../entities/draftDonation.js'; +import { logger } from '../utils/logger.js'; +import { AppDataSource } from '../orm.js'; // mark donation status matched based on fromWalletAddress, toWalletAddress, networkId, tokenAddress and amount export async function markDraftDonationStatusMatched(params: { diff --git a/src/repositories/draftRecurringDonationRepository.ts b/src/repositories/draftRecurringDonationRepository.ts index 41f009b85..a373a3e1e 100644 --- a/src/repositories/draftRecurringDonationRepository.ts +++ b/src/repositories/draftRecurringDonationRepository.ts @@ -1,8 +1,8 @@ -import { logger } from '../utils/logger'; +import { logger } from '../utils/logger.js'; import { DRAFT_RECURRING_DONATION_STATUS, DraftRecurringDonation, -} from '../entities/draftRecurringDonation'; +} from '../entities/draftRecurringDonation.js'; // mark donation status matched based on fromWalletAddress, toWalletAddress, networkId, tokenAddress and amount export async function markDraftRecurringDonationStatusMatched(params: { diff --git a/src/repositories/instantBoostingRepository.test.ts b/src/repositories/instantBoostingRepository.test.ts index b1c62d2f1..cd79c99c4 100644 --- a/src/repositories/instantBoostingRepository.test.ts +++ b/src/repositories/instantBoostingRepository.test.ts @@ -6,18 +6,18 @@ import { refreshProjectInstantPowerView, saveOrUpdateInstantPowerBalances, setMaxFetchedUpdatedAtTimestamp, -} from './instantBoostingRepository'; -import { InstantPowerBalance } from '../entities/instantPowerBalance'; +} from './instantBoostingRepository.js'; +import { InstantPowerBalance } from '../entities/instantPowerBalance.js'; import { createProjectData, generateRandomEtheriumAddress, saveProjectDirectlyToDb, saveUserDirectlyToDb, -} from '../../test/testUtils'; -import { PowerBoosting } from '../entities/powerBoosting'; -import { insertSinglePowerBoosting } from './powerBoostingRepository'; -import { InstantPowerFetchState } from '../entities/instantPowerFetchState'; -import { ProjectInstantPowerView } from '../views/projectInstantPowerView'; +} from '../../test/testUtils.js'; +import { PowerBoosting } from '../entities/powerBoosting.js'; +import { insertSinglePowerBoosting } from './powerBoostingRepository.js'; +import { InstantPowerFetchState } from '../entities/instantPowerFetchState.js'; +import { ProjectInstantPowerView } from '../views/projectInstantPowerView.js'; // describe( // 'getLastInstantPowerUpdatedAt test cases', diff --git a/src/repositories/instantBoostingRepository.ts b/src/repositories/instantBoostingRepository.ts index 1e7e3535f..180ae17ba 100644 --- a/src/repositories/instantBoostingRepository.ts +++ b/src/repositories/instantBoostingRepository.ts @@ -1,8 +1,8 @@ -import { InstantPowerBalance } from '../entities/instantPowerBalance'; -import { logger } from '../utils/logger'; -import { AppDataSource } from '../orm'; -import { InstantPowerFetchState } from '../entities/instantPowerFetchState'; -import { ProjectUserInstantPowerView } from '../views/projectUserInstantPowerView'; +import { InstantPowerBalance } from '../entities/instantPowerBalance.js'; +import { logger } from '../utils/logger.js'; +import { AppDataSource } from '../orm.js'; +import { InstantPowerFetchState } from '../entities/instantPowerFetchState.js'; +import { ProjectUserInstantPowerView } from '../views/projectUserInstantPowerView.js'; export const saveOrUpdateInstantPowerBalances = async ( instances: Partial[], diff --git a/src/repositories/organizationRepository.ts b/src/repositories/organizationRepository.ts index efd508b86..81b6cdf10 100644 --- a/src/repositories/organizationRepository.ts +++ b/src/repositories/organizationRepository.ts @@ -1,4 +1,4 @@ -import { Organization } from '../entities/organization'; +import { Organization } from '../entities/organization.js'; export const findOrganizationById = async ( id: number, diff --git a/src/repositories/powerBalanceSnapshotRepository.test.ts b/src/repositories/powerBalanceSnapshotRepository.test.ts index 37123e64f..fdb918785 100644 --- a/src/repositories/powerBalanceSnapshotRepository.test.ts +++ b/src/repositories/powerBalanceSnapshotRepository.test.ts @@ -2,9 +2,9 @@ import { assertNotThrowsAsync, generateRandomEtheriumAddress, saveUserDirectlyToDb, -} from '../../test/testUtils'; -import { PowerSnapshot } from '../entities/powerSnapshot'; -import { addOrUpdatePowerSnapshotBalances } from './powerBalanceSnapshotRepository'; +} from '../../test/testUtils.js'; +import { PowerSnapshot } from '../entities/powerSnapshot.js'; +import { addOrUpdatePowerSnapshotBalances } from './powerBalanceSnapshotRepository.js'; describe( 'createPowerSnapshotBalances test cases', diff --git a/src/repositories/powerBalanceSnapshotRepository.ts b/src/repositories/powerBalanceSnapshotRepository.ts index 58e70107e..9d235382a 100644 --- a/src/repositories/powerBalanceSnapshotRepository.ts +++ b/src/repositories/powerBalanceSnapshotRepository.ts @@ -1,4 +1,4 @@ -import { PowerBalanceSnapshot } from '../entities/powerBalanceSnapshot'; +import { PowerBalanceSnapshot } from '../entities/powerBalanceSnapshot.js'; type PowerBalanceSnapshotParams = Pick< PowerBalanceSnapshot, diff --git a/src/repositories/powerBoostingRepository.test.ts b/src/repositories/powerBoostingRepository.test.ts index 1fcb39afc..e6e879cf2 100644 --- a/src/repositories/powerBoostingRepository.test.ts +++ b/src/repositories/powerBoostingRepository.test.ts @@ -5,7 +5,7 @@ import { generateRandomEtheriumAddress, saveProjectDirectlyToDb, saveUserDirectlyToDb, -} from '../../test/testUtils'; +} from '../../test/testUtils.js'; import { cancelProjectBoosting, findPowerBoostings, @@ -15,13 +15,13 @@ import { setMultipleBoosting, setSingleBoosting, takePowerBoostingSnapshot, -} from './powerBoostingRepository'; -import { PowerBoosting } from '../entities/powerBoosting'; -import { PowerSnapshot } from '../entities/powerSnapshot'; -import { PowerBoostingSnapshot } from '../entities/powerBoostingSnapshot'; -import { errorMessages } from '../utils/errorMessages'; -import { AppDataSource } from '../orm'; -import { PowerBalanceSnapshot } from '../entities/powerBalanceSnapshot'; +} from './powerBoostingRepository.js'; +import { PowerBoosting } from '../entities/powerBoosting.js'; +import { PowerSnapshot } from '../entities/powerSnapshot.js'; +import { PowerBoostingSnapshot } from '../entities/powerBoostingSnapshot.js'; +import { errorMessages } from '../utils/errorMessages.js'; +import { AppDataSource } from '../orm.js'; +import { PowerBalanceSnapshot } from '../entities/powerBalanceSnapshot.js'; describe('findUserPowerBoosting() testCases', findUserPowerBoostingTestCases); describe('findPowerBoostings() testCases', findPowerBoostingsTestCases); diff --git a/src/repositories/powerBoostingRepository.ts b/src/repositories/powerBoostingRepository.ts index 9b255d488..ff9177483 100644 --- a/src/repositories/powerBoostingRepository.ts +++ b/src/repositories/powerBoostingRepository.ts @@ -1,18 +1,18 @@ import { Brackets } from 'typeorm'; -import { PowerBoosting } from '../entities/powerBoosting'; -import { Project } from '../entities/project'; -import { publicSelectionFields, User } from '../entities/user'; -import { logger } from '../utils/logger'; +import { PowerBoosting } from '../entities/powerBoosting.js'; +import { Project } from '../entities/project.js'; +import { publicSelectionFields, User } from '../entities/user.js'; +import { logger } from '../utils/logger.js'; import { errorMessages, i18n, translationErrorMessagesKeys, -} from '../utils/errorMessages'; -import { PowerSnapshot } from '../entities/powerSnapshot'; -import { getRoundNumberByDate } from '../utils/powerBoostingUtils'; -import { getKeyByValue } from '../utils/utils'; -import { PowerBoostingSnapshot } from '../entities/powerBoostingSnapshot'; -import { AppDataSource } from '../orm'; +} from '../utils/errorMessages.js'; +import { PowerSnapshot } from '../entities/powerSnapshot.js'; +import { getRoundNumberByDate } from '../utils/powerBoostingUtils.js'; +import { getKeyByValue } from '../utils/utils.js'; +import { PowerBoostingSnapshot } from '../entities/powerBoostingSnapshot.js'; +import { AppDataSource } from '../orm.js'; const MAX_PROJECT_BOOST_LIMIT = Number( process.env.GIVPOWER_BOOSTING_USER_PROJECTS_LIMIT || '20', diff --git a/src/repositories/powerRoundRepository.test.ts b/src/repositories/powerRoundRepository.test.ts index 53136aaa1..e9d11eac9 100644 --- a/src/repositories/powerRoundRepository.test.ts +++ b/src/repositories/powerRoundRepository.test.ts @@ -1,7 +1,7 @@ import { assert } from 'chai'; -import { assertThrowsAsync } from '../../test/testUtils'; -import { getPowerRound, setPowerRound } from './powerRoundRepository'; -import { PowerRound } from '../entities/powerRound'; +import { assertThrowsAsync } from '../../test/testUtils.js'; +import { getPowerRound, setPowerRound } from './powerRoundRepository.js'; +import { PowerRound } from '../entities/powerRound.js'; describe('powerRoundRepository testCases', () => { it('should return correct round after setting', async () => { diff --git a/src/repositories/powerRoundRepository.ts b/src/repositories/powerRoundRepository.ts index dda8d6d91..e29ba53b7 100644 --- a/src/repositories/powerRoundRepository.ts +++ b/src/repositories/powerRoundRepository.ts @@ -1,4 +1,4 @@ -import { PowerRound } from '../entities/powerRound'; +import { PowerRound } from '../entities/powerRound.js'; export const setPowerRound = async (round: number): Promise => { let powerRound = await PowerRound.findOne({ where: {} }); diff --git a/src/repositories/powerSnapshotRepository.test.ts b/src/repositories/powerSnapshotRepository.test.ts index 51360e49b..ad5fb6a82 100644 --- a/src/repositories/powerSnapshotRepository.test.ts +++ b/src/repositories/powerSnapshotRepository.test.ts @@ -1,20 +1,20 @@ import { assert } from 'chai'; -import { PowerSnapshot } from '../entities/powerSnapshot'; +import { PowerSnapshot } from '../entities/powerSnapshot.js'; import { getPowerBoostingSnapshotWithoutBalance, updatePowerSnapshotSyncedFlag, -} from './powerSnapshotRepository'; +} from './powerSnapshotRepository.js'; import { createProjectData, generateRandomEtheriumAddress, saveProjectDirectlyToDb, saveUserDirectlyToDb, -} from '../../test/testUtils'; -import { PowerBoostingSnapshot } from '../entities/powerBoostingSnapshot'; -import { PowerBalanceSnapshot } from '../entities/powerBalanceSnapshot'; -import { AppDataSource } from '../orm'; -import { addOrUpdatePowerSnapshotBalances } from './powerBalanceSnapshotRepository'; -import { getTimestampInSeconds } from '../utils/utils'; +} from '../../test/testUtils.js'; +import { PowerBoostingSnapshot } from '../entities/powerBoostingSnapshot.js'; +import { PowerBalanceSnapshot } from '../entities/powerBalanceSnapshot.js'; +import { AppDataSource } from '../orm.js'; +import { addOrUpdatePowerSnapshotBalances } from './powerBalanceSnapshotRepository.js'; +import { getTimestampInSeconds } from '../utils/utils.js'; describe('findPowerSnapshotById() test cases', findPowerSnapshotByIdTestCases); describe('test balance snapshot functions', balanceSnapshotTestCases); diff --git a/src/repositories/powerSnapshotRepository.ts b/src/repositories/powerSnapshotRepository.ts index d673bb25c..b8803a167 100644 --- a/src/repositories/powerSnapshotRepository.ts +++ b/src/repositories/powerSnapshotRepository.ts @@ -1,5 +1,5 @@ -import { PowerSnapshot } from '../entities/powerSnapshot'; -import { AppDataSource } from '../orm'; +import { PowerSnapshot } from '../entities/powerSnapshot.js'; +import { AppDataSource } from '../orm.js'; export const findInCompletePowerSnapShots = async (): Promise< PowerSnapshot[] diff --git a/src/repositories/previousRoundRankRepository.test.ts b/src/repositories/previousRoundRankRepository.test.ts index cd418446a..3782b31e7 100644 --- a/src/repositories/previousRoundRankRepository.test.ts +++ b/src/repositories/previousRoundRankRepository.test.ts @@ -3,10 +3,10 @@ import { copyProjectRanksToPreviousRoundRankTable, deleteAllPreviousRoundRanks, projectsThatTheirRanksHaveChanged, -} from './previousRoundRankRepository'; -import { AppDataSource } from '../orm'; -import { PowerBalanceSnapshot } from '../entities/powerBalanceSnapshot'; -import { PowerBoostingSnapshot } from '../entities/powerBoostingSnapshot'; +} from './previousRoundRankRepository.js'; +import { AppDataSource } from '../orm.js'; +import { PowerBalanceSnapshot } from '../entities/powerBalanceSnapshot.js'; +import { PowerBoostingSnapshot } from '../entities/powerBoostingSnapshot.js'; import { createProjectData, generateRandomEtheriumAddress, @@ -14,23 +14,23 @@ import { saveUserDirectlyToDb, SEED_DATA, dbIndependentTests, -} from '../../test/testUtils'; +} from '../../test/testUtils.js'; import { insertSinglePowerBoosting, takePowerBoostingSnapshot, -} from './powerBoostingRepository'; -import { getPowerRound, setPowerRound } from './powerRoundRepository'; +} from './powerBoostingRepository.js'; +import { getPowerRound, setPowerRound } from './powerRoundRepository.js'; import { getProjectPowers, refreshProjectPowerView, -} from './projectPowerViewRepository'; -import { Project } from '../entities/project'; -import { PreviousRoundRank } from '../entities/previousRoundRank'; -import { ProjectPowerView } from '../views/projectPowerView'; -import { findProjectById } from './projectRepository'; -import { PowerRound } from '../entities/powerRound'; -import { addOrUpdatePowerSnapshotBalances } from './powerBalanceSnapshotRepository'; -import { findPowerSnapshots } from './powerSnapshotRepository'; +} from './projectPowerViewRepository.js'; +import { Project } from '../entities/project.js'; +import { PreviousRoundRank } from '../entities/previousRoundRank.js'; +import { ProjectPowerView } from '../views/projectPowerView.js'; +import { findProjectById } from './projectRepository.js'; +import { PowerRound } from '../entities/powerRound.js'; +import { addOrUpdatePowerSnapshotBalances } from './powerBalanceSnapshotRepository.js'; +import { findPowerSnapshots } from './powerSnapshotRepository.js'; describe( 'copyProjectRanksToPreviousRoundRankTable test cases', diff --git a/src/repositories/previousRoundRankRepository.ts b/src/repositories/previousRoundRankRepository.ts index 4ea964444..596cda2dd 100644 --- a/src/repositories/previousRoundRankRepository.ts +++ b/src/repositories/previousRoundRankRepository.ts @@ -1,5 +1,5 @@ -import { PowerSnapshot } from '../entities/powerSnapshot'; -import { PreviousRoundRank } from '../entities/previousRoundRank'; +import { PowerSnapshot } from '../entities/powerSnapshot.js'; +import { PreviousRoundRank } from '../entities/previousRoundRank.js'; export const deleteAllPreviousRoundRanks = async () => { return PreviousRoundRank.query( diff --git a/src/repositories/projectAddressRepository.test.ts b/src/repositories/projectAddressRepository.test.ts index 1df448209..19a001baf 100644 --- a/src/repositories/projectAddressRepository.test.ts +++ b/src/repositories/projectAddressRepository.test.ts @@ -9,18 +9,18 @@ import { getPurpleListAddresses, isWalletAddressInPurpleList, removeRecipientAddressOfProject, -} from './projectAddressRepository'; +} from './projectAddressRepository.js'; import { createProjectData, generateRandomEtheriumAddress, generateRandomSolanaAddress, saveProjectDirectlyToDb, saveUserDirectlyToDb, -} from '../../test/testUtils'; -import { NETWORK_IDS } from '../provider'; -import { ProjectStatus } from '../entities/projectStatus'; -import { ProjStatus } from '../entities/project'; -import { ChainType } from '../types/network'; +} from '../../test/testUtils.js'; +import { NETWORK_IDS } from '../provider.js'; +import { ProjectStatus } from '../entities/projectStatus.js'; +import { ProjStatus } from '../entities/project.js'; +import { ChainType } from '../types/network.js'; describe('getPurpleListAddresses test cases', getPurpleListAddressesTestCases); describe( diff --git a/src/repositories/projectAddressRepository.ts b/src/repositories/projectAddressRepository.ts index 69adcfc76..5cdd19510 100644 --- a/src/repositories/projectAddressRepository.ts +++ b/src/repositories/projectAddressRepository.ts @@ -1,9 +1,9 @@ -import { ProjectAddress } from '../entities/projectAddress'; -import { Project } from '../entities/project'; -import { User } from '../entities/user'; -import { ChainType } from '../types/network'; -import { logger } from '../utils/logger'; -import SentryLogger from '../sentryLogger'; +import { ProjectAddress } from '../entities/projectAddress.js'; +import { Project } from '../entities/project.js'; +import { User } from '../entities/user.js'; +import { ChainType } from '../types/network.js'; +import { logger } from '../utils/logger.js'; +import SentryLogger from '../sentryLogger.js'; export const getPurpleListAddresses = async (): Promise< { projectAddress: string }[] diff --git a/src/repositories/projectFuturePowerViewRepository.ts b/src/repositories/projectFuturePowerViewRepository.ts index 0779ab4bf..dfad7c67f 100644 --- a/src/repositories/projectFuturePowerViewRepository.ts +++ b/src/repositories/projectFuturePowerViewRepository.ts @@ -1,4 +1,4 @@ -import { ProjectFuturePowerView } from '../views/projectFuturePowerView'; +import { ProjectFuturePowerView } from '../views/projectFuturePowerView.js'; export const findFuturePowers = async ( projectIds: number[] = [], diff --git a/src/repositories/projectPowerViewRepository.test.ts b/src/repositories/projectPowerViewRepository.test.ts index 90e6890e7..c1d29a9a1 100644 --- a/src/repositories/projectPowerViewRepository.test.ts +++ b/src/repositories/projectPowerViewRepository.test.ts @@ -5,12 +5,12 @@ import { saveProjectDirectlyToDb, saveUserDirectlyToDb, sleep, -} from '../../test/testUtils'; +} from '../../test/testUtils.js'; import { insertSinglePowerBoosting, takePowerBoostingSnapshot, -} from './powerBoostingRepository'; -import { setPowerRound } from './powerRoundRepository'; +} from './powerBoostingRepository.js'; +import { setPowerRound } from './powerRoundRepository.js'; import { getBottomRank, getProjectPowers, @@ -18,15 +18,15 @@ import { refreshProjectFuturePowerView, getProjectFuturePowers, findProjectPowerViewByProjectId, -} from './projectPowerViewRepository'; -import { Project, ProjStatus } from '../entities/project'; -import { PowerBalanceSnapshot } from '../entities/powerBalanceSnapshot'; -import { PowerBoostingSnapshot } from '../entities/powerBoostingSnapshot'; -import { PowerBoosting } from '../entities/powerBoosting'; -import { ProjectStatus } from '../entities/projectStatus'; -import { AppDataSource } from '../orm'; -import { addOrUpdatePowerSnapshotBalances } from './powerBalanceSnapshotRepository'; -import { findPowerSnapshots } from './powerSnapshotRepository'; +} from './projectPowerViewRepository.js'; +import { Project, ProjStatus } from '../entities/project.js'; +import { PowerBalanceSnapshot } from '../entities/powerBalanceSnapshot.js'; +import { PowerBoostingSnapshot } from '../entities/powerBoostingSnapshot.js'; +import { PowerBoosting } from '../entities/powerBoosting.js'; +import { ProjectStatus } from '../entities/projectStatus.js'; +import { AppDataSource } from '../orm.js'; +import { addOrUpdatePowerSnapshotBalances } from './powerBalanceSnapshotRepository.js'; +import { findPowerSnapshots } from './powerSnapshotRepository.js'; describe( 'projectPowerViewRepository test', diff --git a/src/repositories/projectPowerViewRepository.ts b/src/repositories/projectPowerViewRepository.ts index 31318349a..3041196f9 100644 --- a/src/repositories/projectPowerViewRepository.ts +++ b/src/repositories/projectPowerViewRepository.ts @@ -1,11 +1,12 @@ import { Not, MoreThan } from 'typeorm'; +// @ts-expect-error migrate to ESM import { FindOneOptions } from 'typeorm/find-options/FindOneOptions'; -import { ProjectPowerView } from '../views/projectPowerView'; -import { ProjectFuturePowerView } from '../views/projectFuturePowerView'; -import { logger } from '../utils/logger'; -import { updatePowerSnapshotSyncedFlag } from './powerSnapshotRepository'; -import { LastSnapshotProjectPowerView } from '../views/lastSnapshotProjectPowerView'; -import { AppDataSource } from '../orm'; +import { ProjectPowerView } from '../views/projectPowerView.js'; +import { ProjectFuturePowerView } from '../views/projectFuturePowerView.js'; +import { logger } from '../utils/logger.js'; +import { updatePowerSnapshotSyncedFlag } from './powerSnapshotRepository.js'; +import { LastSnapshotProjectPowerView } from '../views/lastSnapshotProjectPowerView.js'; +import { AppDataSource } from '../orm.js'; export const getProjectPowers = async ( take: number = 50, diff --git a/src/repositories/projectRepository.test.ts b/src/repositories/projectRepository.test.ts index cec4c5a14..e75d8b114 100644 --- a/src/repositories/projectRepository.test.ts +++ b/src/repositories/projectRepository.test.ts @@ -11,32 +11,32 @@ import { updateProjectWithVerificationForm, verifyMultipleProjects, verifyProject, -} from './projectRepository'; +} from './projectRepository.js'; import { createProjectData, generateRandomEtheriumAddress, saveProjectDirectlyToDb, saveUserDirectlyToDb, -} from '../../test/testUtils'; -import { createProjectVerificationForm } from './projectVerificationRepository'; -import { PROJECT_VERIFICATION_STATUSES } from '../entities/projectVerificationForm'; -import { NETWORK_IDS } from '../provider'; -import { setPowerRound } from './powerRoundRepository'; -import { refreshProjectPowerView } from './projectPowerViewRepository'; +} from '../../test/testUtils.js'; +import { createProjectVerificationForm } from './projectVerificationRepository.js'; +import { PROJECT_VERIFICATION_STATUSES } from '../entities/projectVerificationForm.js'; +import { NETWORK_IDS } from '../provider.js'; +import { setPowerRound } from './powerRoundRepository.js'; +import { refreshProjectPowerView } from './projectPowerViewRepository.js'; import { insertSinglePowerBoosting, takePowerBoostingSnapshot, -} from './powerBoostingRepository'; -import { Project } from '../entities/project'; -import { User } from '../entities/user'; -import { PowerBalanceSnapshot } from '../entities/powerBalanceSnapshot'; -import { PowerBoostingSnapshot } from '../entities/powerBoostingSnapshot'; -import { AppDataSource } from '../orm'; -import { SUMMARY_LENGTH } from '../constants/summary'; -import { getHtmlTextSummary } from '../utils/utils'; -import { generateRandomString } from '../utils/utils'; -import { addOrUpdatePowerSnapshotBalances } from './powerBalanceSnapshotRepository'; -import { findPowerSnapshots } from './powerSnapshotRepository'; +} from './powerBoostingRepository.js'; +import { Project } from '../entities/project.js'; +import { User } from '../entities/user.js'; +import { PowerBalanceSnapshot } from '../entities/powerBalanceSnapshot.js'; +import { PowerBoostingSnapshot } from '../entities/powerBoostingSnapshot.js'; +import { AppDataSource } from '../orm.js'; +import { SUMMARY_LENGTH } from '../constants/summary.js'; +import { getHtmlTextSummary } from '../utils/utils.js'; +import { generateRandomString } from '../utils/utils.js'; +import { addOrUpdatePowerSnapshotBalances } from './powerBalanceSnapshotRepository.js'; +import { findPowerSnapshots } from './powerSnapshotRepository.js'; describe( 'findProjectByWalletAddress test cases', diff --git a/src/repositories/projectRepository.ts b/src/repositories/projectRepository.ts index a00fedd7c..f7aff814c 100644 --- a/src/repositories/projectRepository.ts +++ b/src/repositories/projectRepository.ts @@ -6,14 +6,17 @@ import { ReviewStatus, RevokeSteps, SortingField, -} from '../entities/project'; -import { ProjectVerificationForm } from '../entities/projectVerificationForm'; -import { ProjectAddress } from '../entities/projectAddress'; -import { i18n, translationErrorMessagesKeys } from '../utils/errorMessages'; -import { publicSelectionFields } from '../entities/user'; -import { ResourcesTotalPerMonthAndYear } from '../resolvers/donationResolver'; -import { OrderDirection, ProjectResolver } from '../resolvers/projectResolver'; -import { getAppropriateNetworkId } from '../services/chains'; +} from '../entities/project.js'; +import { ProjectVerificationForm } from '../entities/projectVerificationForm.js'; +import { ProjectAddress } from '../entities/projectAddress.js'; +import { i18n, translationErrorMessagesKeys } from '../utils/errorMessages.js'; +import { publicSelectionFields } from '../entities/user.js'; +import { ResourcesTotalPerMonthAndYear } from '../resolvers/donationResolver.js'; +import { + OrderDirection, + ProjectResolver, +} from '../resolvers/projectResolver.js'; +import { getAppropriateNetworkId } from '../services/chains/index.js'; export const findProjectById = (projectId: number): Promise => { // return Project.findOne({ id: projectId }); diff --git a/src/repositories/projectSatusHistoryRepository.ts b/src/repositories/projectSatusHistoryRepository.ts index 2b26e65a4..9663b9b83 100644 --- a/src/repositories/projectSatusHistoryRepository.ts +++ b/src/repositories/projectSatusHistoryRepository.ts @@ -1,4 +1,4 @@ -import { ProjectStatusHistory } from '../entities/projectStatusHistory'; +import { ProjectStatusHistory } from '../entities/projectStatusHistory.js'; export const findOneProjectStatusHistoryByProjectId = ( projectId: number, diff --git a/src/repositories/projectSocialMediaRepository.ts b/src/repositories/projectSocialMediaRepository.ts index 45e874dca..ef6f96f25 100644 --- a/src/repositories/projectSocialMediaRepository.ts +++ b/src/repositories/projectSocialMediaRepository.ts @@ -1,5 +1,5 @@ -import { ProjectSocialMedia } from '../entities/projectSocialMedia'; -import { ProjectSocialMediaType } from '../types/projectSocialMediaType'; +import { ProjectSocialMedia } from '../entities/projectSocialMedia.js'; +import { ProjectSocialMediaType } from '../types/projectSocialMediaType.js'; export const addBulkProjectSocialMedia = async ( socialMediaArray: { diff --git a/src/repositories/projectUpdateRepository.test.ts b/src/repositories/projectUpdateRepository.test.ts index 21a263624..ad731e124 100644 --- a/src/repositories/projectUpdateRepository.test.ts +++ b/src/repositories/projectUpdateRepository.test.ts @@ -2,10 +2,10 @@ import { assert } from 'chai'; import { createProjectData, saveProjectDirectlyToDb, -} from '../../test/testUtils'; -import { ProjectUpdate } from '../entities/project'; -import { SUMMARY_LENGTH } from '../constants/summary'; -import { getHtmlTextSummary } from '../utils/utils'; +} from '../../test/testUtils.js'; +import { ProjectUpdate } from '../entities/project.js'; +import { SUMMARY_LENGTH } from '../constants/summary.js'; +import { getHtmlTextSummary } from '../utils/utils.js'; describe('update contentSummary test cases', updateContentSummaryTestCases); diff --git a/src/repositories/projectUpdateRepository.ts b/src/repositories/projectUpdateRepository.ts index cbaf73e17..379ed4f5b 100644 --- a/src/repositories/projectUpdateRepository.ts +++ b/src/repositories/projectUpdateRepository.ts @@ -1,4 +1,4 @@ -import { ProjectUpdate } from '../entities/project'; +import { ProjectUpdate } from '../entities/project.js'; export const findProjectUpdatesByProjectId = async ( projectId: number, diff --git a/src/repositories/projectVerificationRepository.test.ts b/src/repositories/projectVerificationRepository.test.ts index b1c60e628..e67eddc1a 100644 --- a/src/repositories/projectVerificationRepository.test.ts +++ b/src/repositories/projectVerificationRepository.test.ts @@ -5,7 +5,7 @@ import { PROJECT_VERIFICATION_STATUSES, PROJECT_VERIFICATION_STEPS, ProjectContacts, -} from '../entities/projectVerificationForm'; +} from '../entities/projectVerificationForm.js'; import { createProjectData, generateRandomEtheriumAddress, @@ -13,7 +13,7 @@ import { saveProjectDirectlyToDb, saveUserDirectlyToDb, SEED_DATA, -} from '../../test/testUtils'; +} from '../../test/testUtils.js'; import { createProjectVerificationForm, findProjectVerificationFormById, @@ -27,8 +27,8 @@ import { updateProjectVerificationLastStep, verifyForm, verifyMultipleForms, -} from './projectVerificationRepository'; -import { ChainType } from '../types/network'; +} from './projectVerificationRepository.js'; +import { ChainType } from '../types/network.js'; describe( 'createProjectVerificationForm test cases', diff --git a/src/repositories/projectVerificationRepository.ts b/src/repositories/projectVerificationRepository.ts index df600f776..442b81ff1 100644 --- a/src/repositories/projectVerificationRepository.ts +++ b/src/repositories/projectVerificationRepository.ts @@ -8,13 +8,13 @@ import { ProjectContacts, ProjectRegistry, ProjectVerificationForm, -} from '../entities/projectVerificationForm'; -import { findProjectById } from './projectRepository'; -import { findUserById } from './userRepository'; -import { i18n, translationErrorMessagesKeys } from '../utils/errorMessages'; -import { User } from '../entities/user'; -import { getAppropriateNetworkId } from '../services/chains'; -import { logger } from '../utils/logger'; +} from '../entities/projectVerificationForm.js'; +import { findProjectById } from './projectRepository.js'; +import { findUserById } from './userRepository.js'; +import { i18n, translationErrorMessagesKeys } from '../utils/errorMessages.js'; +import { User } from '../entities/user.js'; +import { getAppropriateNetworkId } from '../services/chains/index.js'; +import { logger } from '../utils/logger.js'; export const createProjectVerificationForm = async (params: { userId: number; diff --git a/src/repositories/qfRoundHistoryRepository.test.ts b/src/repositories/qfRoundHistoryRepository.test.ts index 16e07213d..f41fc528c 100644 --- a/src/repositories/qfRoundHistoryRepository.test.ts +++ b/src/repositories/qfRoundHistoryRepository.test.ts @@ -8,15 +8,15 @@ import { saveDonationDirectlyToDb, saveProjectDirectlyToDb, saveUserDirectlyToDb, -} from '../../test/testUtils'; -import { QfRound } from '../entities/qfRound'; -import { Project } from '../entities/project'; +} from '../../test/testUtils.js'; +import { QfRound } from '../entities/qfRound.js'; +import { Project } from '../entities/project.js'; import { fillQfRoundHistory, getQfRoundHistoriesThatDontHaveRelatedDonations, getQfRoundHistory, -} from './qfRoundHistoryRepository'; +} from './qfRoundHistoryRepository.js'; describe('fillQfRoundHistory test cases', fillQfRoundHistoryTestCases); describe( diff --git a/src/repositories/qfRoundHistoryRepository.ts b/src/repositories/qfRoundHistoryRepository.ts index 7a04d7c6b..99df44cd3 100644 --- a/src/repositories/qfRoundHistoryRepository.ts +++ b/src/repositories/qfRoundHistoryRepository.ts @@ -1,6 +1,6 @@ -import { AppDataSource } from '../orm'; -import { QfRoundHistory } from '../entities/qfRoundHistory'; -import { logger } from '../utils/logger'; +import { AppDataSource } from '../orm.js'; +import { QfRoundHistory } from '../entities/qfRoundHistory.js'; +import { logger } from '../utils/logger.js'; export const fillQfRoundHistory = async (): Promise => { try { diff --git a/src/repositories/qfRoundRepository.test.ts b/src/repositories/qfRoundRepository.test.ts index 1814d1a38..984ade7a2 100644 --- a/src/repositories/qfRoundRepository.test.ts +++ b/src/repositories/qfRoundRepository.test.ts @@ -7,8 +7,8 @@ import { saveDonationDirectlyToDb, saveProjectDirectlyToDb, saveUserDirectlyToDb, -} from '../../test/testUtils'; -import { QfRound } from '../entities/qfRound'; +} from '../../test/testUtils.js'; +import { QfRound } from '../entities/qfRound.js'; import { deactivateExpiredQfRounds, findQfRoundById, @@ -17,10 +17,10 @@ import { getProjectDonationsSqrtRootSum, getQfRoundTotalSqrtRootSumSquared, getQfRoundStats, -} from './qfRoundRepository'; -import { Project } from '../entities/project'; -import { refreshProjectEstimatedMatchingView } from '../services/projectViewsService'; -import { getProjectQfRoundStats } from './donationRepository'; +} from './qfRoundRepository.js'; +import { Project } from '../entities/project.js'; +import { refreshProjectEstimatedMatchingView } from '../services/projectViewsService.js'; +import { getProjectQfRoundStats } from './donationRepository.js'; describe( 'getProjectDonationsSqrtRootSum test cases', diff --git a/src/repositories/qfRoundRepository.ts b/src/repositories/qfRoundRepository.ts index 26f8c516d..bbfc8bc29 100644 --- a/src/repositories/qfRoundRepository.ts +++ b/src/repositories/qfRoundRepository.ts @@ -1,15 +1,15 @@ import { Field, Float, Int, ObjectType, registerEnumType } from 'type-graphql'; -import { QfRound } from '../entities/qfRound'; -import { UserQfRoundModelScore } from '../entities/userQfRoundModelScore'; -import { Donation } from '../entities/donation'; -import { User } from '../entities/user'; -import { AppDataSource } from '../orm'; -import { QfArchivedRoundsOrderBy } from '../resolvers/qfRoundResolver'; -import { ProjectEstimatedMatchingView } from '../entities/ProjectEstimatedMatchingView'; -import { Sybil } from '../entities/sybil'; -import { ProjectFraud } from '../entities/projectFraud'; -import config from '../config'; -import { logger } from '../utils/logger'; +import { QfRound } from '../entities/qfRound.js'; +import { UserQfRoundModelScore } from '../entities/userQfRoundModelScore.js'; +import { Donation } from '../entities/donation.js'; +import { User } from '../entities/user.js'; +import { AppDataSource } from '../orm.js'; +import { QfArchivedRoundsOrderBy } from '../resolvers/qfRoundResolver.js'; +import { ProjectEstimatedMatchingView } from '../entities/ProjectEstimatedMatchingView.js'; +import { Sybil } from '../entities/sybil.js'; +import { ProjectFraud } from '../entities/projectFraud.js'; +import config from '../config.js'; +import { logger } from '../utils/logger.js'; const qfRoundEstimatedMatchingParamsCacheDuration = Number( process.env.QF_ROUND_ESTIMATED_MATCHING_CACHE_DURATION || 60000, diff --git a/src/repositories/qfRoundRepository2.ts b/src/repositories/qfRoundRepository2.ts index e3e2696d0..d96bc6907 100644 --- a/src/repositories/qfRoundRepository2.ts +++ b/src/repositories/qfRoundRepository2.ts @@ -1,9 +1,9 @@ -import { QfRound } from '../entities/qfRound'; -import { getOrttoPersonAttributes } from '../adapters/notifications/NotificationCenterAdapter'; -import { getNotificationAdapter } from '../adapters/adaptersFactory'; -import { AppDataSource } from '../orm'; -import { Project } from '../entities/project'; -import { OrttoPerson } from '../adapters/notifications/NotificationAdapterInterface'; +import { QfRound } from '../entities/qfRound.js'; +import { getOrttoPersonAttributes } from '../adapters/notifications/NotificationCenterAdapter.js'; +import { getNotificationAdapter } from '../adapters/adaptersFactory.js'; +import { AppDataSource } from '../orm.js'; +import { Project } from '../entities/project.js'; +import { OrttoPerson } from '../adapters/notifications/NotificationAdapterInterface.js'; // The repository functions that uses Project entity should be here export const relateManyProjectsToQfRound = async (params: { diff --git a/src/repositories/reactionRepository.ts b/src/repositories/reactionRepository.ts index 2fdc705ad..11b31a876 100644 --- a/src/repositories/reactionRepository.ts +++ b/src/repositories/reactionRepository.ts @@ -1,4 +1,4 @@ -import { Reaction } from '../entities/reaction'; +import { Reaction } from '../entities/reaction.js'; export const findUserReactionsByProjectIds = async ( authenticatedUserId: number, diff --git a/src/repositories/recurringDonationRepository.test.ts b/src/repositories/recurringDonationRepository.test.ts index 60c29f122..c9f61a880 100644 --- a/src/repositories/recurringDonationRepository.test.ts +++ b/src/repositories/recurringDonationRepository.test.ts @@ -8,19 +8,19 @@ import { saveDonationDirectlyToDb, saveProjectDirectlyToDb, saveUserDirectlyToDb, -} from '../../test/testUtils'; -import { NETWORK_IDS } from '../provider'; -import { addNewAnchorAddress } from './anchorContractAddressRepository'; +} from '../../test/testUtils.js'; +import { NETWORK_IDS } from '../provider.js'; +import { addNewAnchorAddress } from './anchorContractAddressRepository.js'; import { nonZeroRecurringDonationsByProjectId, createNewRecurringDonation, findRecurringDonationById, findRecurringDonationByProjectIdAndUserIdAndCurrency, updateRecurringDonationFromTheStreamDonations, -} from './recurringDonationRepository'; -import { getPendingRecurringDonationsIds } from './recurringDonationRepository'; -import { DONATION_STATUS } from '../entities/donation'; -import { RECURRING_DONATION_STATUS } from '../entities/recurringDonation'; +} from './recurringDonationRepository.js'; +import { getPendingRecurringDonationsIds } from './recurringDonationRepository.js'; +import { DONATION_STATUS } from '../entities/donation.js'; +import { RECURRING_DONATION_STATUS } from '../entities/recurringDonation.js'; describe( 'createNewRecurringDonationTestCases', diff --git a/src/repositories/recurringDonationRepository.ts b/src/repositories/recurringDonationRepository.ts index 7dec0dea1..083331e97 100644 --- a/src/repositories/recurringDonationRepository.ts +++ b/src/repositories/recurringDonationRepository.ts @@ -1,13 +1,13 @@ import moment from 'moment'; import { MoreThan } from 'typeorm'; -import { Project } from '../entities/project'; -import { User } from '../entities/user'; +import { Project } from '../entities/project.js'; +import { User } from '../entities/user.js'; import { RECURRING_DONATION_STATUS, RecurringDonation, -} from '../entities/recurringDonation'; -import { AnchorContractAddress } from '../entities/anchorContractAddress'; -import { logger } from '../utils/logger'; +} from '../entities/recurringDonation.js'; +import { AnchorContractAddress } from '../entities/anchorContractAddress.js'; +import { logger } from '../utils/logger.js'; export const createNewRecurringDonation = async (params: { project: Project; diff --git a/src/repositories/referredEventRepository.ts b/src/repositories/referredEventRepository.ts index 6aeed0700..2df2939bd 100644 --- a/src/repositories/referredEventRepository.ts +++ b/src/repositories/referredEventRepository.ts @@ -1,4 +1,4 @@ -import { ReferredEvent } from '../entities/referredEvent'; +import { ReferredEvent } from '../entities/referredEvent.js'; export const firstOrCreateReferredEventByUserId = async ( userId: number, diff --git a/src/repositories/socialProfileRepository.test.ts b/src/repositories/socialProfileRepository.test.ts index c4a7116b4..2eea07ac5 100644 --- a/src/repositories/socialProfileRepository.test.ts +++ b/src/repositories/socialProfileRepository.test.ts @@ -5,14 +5,14 @@ import { saveProjectDirectlyToDb, saveProjectVerificationFormDirectlyToDb, saveUserDirectlyToDb, -} from '../../test/testUtils'; +} from '../../test/testUtils.js'; import { createSocialProfile, findSocialProfileById, findSocialProfilesByProjectId, removeSocialProfileById, -} from './socialProfileRepository'; -import { SOCIAL_NETWORKS } from '../entities/socialProfile'; +} from './socialProfileRepository.js'; +import { SOCIAL_NETWORKS } from '../entities/socialProfile.js'; describe( 'removeSocialProfileById test cases', diff --git a/src/repositories/socialProfileRepository.ts b/src/repositories/socialProfileRepository.ts index 5ed6d2798..cde6519f1 100644 --- a/src/repositories/socialProfileRepository.ts +++ b/src/repositories/socialProfileRepository.ts @@ -1,6 +1,6 @@ -import { i18n, translationErrorMessagesKeys } from '../utils/errorMessages'; -import { SocialProfile } from '../entities/socialProfile'; -import { findProjectVerificationFormById } from './projectVerificationRepository'; +import { i18n, translationErrorMessagesKeys } from '../utils/errorMessages.js'; +import { SocialProfile } from '../entities/socialProfile.js'; +import { findProjectVerificationFormById } from './projectVerificationRepository.js'; // TODO should write test cases for all of these functions export const createSocialProfile = async (params: { diff --git a/src/repositories/statusReasonRepository.test.ts b/src/repositories/statusReasonRepository.test.ts index 150cea27e..28cad9592 100644 --- a/src/repositories/statusReasonRepository.test.ts +++ b/src/repositories/statusReasonRepository.test.ts @@ -1,11 +1,11 @@ import { assert } from 'chai'; -import { ProjectStatusReason } from '../entities/projectStatusReason'; +import { ProjectStatusReason } from '../entities/projectStatusReason.js'; import { findAllStatusReasons, findStatusReasonsByStatusId, -} from './statusReasonRepository'; -import { ProjectStatus } from '../entities/projectStatus'; -import { ProjStatus } from '../entities/project'; +} from './statusReasonRepository.js'; +import { ProjectStatus } from '../entities/projectStatus.js'; +import { ProjStatus } from '../entities/project.js'; describe('findAllStatusReasons test cases', () => { it('should find all status reasons', async () => { diff --git a/src/repositories/statusReasonRepository.ts b/src/repositories/statusReasonRepository.ts index b167927a8..5eecf5e37 100644 --- a/src/repositories/statusReasonRepository.ts +++ b/src/repositories/statusReasonRepository.ts @@ -1,4 +1,4 @@ -import { ProjectStatusReason } from '../entities/projectStatusReason'; +import { ProjectStatusReason } from '../entities/projectStatusReason.js'; export const findAllStatusReasons = async (): Promise< ProjectStatusReason[] diff --git a/src/repositories/tokenRepository.ts b/src/repositories/tokenRepository.ts index b764d9075..19cf96e57 100644 --- a/src/repositories/tokenRepository.ts +++ b/src/repositories/tokenRepository.ts @@ -1,4 +1,4 @@ -import { Token } from '../entities/token'; +import { Token } from '../entities/token.js'; export const findTokenByTokenAddress = async ( tokenAddress: string, diff --git a/src/repositories/userProjectPowerViewRepository.test.ts b/src/repositories/userProjectPowerViewRepository.test.ts index 667daf43f..469480e9d 100644 --- a/src/repositories/userProjectPowerViewRepository.test.ts +++ b/src/repositories/userProjectPowerViewRepository.test.ts @@ -5,26 +5,26 @@ import { saveProjectDirectlyToDb, saveUserDirectlyToDb, sleep, -} from '../../test/testUtils'; +} from '../../test/testUtils.js'; import { insertSinglePowerBoosting, takePowerBoostingSnapshot, -} from './powerBoostingRepository'; -import { setPowerRound } from './powerRoundRepository'; +} from './powerBoostingRepository.js'; +import { setPowerRound } from './powerRoundRepository.js'; import { getUserProjectPowers, refreshUserProjectPowerView, -} from './userProjectPowerViewRepository'; -import { PowerBalanceSnapshot } from '../entities/powerBalanceSnapshot'; -import { PowerBoostingSnapshot } from '../entities/powerBoostingSnapshot'; -import { PowerBoosting } from '../entities/powerBoosting'; +} from './userProjectPowerViewRepository.js'; +import { PowerBalanceSnapshot } from '../entities/powerBalanceSnapshot.js'; +import { PowerBoostingSnapshot } from '../entities/powerBoostingSnapshot.js'; +import { PowerBoosting } from '../entities/powerBoosting.js'; import { UserPowerOrderDirection, UserPowerOrderField, -} from '../resolvers/userProjectPowerResolver'; -import { AppDataSource } from '../orm'; -import { addOrUpdatePowerSnapshotBalances } from './powerBalanceSnapshotRepository'; -import { findPowerSnapshots } from './powerSnapshotRepository'; +} from '../resolvers/userProjectPowerResolver.js'; +import { AppDataSource } from '../orm.js'; +import { addOrUpdatePowerSnapshotBalances } from './powerBalanceSnapshotRepository.js'; +import { findPowerSnapshots } from './powerSnapshotRepository.js'; describe('userProjectPowerViewRepository test', () => { beforeEach(async () => { diff --git a/src/repositories/userProjectPowerViewRepository.ts b/src/repositories/userProjectPowerViewRepository.ts index 9d1498bfa..bb5dbf535 100644 --- a/src/repositories/userProjectPowerViewRepository.ts +++ b/src/repositories/userProjectPowerViewRepository.ts @@ -1,8 +1,8 @@ -import { UserProjectPowerView } from '../views/userProjectPowerView'; -import { publicSelectionFields } from '../entities/user'; -import { logger } from '../utils/logger'; -import { UserPowerOrderBy } from '../resolvers/userProjectPowerResolver'; -import { AppDataSource } from '../orm'; +import { UserProjectPowerView } from '../views/userProjectPowerView.js'; +import { publicSelectionFields } from '../entities/user.js'; +import { logger } from '../utils/logger.js'; +import { UserPowerOrderBy } from '../resolvers/userProjectPowerResolver.js'; +import { AppDataSource } from '../orm.js'; export const getUserProjectPowers = async (params: { take: number; diff --git a/src/repositories/userRepository.test.ts b/src/repositories/userRepository.test.ts index 585e4b4a5..9261a22f8 100644 --- a/src/repositories/userRepository.test.ts +++ b/src/repositories/userRepository.test.ts @@ -6,8 +6,8 @@ import { saveDonationDirectlyToDb, saveProjectDirectlyToDb, saveUserDirectlyToDb, -} from '../../test/testUtils'; -import { User, UserRole } from '../entities/user'; +} from '../../test/testUtils.js'; +import { User, UserRole } from '../entities/user.js'; import { findAdminUserByEmail, findAllUsers, @@ -17,9 +17,9 @@ import { findUsersWhoDonatedToProjectExcludeWhoLiked, findUsersWhoLikedProjectExcludeProjectOwner, findUsersWhoSupportProject, -} from './userRepository'; -import { Reaction } from '../entities/reaction'; -import { insertSinglePowerBoosting } from './powerBoostingRepository'; +} from './userRepository.js'; +import { Reaction } from '../entities/reaction.js'; +import { insertSinglePowerBoosting } from './powerBoostingRepository.js'; describe('sql injection test cases', sqlInjectionTestCases); diff --git a/src/repositories/userRepository.ts b/src/repositories/userRepository.ts index 0f7ca150f..7906f525a 100644 --- a/src/repositories/userRepository.ts +++ b/src/repositories/userRepository.ts @@ -1,10 +1,10 @@ -import { publicSelectionFields, User, UserRole } from '../entities/user'; -import { Donation } from '../entities/donation'; -import { Reaction } from '../entities/reaction'; -import { PowerBoosting } from '../entities/powerBoosting'; -import { Project, ProjStatus, ReviewStatus } from '../entities/project'; -import { isEvmAddress } from '../utils/networks'; -import { retrieveActiveQfRoundUserMBDScore } from './qfRoundRepository'; +import { publicSelectionFields, User, UserRole } from '../entities/user.js'; +import { Donation } from '../entities/donation.js'; +import { Reaction } from '../entities/reaction.js'; +import { PowerBoosting } from '../entities/powerBoosting.js'; +import { Project, ProjStatus, ReviewStatus } from '../entities/project.js'; +import { isEvmAddress } from '../utils/networks.js'; +import { retrieveActiveQfRoundUserMBDScore } from './qfRoundRepository.js'; export const findAdminUserByEmail = async ( email: string, diff --git a/src/resolvers/anchorContractAddressResolver.test.ts b/src/resolvers/anchorContractAddressResolver.test.ts index a53a96818..a79fea855 100644 --- a/src/resolvers/anchorContractAddressResolver.test.ts +++ b/src/resolvers/anchorContractAddressResolver.test.ts @@ -1,6 +1,6 @@ import { assert } from 'chai'; import axios from 'axios'; -import { NETWORK_IDS } from '../provider'; +import { NETWORK_IDS } from '../provider.js'; import { createProjectData, generateRandomEtheriumAddress, @@ -9,15 +9,15 @@ import { graphqlUrl, saveProjectDirectlyToDb, saveUserDirectlyToDb, -} from '../../test/testUtils'; -import { createAnchorContractAddressQuery } from '../../test/graphqlQueries'; +} from '../../test/testUtils.js'; +import { createAnchorContractAddressQuery } from '../../test/graphqlQueries.js'; import { errorMessages, translationErrorMessagesKeys, -} from '../utils/errorMessages'; -import { addNewAnchorAddress } from '../repositories/anchorContractAddressRepository'; -import { AnchorContractAddress } from '../entities/anchorContractAddress'; -import { findUserByWalletAddress } from '../repositories/userRepository'; +} from '../utils/errorMessages.js'; +import { addNewAnchorAddress } from '../repositories/anchorContractAddressRepository.js'; +import { AnchorContractAddress } from '../entities/anchorContractAddress.js'; +import { findUserByWalletAddress } from '../repositories/userRepository.js'; describe( 'addAnchorContractAddress test cases', diff --git a/src/resolvers/anchorContractAddressResolver.ts b/src/resolvers/anchorContractAddressResolver.ts index b45fd4c2b..9fb6b53d1 100644 --- a/src/resolvers/anchorContractAddressResolver.ts +++ b/src/resolvers/anchorContractAddressResolver.ts @@ -3,17 +3,17 @@ import { promises as fs } from 'fs'; import { ethers } from 'ethers'; import { Arg, Ctx, Int, Mutation, Resolver } from 'type-graphql'; -import { AnchorContractAddress } from '../entities/anchorContractAddress'; -import { findProjectById } from '../repositories/projectRepository'; -import { i18n, translationErrorMessagesKeys } from '../utils/errorMessages'; +import { AnchorContractAddress } from '../entities/anchorContractAddress.js'; +import { findProjectById } from '../repositories/projectRepository.js'; +import { i18n, translationErrorMessagesKeys } from '../utils/errorMessages.js'; import { addNewAnchorAddress, findActiveAnchorAddress, -} from '../repositories/anchorContractAddressRepository'; -import { ApolloContext } from '../types/ApolloContext'; -import { findUserById } from '../repositories/userRepository'; -import { getProvider } from '../provider'; -import { logger } from '../utils/logger'; +} from '../repositories/anchorContractAddressRepository.js'; +import { ApolloContext } from '../types/ApolloContext.js'; +import { findUserById } from '../repositories/userRepository.js'; +import { getProvider } from '../provider.js'; +import { logger } from '../utils/logger.js'; @Resolver(_of => AnchorContractAddress) export class AnchorContractAddressResolver { diff --git a/src/resolvers/campaignResolver.test.ts b/src/resolvers/campaignResolver.test.ts index 98d4ffd93..f69eab3f7 100644 --- a/src/resolvers/campaignResolver.test.ts +++ b/src/resolvers/campaignResolver.test.ts @@ -5,14 +5,17 @@ import { graphqlUrl, saveProjectDirectlyToDb, SEED_DATA, -} from '../../test/testUtils'; -import { fetchCampaignBySlug, getCampaigns } from '../../test/graphqlQueries'; +} from '../../test/testUtils.js'; +import { + fetchCampaignBySlug, + getCampaigns, +} from '../../test/graphqlQueries.js'; import { Campaign, CampaignFilterField, CampaignType, -} from '../entities/campaign'; -import { generateRandomString } from '../utils/utils'; +} from '../entities/campaign.js'; +import { generateRandomString } from '../utils/utils.js'; describe('Fetch campaigns test cases', fetchCampaignsTestCases); describe('Fetch campaignBySlug test cases', fetchCampaignBySlugTestCases); diff --git a/src/resolvers/campaignResolver.ts b/src/resolvers/campaignResolver.ts index 1a0f32429..7984d7f2a 100644 --- a/src/resolvers/campaignResolver.ts +++ b/src/resolvers/campaignResolver.ts @@ -3,15 +3,15 @@ import { Campaign, CampaignFilterField, CampaignSortingField, -} from '../entities/campaign'; +} from '../entities/campaign.js'; import { findAllActiveCampaigns, findCampaignBySlug, findFeaturedCampaign, -} from '../repositories/campaignRepository'; -import { ApolloContext } from '../types/ApolloContext'; -import { errorMessages } from '../utils/errorMessages'; -import { fillCampaignProjects } from '../services/campaignService'; +} from '../repositories/campaignRepository.js'; +import { ApolloContext } from '../types/ApolloContext.js'; +import { errorMessages } from '../utils/errorMessages.js'; +import { fillCampaignProjects } from '../services/campaignService.js'; registerEnumType(CampaignSortingField, { name: 'CampaignSortingField', diff --git a/src/resolvers/categoryResolver.test.ts b/src/resolvers/categoryResolver.test.ts index 36b521f51..7bccefac5 100644 --- a/src/resolvers/categoryResolver.test.ts +++ b/src/resolvers/categoryResolver.test.ts @@ -4,13 +4,13 @@ import { graphqlUrl, saveCategoryDirectlyToDb, saveMainCategoryDirectlyToDb, -} from '../../test/testUtils'; +} from '../../test/testUtils.js'; import { getCategoryData, getMainCategoriesData, -} from '../../test/graphqlQueries'; -import { generateRandomString } from '../utils/utils'; -import { MainCategory } from '../entities/mainCategory'; +} from '../../test/graphqlQueries.js'; +import { generateRandomString } from '../utils/utils.js'; +import { MainCategory } from '../entities/mainCategory.js'; describe('mainCategoryTestCases() test cases', mainCategoryTestCases); describe('categoryTestCases() test cases', categoryTestCases); diff --git a/src/resolvers/categoryResolver.ts b/src/resolvers/categoryResolver.ts index 6d5c8233b..c1b2433db 100644 --- a/src/resolvers/categoryResolver.ts +++ b/src/resolvers/categoryResolver.ts @@ -1,11 +1,11 @@ import { Query, Resolver } from 'type-graphql'; import { Repository } from 'typeorm'; -import { User } from '../entities/user'; -import { Category } from '../entities/category'; -import { MainCategory } from '../entities/mainCategory'; -import { AppDataSource } from '../orm'; -import config from '../config'; +import { User } from '../entities/user.js'; +import { Category } from '../entities/category.js'; +import { MainCategory } from '../entities/mainCategory.js'; +import { AppDataSource } from '../orm.js'; +import config from '../config.js'; const qfRoundsAndMainCategoryCacheDuration = (config.get('QF_ROUND_AND_MAIN_CATEGORIES_CACHE_DURATION') as number) || @@ -15,6 +15,7 @@ const qfRoundsAndMainCategoryCacheDuration = export class CategoryResolver { constructor( private readonly categoryRepository: Repository, + // @ts-expect-error migrate to ESM private readonly mainCategoryRepository: Repository, ) { this.categoryRepository = diff --git a/src/resolvers/chainvineResolver.test.ts b/src/resolvers/chainvineResolver.test.ts index 6c000fc29..72f2631f6 100644 --- a/src/resolvers/chainvineResolver.test.ts +++ b/src/resolvers/chainvineResolver.test.ts @@ -6,12 +6,12 @@ import { generateTestAccessToken, graphqlUrl, saveUserDirectlyToDb, -} from '../../test/testUtils'; +} from '../../test/testUtils.js'; import { registerClickOnChainvineQuery, registerOnChainvineQuery, -} from '../../test/graphqlQueries'; -import { findReferredEventByUserId } from '../repositories/referredEventRepository'; +} from '../../test/graphqlQueries.js'; +import { findReferredEventByUserId } from '../repositories/referredEventRepository.js'; describe('Register on chainvine test cases', registerOnChainvineTestCases); describe( diff --git a/src/resolvers/chainvineResolver.ts b/src/resolvers/chainvineResolver.ts index 00ef0cef7..33d9e0db1 100644 --- a/src/resolvers/chainvineResolver.ts +++ b/src/resolvers/chainvineResolver.ts @@ -1,14 +1,14 @@ import { Arg, Ctx, Mutation, Resolver } from 'type-graphql'; -import { ApolloContext } from '../types/ApolloContext'; -import { i18n, translationErrorMessagesKeys } from '../utils/errorMessages'; -import { logger } from '../utils/logger'; -import { User } from '../entities/user'; +import { ApolloContext } from '../types/ApolloContext.js'; +import { i18n, translationErrorMessagesKeys } from '../utils/errorMessages.js'; +import { logger } from '../utils/logger.js'; +import { User } from '../entities/user.js'; import { findUserById, findUserByWalletAddress, -} from '../repositories/userRepository'; -import { getChainvineAdapter } from '../adapters/adaptersFactory'; -import { firstOrCreateReferredEventByUserId } from '../repositories/referredEventRepository'; +} from '../repositories/userRepository.js'; +import { getChainvineAdapter } from '../adapters/adaptersFactory.js'; +import { firstOrCreateReferredEventByUserId } from '../repositories/referredEventRepository.js'; @Resolver(_of => User) export class ChainvineResolver { @@ -29,6 +29,7 @@ export class ChainvineResolver { try { const chainvineId = await getChainvineAdapter().generateChainvineId( + // @ts-expect-error migrate to esm dbUser.walletAddress, ); @@ -69,12 +70,14 @@ export class ChainvineResolver { } if (!referredEvent.isDonorClickEventSent) { + // @ts-expect-error migrate to esm await getChainvineAdapter().registerClickEvent(referrerId); referredEvent.isDonorClickEventSent = true; await referredEvent.save(); } if (!referredEvent.isDonorLinkedToReferrer) { + // @ts-expect-error migrate to esm await getChainvineAdapter().linkDonorToReferrer({ walletAddress: dbUser.walletAddress, referrerId, diff --git a/src/resolvers/donationResolver.test.ts b/src/resolvers/donationResolver.test.ts index 15faa2d43..e2221f797 100644 --- a/src/resolvers/donationResolver.test.ts +++ b/src/resolvers/donationResolver.test.ts @@ -1,5 +1,6 @@ import { assert } from 'chai'; import axios from 'axios'; +import moment from 'moment'; import { generateTestAccessToken, graphqlUrl, @@ -16,9 +17,9 @@ import { generateRandomSolanaAddress, generateRandomSolanaTxHash, deleteProjectDirectlyFromDb, -} from '../../test/testUtils'; -import { errorMessages } from '../utils/errorMessages'; -import { Donation, DONATION_STATUS } from '../entities/donation'; +} from '../../test/testUtils.js'; +import { errorMessages } from '../utils/errorMessages.js'; +import { Donation, DONATION_STATUS } from '../entities/donation.js'; import { fetchDonationsByUserIdQuery, fetchDonationsByDonorQuery, @@ -36,39 +37,36 @@ import { fetchNewDonorsCount, fetchNewDonorsDonationTotalUsd, fetchDonationMetricsQuery, -} from '../../test/graphqlQueries'; -import { NETWORK_IDS } from '../provider'; -import { User } from '../entities/user'; -import { Organization, ORGANIZATION_LABELS } from '../entities/organization'; -import { ProjStatus, ReviewStatus } from '../entities/project'; -import { Token } from '../entities/token'; +} from '../../test/graphqlQueries.js'; +import { NETWORK_IDS } from '../provider.js'; +import { User } from '../entities/user.js'; +import { Organization, ORGANIZATION_LABELS } from '../entities/organization.js'; +import { ProjStatus, ReviewStatus } from '../entities/project.js'; +import { Token } from '../entities/token.js'; import { insertSinglePowerBoosting, takePowerBoostingSnapshot, -} from '../repositories/powerBoostingRepository'; -import { setPowerRound } from '../repositories/powerRoundRepository'; -import { refreshProjectPowerView } from '../repositories/projectPowerViewRepository'; -import { PowerBalanceSnapshot } from '../entities/powerBalanceSnapshot'; -import { PowerBoostingSnapshot } from '../entities/powerBoostingSnapshot'; -import { AppDataSource } from '../orm'; -import { generateRandomString } from '../utils/utils'; -import { getChainvineAdapter } from '../adapters/adaptersFactory'; -import { firstOrCreateReferredEventByUserId } from '../repositories/referredEventRepository'; -import { QfRound } from '../entities/qfRound'; -import { addOrUpdatePowerSnapshotBalances } from '../repositories/powerBalanceSnapshotRepository'; -import { findPowerSnapshots } from '../repositories/powerSnapshotRepository'; -import { ChainType } from '../types/network'; -import { getDefaultSolanaChainId } from '../services/chains'; +} from '../repositories/powerBoostingRepository.js'; +import { setPowerRound } from '../repositories/powerRoundRepository.js'; +import { refreshProjectPowerView } from '../repositories/projectPowerViewRepository.js'; +import { PowerBalanceSnapshot } from '../entities/powerBalanceSnapshot.js'; +import { PowerBoostingSnapshot } from '../entities/powerBoostingSnapshot.js'; +import { AppDataSource } from '../orm.js'; +import { generateRandomString } from '../utils/utils.js'; +import { getChainvineAdapter } from '../adapters/adaptersFactory.js'; +import { firstOrCreateReferredEventByUserId } from '../repositories/referredEventRepository.js'; +import { QfRound } from '../entities/qfRound.js'; +import { addOrUpdatePowerSnapshotBalances } from '../repositories/powerBalanceSnapshotRepository.js'; +import { findPowerSnapshots } from '../repositories/powerSnapshotRepository.js'; +import { ChainType } from '../types/network.js'; +import { getDefaultSolanaChainId } from '../services/chains/index.js'; import { DRAFT_DONATION_STATUS, DraftDonation, -} from '../entities/draftDonation'; -import { addNewAnchorAddress } from '../repositories/anchorContractAddressRepository'; -import { createNewRecurringDonation } from '../repositories/recurringDonationRepository'; -import { RECURRING_DONATION_STATUS } from '../entities/recurringDonation'; - -// eslint-disable-next-line @typescript-eslint/no-var-requires -const moment = require('moment'); +} from '../entities/draftDonation.js'; +import { addNewAnchorAddress } from '../repositories/anchorContractAddressRepository.js'; +import { createNewRecurringDonation } from '../repositories/recurringDonationRepository.js'; +import { RECURRING_DONATION_STATUS } from '../entities/recurringDonation.js'; // TODO Write test cases describe('donations() test cases', donationsTestCases); diff --git a/src/resolvers/donationResolver.ts b/src/resolvers/donationResolver.ts index 2397c95c7..de1f8237d 100644 --- a/src/resolvers/donationResolver.ts +++ b/src/resolvers/donationResolver.ts @@ -16,32 +16,32 @@ import { import { Service } from 'typedi'; import { Max, Min } from 'class-validator'; import { Brackets, In, Repository } from 'typeorm'; -import { Donation, DONATION_STATUS, SortField } from '../entities/donation'; -import { ApolloContext } from '../types/ApolloContext'; -import { Project, ProjStatus } from '../entities/project'; -import { Token } from '../entities/token'; -import { publicSelectionFields, User } from '../entities/user'; -import SentryLogger from '../sentryLogger'; -import { i18n, translationErrorMessagesKeys } from '../utils/errorMessages'; -import { NETWORK_IDS } from '../provider'; +import { Donation, DONATION_STATUS, SortField } from '../entities/donation.js'; +import { ApolloContext } from '../types/ApolloContext.js'; +import { Project, ProjStatus } from '../entities/project.js'; +import { Token } from '../entities/token.js'; +import { publicSelectionFields, User } from '../entities/user.js'; +import SentryLogger from '../sentryLogger.js'; +import { i18n, translationErrorMessagesKeys } from '../utils/errorMessages.js'; +import { NETWORK_IDS } from '../provider.js'; import { getDonationToGivethWithDonationBoxMetrics, isTokenAcceptableForProject, syncDonationStatusWithBlockchainNetwork, updateDonationPricesAndValues, -} from '../services/donationService'; +} from '../services/donationService.js'; import { createDonationQueryValidator, getDonationsQueryValidator, resourcePerDateReportValidator, updateDonationQueryValidator, validateWithJoiSchema, -} from '../utils/validators/graphqlQueryValidators'; -import { logger } from '../utils/logger'; +} from '../utils/validators/graphqlQueryValidators.js'; +import { logger } from '../utils/logger.js'; import { findUserById, setUserAsReferrer, -} from '../repositories/userRepository'; +} from '../repositories/userRepository.js'; import { donationsNumberPerDateRange, donationsTotalAmountPerDateRange, @@ -54,23 +54,23 @@ import { isVerifiedDonationExistsInQfRound, newDonorsCount, newDonorsDonationTotalUsd, -} from '../repositories/donationRepository'; -import { sleep } from '../utils/utils'; -import { findProjectRecipientAddressByNetworkId } from '../repositories/projectAddressRepository'; -import { MainCategory } from '../entities/mainCategory'; -import { findProjectById } from '../repositories/projectRepository'; -import { AppDataSource } from '../orm'; -import { getChainvineReferralInfoForDonation } from '../services/chainvineReferralService'; -import { relatedActiveQfRoundForProject } from '../services/qfRoundService'; -import { detectAddressChainType } from '../utils/networks'; -import { ChainType } from '../types/network'; -import { getAppropriateNetworkId } from '../services/chains'; -import { markDraftDonationStatusMatched } from '../repositories/draftDonationRepository'; +} from '../repositories/donationRepository.js'; +import { sleep } from '../utils/utils.js'; +import { findProjectRecipientAddressByNetworkId } from '../repositories/projectAddressRepository.js'; +import { MainCategory } from '../entities/mainCategory.js'; +import { findProjectById } from '../repositories/projectRepository.js'; +import { AppDataSource } from '../orm.js'; +import { getChainvineReferralInfoForDonation } from '../services/chainvineReferralService.js'; +import { relatedActiveQfRoundForProject } from '../services/qfRoundService.js'; +import { detectAddressChainType } from '../utils/networks.js'; +import { ChainType } from '../types/network.js'; +import { getAppropriateNetworkId } from '../services/chains/index.js'; +import { markDraftDonationStatusMatched } from '../repositories/draftDonationRepository.js'; import { DRAFT_DONATION_STATUS, DraftDonation, -} from '../entities/draftDonation'; -import { nonZeroRecurringDonationsByProjectId } from '../repositories/recurringDonationRepository'; +} from '../entities/draftDonation.js'; +import { nonZeroRecurringDonationsByProjectId } from '../repositories/recurringDonationRepository.js'; const draftDonationEnabled = process.env.ENABLE_DRAFT_DONATION === 'true'; diff --git a/src/resolvers/draftDonationResolver.test.ts b/src/resolvers/draftDonationResolver.test.ts index 81abe98b1..bb2abb195 100644 --- a/src/resolvers/draftDonationResolver.test.ts +++ b/src/resolvers/draftDonationResolver.test.ts @@ -8,23 +8,23 @@ import { generateRandomEvmTxHash, generateRandomEtheriumAddress, saveRecurringDonationDirectlyToDb, -} from '../../test/testUtils'; +} from '../../test/testUtils.js'; import { createDraftDonationMutation, createDraftRecurringDonationMutation, -} from '../../test/graphqlQueries'; -import { NETWORK_IDS } from '../provider'; -import { User } from '../entities/user'; -import { generateRandomString } from '../utils/utils'; -import { ChainType } from '../types/network'; +} from '../../test/graphqlQueries.js'; +import { NETWORK_IDS } from '../provider.js'; +import { User } from '../entities/user.js'; +import { generateRandomString } from '../utils/utils.js'; +import { ChainType } from '../types/network.js'; import { DRAFT_DONATION_STATUS, DraftDonation, -} from '../entities/draftDonation'; +} from '../entities/draftDonation.js'; import { DRAFT_RECURRING_DONATION_STATUS, DraftRecurringDonation, -} from '../entities/draftRecurringDonation'; +} from '../entities/draftRecurringDonation.js'; describe('createDraftDonation() test cases', createDraftDonationTestCases); describe( diff --git a/src/resolvers/draftDonationResolver.ts b/src/resolvers/draftDonationResolver.ts index 7d0c585bc..911b50504 100644 --- a/src/resolvers/draftDonationResolver.ts +++ b/src/resolvers/draftDonationResolver.ts @@ -1,30 +1,30 @@ import { Arg, Ctx, Mutation, Resolver } from 'type-graphql'; import { Repository } from 'typeorm'; -import { ApolloContext } from '../types/ApolloContext'; -import { User } from '../entities/user'; -import SentryLogger from '../sentryLogger'; -import { i18n, translationErrorMessagesKeys } from '../utils/errorMessages'; +import { ApolloContext } from '../types/ApolloContext.js'; +import { User } from '../entities/user.js'; +import SentryLogger from '../sentryLogger.js'; +import { i18n, translationErrorMessagesKeys } from '../utils/errorMessages.js'; import { createDraftDonationQueryValidator, createDraftRecurringDonationQueryValidator, validateWithJoiSchema, -} from '../utils/validators/graphqlQueryValidators'; -import { logger } from '../utils/logger'; -import { findUserById } from '../repositories/userRepository'; -import { AppDataSource } from '../orm'; -import { detectAddressChainType } from '../utils/networks'; -import { ChainType } from '../types/network'; -import { getAppropriateNetworkId } from '../services/chains'; +} from '../utils/validators/graphqlQueryValidators.js'; +import { logger } from '../utils/logger.js'; +import { findUserById } from '../repositories/userRepository.js'; +import { AppDataSource } from '../orm.js'; +import { detectAddressChainType } from '../utils/networks.js'; +import { ChainType } from '../types/network.js'; +import { getAppropriateNetworkId } from '../services/chains/index.js'; import { DRAFT_DONATION_STATUS, DraftDonation, -} from '../entities/draftDonation'; -import { DraftRecurringDonation } from '../entities/draftRecurringDonation'; +} from '../entities/draftDonation.js'; +import { DraftRecurringDonation } from '../entities/draftRecurringDonation.js'; import { findRecurringDonationById, findRecurringDonationByProjectIdAndUserIdAndCurrency, -} from '../repositories/recurringDonationRepository'; -import { RecurringDonation } from '../entities/recurringDonation'; +} from '../repositories/recurringDonationRepository.js'; +import { RecurringDonation } from '../entities/recurringDonation.js'; const draftDonationEnabled = process.env.ENABLE_DRAFT_DONATION === 'true'; const draftRecurringDonationEnabled = @@ -32,6 +32,7 @@ const draftRecurringDonationEnabled = @Resolver(_of => User) export class DraftDonationResolver { + // @ts-expect-error migrate to ESM private readonly donationRepository: Repository; constructor() { diff --git a/src/resolvers/givPowerTestingResolver.ts b/src/resolvers/givPowerTestingResolver.ts index 3e4424180..a3facfe74 100644 --- a/src/resolvers/givPowerTestingResolver.ts +++ b/src/resolvers/givPowerTestingResolver.ts @@ -7,26 +7,26 @@ import { Query, Resolver, } from 'type-graphql'; -import { PowerBalanceSnapshot } from '../entities/powerBalanceSnapshot'; -import { findPowerBalances } from '../repositories/powerBalanceSnapshotRepository'; -import { PowerSnapshot } from '../entities/powerSnapshot'; -import { findPowerSnapshots } from '../repositories/powerSnapshotRepository'; -import { PowerRound } from '../entities/powerRound'; -import { getPowerRound } from '../repositories/powerRoundRepository'; -import { ProjectFuturePowerView } from '../views/projectFuturePowerView'; -import { findFuturePowers } from '../repositories/projectFuturePowerViewRepository'; -import { findProjectsPowers } from '../repositories/projectPowerViewRepository'; -import { ProjectPowerView } from '../views/projectPowerView'; -import { UserProjectPowerView } from '../views/userProjectPowerView'; -import { getUserProjectPowers } from '../repositories/userProjectPowerViewRepository'; -import { UserProjectPowerArgs } from './userProjectPowerResolver'; -import { i18n, translationErrorMessagesKeys } from '../utils/errorMessages'; -import { PowerBoostingSnapshot } from '../entities/powerBoostingSnapshot'; +import { PowerBalanceSnapshot } from '../entities/powerBalanceSnapshot.js'; +import { findPowerBalances } from '../repositories/powerBalanceSnapshotRepository.js'; +import { PowerSnapshot } from '../entities/powerSnapshot.js'; +import { findPowerSnapshots } from '../repositories/powerSnapshotRepository.js'; +import { PowerRound } from '../entities/powerRound.js'; +import { getPowerRound } from '../repositories/powerRoundRepository.js'; +import { ProjectFuturePowerView } from '../views/projectFuturePowerView.js'; +import { findFuturePowers } from '../repositories/projectFuturePowerViewRepository.js'; +import { findProjectsPowers } from '../repositories/projectPowerViewRepository.js'; +import { ProjectPowerView } from '../views/projectPowerView.js'; +import { UserProjectPowerView } from '../views/userProjectPowerView.js'; +import { getUserProjectPowers } from '../repositories/userProjectPowerViewRepository.js'; +import { UserProjectPowerArgs } from './userProjectPowerResolver.js'; +import { i18n, translationErrorMessagesKeys } from '../utils/errorMessages.js'; +import { PowerBoostingSnapshot } from '../entities/powerBoostingSnapshot.js'; import { findUserPowerBoostings, findUserProjectPowerBoostingsSnapshots, -} from '../repositories/powerBoostingRepository'; -import { PowerBoosting } from '../entities/powerBoosting'; +} from '../repositories/powerBoostingRepository.js'; +import { PowerBoosting } from '../entities/powerBoosting.js'; const enableGivPower = process.env.ENABLE_GIV_POWER_TESTING as string; diff --git a/src/resolvers/graphqlApi/project.ts b/src/resolvers/graphqlApi/project.ts index ab3858f64..edcbadc16 100644 --- a/src/resolvers/graphqlApi/project.ts +++ b/src/resolvers/graphqlApi/project.ts @@ -1,5 +1,6 @@ import gql from 'graphql-tag'; +// @ts-expect-error migrate to ESM const FETCH_PROJECTS = gql` query FetchProjects($limit: Int, $skip: Int, $orderBy: OrderBy) { topProjects(take: $limit, skip: $skip, orderBy: $orderBy) { @@ -25,6 +26,7 @@ const FETCH_PROJECTS = gql` } `; +// @ts-expect-error migrate to ESM const FETCH_PROJECT = gql` query Project($id: ID!) { project(id: $id) { @@ -43,6 +45,7 @@ const FETCH_PROJECT = gql` } `; +// @ts-expect-error migrate to ESM const FETCH_PROJECT_BY_SLUG = gql` query ProjectBySlug($slug: String!) { projectBySlug(slug: $slug) { @@ -61,6 +64,7 @@ const FETCH_PROJECT_BY_SLUG = gql` } `; +// @ts-expect-error migrate to ESM const ADD_BANK_ACCOUNT = gql` mutation AddBankAccount($id: ID!) { addBankAccount(projectId: $id, source: "") { @@ -70,6 +74,7 @@ const ADD_BANK_ACCOUNT = gql` } `; +// @ts-expect-error migrate to ESM const GET_LINK_BANK_CREATION = gql` query SetProjectBankAccount( $projectId: Float! @@ -83,6 +88,7 @@ const GET_LINK_BANK_CREATION = gql` ) } `; +// @ts-expect-error as d const GET_DONATION_SESSION = gql` query GetStripeProjectDonationSession( $projectId: Float! @@ -112,6 +118,7 @@ const GET_DONATION_SESSION = gql` // } // ` +// @ts-expect-error as d const GET_STRIPE_DONATION_PDF = gql` query GetStripeDonationPDF($sessionId: Float!) { getStripeDonationPDF(sessionId: $sessionId) { @@ -147,6 +154,7 @@ const GET_STRIPE_DONATION_PDF = gql` // } // ` +// @ts-expect-error as d const GET_STRIPE_PROJECT_DONATIONS = gql` query GetStripeDonations($projectId: Float!) { getStripeProjectDonations(projectId: $projectId) { @@ -161,6 +169,7 @@ const GET_STRIPE_PROJECT_DONATIONS = gql` } } `; +// @ts-expect-error as d const ADD_PROJECT = gql` mutation ($project: ProjectInput!) { addProject(project: $project) { @@ -181,6 +190,7 @@ const ADD_PROJECT = gql` /* ** PROJECT UPDATES */ +// @ts-expect-error as d const ADD_PROJECT_UPDATE = gql` mutation ($projectId: Float!, $title: String!, $content: String!) { addProjectUpdate(projectId: $projectId, title: $title, content: $content) { @@ -192,6 +202,7 @@ const ADD_PROJECT_UPDATE = gql` } `; +// @ts-expect-error as d const GET_PROJECT_UPDATES = gql` query GetProjectUpdates( $projectId: Float! diff --git a/src/resolvers/instantPowerResolver.test.ts b/src/resolvers/instantPowerResolver.test.ts index dd17d325c..adf55b919 100644 --- a/src/resolvers/instantPowerResolver.test.ts +++ b/src/resolvers/instantPowerResolver.test.ts @@ -3,20 +3,20 @@ import axios from 'axios'; import { refreshProjectUserInstantPowerView, saveOrUpdateInstantPowerBalances, -} from '../repositories/instantBoostingRepository'; -import { InstantPowerBalance } from '../entities/instantPowerBalance'; +} from '../repositories/instantBoostingRepository.js'; +import { InstantPowerBalance } from '../entities/instantPowerBalance.js'; import { createProjectData, generateRandomEtheriumAddress, graphqlUrl, saveProjectDirectlyToDb, saveUserDirectlyToDb, -} from '../../test/testUtils'; -import { PowerBoosting } from '../entities/powerBoosting'; -import { insertSinglePowerBoosting } from './../repositories/powerBoostingRepository'; -import { getProjectUserInstantPowerQuery } from '../../test/graphqlQueries'; -import { User } from '../entities/user'; -import { Project } from '../entities/project'; +} from '../../test/testUtils.js'; +import { PowerBoosting } from '../entities/powerBoosting.js'; +import { insertSinglePowerBoosting } from './../repositories/powerBoostingRepository.js'; +import { getProjectUserInstantPowerQuery } from '../../test/graphqlQueries.js'; +import { User } from '../entities/user.js'; +import { Project } from '../entities/project.js'; describe( 'projectUserInstantPowerView test cases', diff --git a/src/resolvers/instantPowerResolver.ts b/src/resolvers/instantPowerResolver.ts index 1cb826de6..89b9d64d3 100644 --- a/src/resolvers/instantPowerResolver.ts +++ b/src/resolvers/instantPowerResolver.ts @@ -1,7 +1,7 @@ import { Arg, Field, Int, ObjectType, Query, Resolver } from 'type-graphql'; -import { ProjectUserInstantPowerView } from '../views/projectUserInstantPowerView'; -import { getProjectUserInstantPowerView } from '../repositories/instantBoostingRepository'; +import { ProjectUserInstantPowerView } from '../views/projectUserInstantPowerView.js'; +import { getProjectUserInstantPowerView } from '../repositories/instantBoostingRepository.js'; @ObjectType() class PaginatedProjectUserInstantPowerView { diff --git a/src/resolvers/onboardingFormResolver.ts b/src/resolvers/onboardingFormResolver.ts index c841b6dde..517d3d2e5 100644 --- a/src/resolvers/onboardingFormResolver.ts +++ b/src/resolvers/onboardingFormResolver.ts @@ -1,6 +1,6 @@ import { Arg, Query, Resolver } from 'type-graphql'; -import { getNotificationAdapter } from '../adapters/adaptersFactory'; -import { logger } from '../utils/logger'; +import { getNotificationAdapter } from '../adapters/adaptersFactory.js'; +import { logger } from '../utils/logger.js'; @Resolver() export class OnboardingFormResolver { diff --git a/src/resolvers/powerBoostingResolver.test.ts b/src/resolvers/powerBoostingResolver.test.ts index 85e8041d0..c1ca43a99 100644 --- a/src/resolvers/powerBoostingResolver.test.ts +++ b/src/resolvers/powerBoostingResolver.test.ts @@ -8,26 +8,26 @@ import { saveProjectDirectlyToDb, saveUserDirectlyToDb, SEED_DATA, -} from '../../test/testUtils'; +} from '../../test/testUtils.js'; import { getBottomPowerRankQuery, getPowerBoostingsQuery, setMultiplePowerBoostingMutation, setSinglePowerBoostingMutation, -} from '../../test/graphqlQueries'; -import { errorMessages } from '../utils/errorMessages'; -import { PowerBoosting } from '../entities/powerBoosting'; +} from '../../test/graphqlQueries.js'; +import { errorMessages } from '../utils/errorMessages.js'; +import { PowerBoosting } from '../entities/powerBoosting.js'; import { insertSinglePowerBoosting, takePowerBoostingSnapshot, -} from '../repositories/powerBoostingRepository'; -import { PowerBalanceSnapshot } from '../entities/powerBalanceSnapshot'; -import { PowerBoostingSnapshot } from '../entities/powerBoostingSnapshot'; -import { setPowerRound } from '../repositories/powerRoundRepository'; -import { refreshProjectPowerView } from '../repositories/projectPowerViewRepository'; -import { AppDataSource } from '../orm'; -import { addOrUpdatePowerSnapshotBalances } from '../repositories/powerBalanceSnapshotRepository'; -import { findPowerSnapshots } from '../repositories/powerSnapshotRepository'; +} from '../repositories/powerBoostingRepository.js'; +import { PowerBalanceSnapshot } from '../entities/powerBalanceSnapshot.js'; +import { PowerBoostingSnapshot } from '../entities/powerBoostingSnapshot.js'; +import { setPowerRound } from '../repositories/powerRoundRepository.js'; +import { refreshProjectPowerView } from '../repositories/projectPowerViewRepository.js'; +import { AppDataSource } from '../orm.js'; +import { addOrUpdatePowerSnapshotBalances } from '../repositories/powerBalanceSnapshotRepository.js'; +import { findPowerSnapshots } from '../repositories/powerSnapshotRepository.js'; describe( 'setSinglePowerBoostingMutation test cases', diff --git a/src/resolvers/powerBoostingResolver.ts b/src/resolvers/powerBoostingResolver.ts index 3feb19638..9c0614617 100644 --- a/src/resolvers/powerBoostingResolver.ts +++ b/src/resolvers/powerBoostingResolver.ts @@ -15,17 +15,17 @@ import { } from 'type-graphql'; import { Max, Min } from 'class-validator'; import { Service } from 'typedi'; -import { ApolloContext } from '../types/ApolloContext'; -import { i18n, translationErrorMessagesKeys } from '../utils/errorMessages'; -import { PowerBoosting } from '../entities/powerBoosting'; +import { ApolloContext } from '../types/ApolloContext.js'; +import { i18n, translationErrorMessagesKeys } from '../utils/errorMessages.js'; +import { PowerBoosting } from '../entities/powerBoosting.js'; import { setMultipleBoosting, setSingleBoosting, findPowerBoostings, -} from '../repositories/powerBoostingRepository'; -import { logger } from '../utils/logger'; -import { getBottomRank } from '../repositories/projectPowerViewRepository'; -import { getNotificationAdapter } from '../adapters/adaptersFactory'; +} from '../repositories/powerBoostingRepository.js'; +import { logger } from '../utils/logger.js'; +import { getBottomRank } from '../repositories/projectPowerViewRepository.js'; +import { getNotificationAdapter } from '../adapters/adaptersFactory.js'; enum PowerBoostingOrderDirection { ASC = 'ASC', diff --git a/src/resolvers/projectPowerResolver.test.ts b/src/resolvers/projectPowerResolver.test.ts index bd7045f72..c7713af2a 100644 --- a/src/resolvers/projectPowerResolver.test.ts +++ b/src/resolvers/projectPowerResolver.test.ts @@ -6,25 +6,25 @@ import { graphqlUrl, saveProjectDirectlyToDb, saveUserDirectlyToDb, -} from '../../test/testUtils'; -import { getPowerAmountRankQuery } from '../../test/graphqlQueries'; -import { PowerBalanceSnapshot } from '../entities/powerBalanceSnapshot'; -import { PowerBoostingSnapshot } from '../entities/powerBoostingSnapshot'; +} from '../../test/testUtils.js'; +import { getPowerAmountRankQuery } from '../../test/graphqlQueries.js'; +import { PowerBalanceSnapshot } from '../entities/powerBalanceSnapshot.js'; +import { PowerBoostingSnapshot } from '../entities/powerBoostingSnapshot.js'; import { refreshProjectFuturePowerView, refreshProjectPowerView, -} from '../repositories/projectPowerViewRepository'; -import { User } from '../entities/user'; -import { Project } from '../entities/project'; +} from '../repositories/projectPowerViewRepository.js'; +import { User } from '../entities/user.js'; +import { Project } from '../entities/project.js'; import { insertSinglePowerBoosting, takePowerBoostingSnapshot, -} from '../repositories/powerBoostingRepository'; -import { setPowerRound } from '../repositories/powerRoundRepository'; -import { PowerBoosting } from '../entities/powerBoosting'; -import { AppDataSource } from '../orm'; -import { addOrUpdatePowerSnapshotBalances } from '../repositories/powerBalanceSnapshotRepository'; -import { findPowerSnapshots } from '../repositories/powerSnapshotRepository'; +} from '../repositories/powerBoostingRepository.js'; +import { setPowerRound } from '../repositories/powerRoundRepository.js'; +import { PowerBoosting } from '../entities/powerBoosting.js'; +import { AppDataSource } from '../orm.js'; +import { addOrUpdatePowerSnapshotBalances } from '../repositories/powerBalanceSnapshotRepository.js'; +import { findPowerSnapshots } from '../repositories/powerSnapshotRepository.js'; describe('userProjectPowers test cases', projectPowersTestCases); diff --git a/src/resolvers/projectPowerResolver.ts b/src/resolvers/projectPowerResolver.ts index ed1724e6a..6e3260153 100644 --- a/src/resolvers/projectPowerResolver.ts +++ b/src/resolvers/projectPowerResolver.ts @@ -1,6 +1,6 @@ import { Arg, Query, Resolver, Int } from 'type-graphql'; -import { getPowerAmountRank } from '../repositories/projectPowerViewRepository'; -import { ProjectPowerView } from '../views/projectPowerView'; +import { getPowerAmountRank } from '../repositories/projectPowerViewRepository.js'; +import { ProjectPowerView } from '../views/projectPowerView.js'; @Resolver(_of => ProjectPowerView) export class ProjectPowerResolver { diff --git a/src/resolvers/projectResolver.allProject.test.ts b/src/resolvers/projectResolver.allProject.test.ts index b20bd5e97..103103735 100644 --- a/src/resolvers/projectResolver.allProject.test.ts +++ b/src/resolvers/projectResolver.allProject.test.ts @@ -13,37 +13,37 @@ import { saveProjectDirectlyToDb, saveUserDirectlyToDb, SEED_DATA, -} from '../../test/testUtils'; -import { fetchMultiFilterAllProjectsQuery } from '../../test/graphqlQueries'; -import { Project, ReviewStatus, SortingField } from '../entities/project'; -import { User } from '../entities/user'; -import { NETWORK_IDS } from '../provider'; -import { findProjectRecipientAddressByNetworkId } from '../repositories/projectAddressRepository'; -import { setPowerRound } from '../repositories/powerRoundRepository'; +} from '../../test/testUtils.js'; +import { fetchMultiFilterAllProjectsQuery } from '../../test/graphqlQueries.js'; +import { Project, ReviewStatus, SortingField } from '../entities/project.js'; +import { User } from '../entities/user.js'; +import { NETWORK_IDS } from '../provider.js'; +import { findProjectRecipientAddressByNetworkId } from '../repositories/projectAddressRepository.js'; +import { setPowerRound } from '../repositories/powerRoundRepository.js'; import { insertSinglePowerBoosting, takePowerBoostingSnapshot, -} from '../repositories/powerBoostingRepository'; -import { refreshProjectPowerView } from '../repositories/projectPowerViewRepository'; -import { PowerBalanceSnapshot } from '../entities/powerBalanceSnapshot'; -import { PowerBoostingSnapshot } from '../entities/powerBoostingSnapshot'; -import { ProjectAddress } from '../entities/projectAddress'; -import { PowerBoosting } from '../entities/powerBoosting'; -import { AppDataSource } from '../orm'; +} from '../repositories/powerBoostingRepository.js'; +import { refreshProjectPowerView } from '../repositories/projectPowerViewRepository.js'; +import { PowerBalanceSnapshot } from '../entities/powerBalanceSnapshot.js'; +import { PowerBoostingSnapshot } from '../entities/powerBoostingSnapshot.js'; +import { ProjectAddress } from '../entities/projectAddress.js'; +import { PowerBoosting } from '../entities/powerBoosting.js'; +import { AppDataSource } from '../orm.js'; // We are using cache so redis needs to be cleared for tests with same filters -import { redis } from '../redis'; -import { Campaign, CampaignType } from '../entities/campaign'; -import { generateRandomString, getHtmlTextSummary } from '../utils/utils'; -import { InstantPowerBalance } from '../entities/instantPowerBalance'; -import { saveOrUpdateInstantPowerBalances } from '../repositories/instantBoostingRepository'; -import { updateInstantBoosting } from '../services/instantBoostingServices'; -import { QfRound } from '../entities/qfRound'; -import { calculateEstimatedMatchingWithParams } from '../utils/qfUtils'; -import { refreshProjectEstimatedMatchingView } from '../services/projectViewsService'; -import { addOrUpdatePowerSnapshotBalances } from '../repositories/powerBalanceSnapshotRepository'; -import { findPowerSnapshots } from '../repositories/powerSnapshotRepository'; -import { ChainType } from '../types/network'; -import { ORGANIZATION_LABELS } from '../entities/organization'; +import { redis } from '../redis.js'; +import { Campaign, CampaignType } from '../entities/campaign.js'; +import { generateRandomString, getHtmlTextSummary } from '../utils/utils.js'; +import { InstantPowerBalance } from '../entities/instantPowerBalance.js'; +import { saveOrUpdateInstantPowerBalances } from '../repositories/instantBoostingRepository.js'; +import { updateInstantBoosting } from '../services/instantBoostingServices.js'; +import { QfRound } from '../entities/qfRound.js'; +import { calculateEstimatedMatchingWithParams } from '../utils/qfUtils.js'; +import { refreshProjectEstimatedMatchingView } from '../services/projectViewsService.js'; +import { addOrUpdatePowerSnapshotBalances } from '../repositories/powerBalanceSnapshotRepository.js'; +import { findPowerSnapshots } from '../repositories/powerSnapshotRepository.js'; +import { ChainType } from '../types/network.js'; +import { ORGANIZATION_LABELS } from '../entities/organization.js'; // search and filters describe('all projects test cases --->', allProjectsTestCases); diff --git a/src/resolvers/projectResolver.test.ts b/src/resolvers/projectResolver.test.ts index bc131740a..d285b2c36 100644 --- a/src/resolvers/projectResolver.test.ts +++ b/src/resolvers/projectResolver.test.ts @@ -13,7 +13,7 @@ import { saveProjectDirectlyToDb, saveUserDirectlyToDb, SEED_DATA, -} from '../../test/testUtils'; +} from '../../test/testUtils.js'; import { activateProjectQuery, addProjectUpdateQuery, @@ -38,74 +38,77 @@ import { updateProjectQuery, walletAddressIsPurpleListed, walletAddressIsValid, -} from '../../test/graphqlQueries'; -import { CreateProjectInput, UpdateProjectInput } from './types/project-input'; +} from '../../test/graphqlQueries.js'; +import { + CreateProjectInput, + UpdateProjectInput, +} from './types/project-input.js'; import { errorMessages, i18n, translationErrorMessagesKeys, -} from '../utils/errorMessages'; +} from '../utils/errorMessages.js'; import { Project, ProjectUpdate, ProjStatus, ReviewStatus, RevokeSteps, -} from '../entities/project'; -import { Category } from '../entities/category'; -import { Reaction } from '../entities/reaction'; -import { ProjectStatus } from '../entities/projectStatus'; -import { User } from '../entities/user'; -import { Organization, ORGANIZATION_LABELS } from '../entities/organization'; -import { Token } from '../entities/token'; -import { NETWORK_IDS } from '../provider'; +} from '../entities/project.js'; +import { Category } from '../entities/category.js'; +import { Reaction } from '../entities/reaction.js'; +import { ProjectStatus } from '../entities/projectStatus.js'; +import { User } from '../entities/user.js'; +import { Organization, ORGANIZATION_LABELS } from '../entities/organization.js'; +import { Token } from '../entities/token.js'; +import { NETWORK_IDS } from '../provider.js'; import { addNewProjectAddress, findAllRelatedAddressByWalletAddress, removeRecipientAddressOfProject, -} from '../repositories/projectAddressRepository'; +} from '../repositories/projectAddressRepository.js'; import { PROJECT_VERIFICATION_STATUSES, ProjectVerificationForm, -} from '../entities/projectVerificationForm'; -import { MainCategory } from '../entities/mainCategory'; -import { findOneProjectStatusHistoryByProjectId } from '../repositories/projectSatusHistoryRepository'; -import { setPowerRound } from '../repositories/powerRoundRepository'; +} from '../entities/projectVerificationForm.js'; +import { MainCategory } from '../entities/mainCategory.js'; +import { findOneProjectStatusHistoryByProjectId } from '../repositories/projectSatusHistoryRepository.js'; +import { setPowerRound } from '../repositories/powerRoundRepository.js'; import { insertSinglePowerBoosting, takePowerBoostingSnapshot, -} from '../repositories/powerBoostingRepository'; +} from '../repositories/powerBoostingRepository.js'; import { refreshProjectFuturePowerView, refreshProjectPowerView, -} from '../repositories/projectPowerViewRepository'; -import { PowerBalanceSnapshot } from '../entities/powerBalanceSnapshot'; -import { PowerBoostingSnapshot } from '../entities/powerBoostingSnapshot'; -import { ProjectAddress } from '../entities/projectAddress'; -import { PowerBoosting } from '../entities/powerBoosting'; -import { refreshUserProjectPowerView } from '../repositories/userProjectPowerViewRepository'; -import { AppDataSource } from '../orm'; +} from '../repositories/projectPowerViewRepository.js'; +import { PowerBalanceSnapshot } from '../entities/powerBalanceSnapshot.js'; +import { PowerBoostingSnapshot } from '../entities/powerBoostingSnapshot.js'; +import { ProjectAddress } from '../entities/projectAddress.js'; +import { PowerBoosting } from '../entities/powerBoosting.js'; +import { refreshUserProjectPowerView } from '../repositories/userProjectPowerViewRepository.js'; +import { AppDataSource } from '../orm.js'; // We are using cache so redis needs to be cleared for tests with same filters import { Campaign, CampaignFilterField, CampaignSortingField, CampaignType, -} from '../entities/campaign'; -import { generateRandomString } from '../utils/utils'; -import { FeaturedUpdate } from '../entities/featuredUpdate'; +} from '../entities/campaign.js'; +import { generateRandomString } from '../utils/utils.js'; +import { FeaturedUpdate } from '../entities/featuredUpdate.js'; import { PROJECT_DESCRIPTION_MAX_LENGTH, PROJECT_TITLE_MAX_LENGTH, -} from '../constants/validators'; -import { InstantPowerBalance } from '../entities/instantPowerBalance'; -import { saveOrUpdateInstantPowerBalances } from '../repositories/instantBoostingRepository'; -import { updateInstantBoosting } from '../services/instantBoostingServices'; -import { addOrUpdatePowerSnapshotBalances } from '../repositories/powerBalanceSnapshotRepository'; -import { findPowerSnapshots } from '../repositories/powerSnapshotRepository'; -import { cacheProjectCampaigns } from '../services/campaignService'; -import { ChainType } from '../types/network'; -import { QfRound } from '../entities/qfRound'; +} from '../constants/validators.js'; +import { InstantPowerBalance } from '../entities/instantPowerBalance.js'; +import { saveOrUpdateInstantPowerBalances } from '../repositories/instantBoostingRepository.js'; +import { updateInstantBoosting } from '../services/instantBoostingServices.js'; +import { addOrUpdatePowerSnapshotBalances } from '../repositories/powerBalanceSnapshotRepository.js'; +import { findPowerSnapshots } from '../repositories/powerSnapshotRepository.js'; +import { cacheProjectCampaigns } from '../services/campaignService.js'; +import { ChainType } from '../types/network.js'; +import { QfRound } from '../entities/qfRound.js'; const ARGUMENT_VALIDATION_ERROR_MESSAGE = new ArgumentValidationError([ { property: '' }, diff --git a/src/resolvers/projectResolver.ts b/src/resolvers/projectResolver.ts index 3da3d5d14..be64191ff 100644 --- a/src/resolvers/projectResolver.ts +++ b/src/resolvers/projectResolver.ts @@ -17,10 +17,12 @@ import { Resolver, } from 'type-graphql'; import graphqlFields from 'graphql-fields'; +// @ts-expect-error as d import { SelectQueryBuilder } from 'typeorm/query-builder/SelectQueryBuilder'; +// @ts-expect-error as d import { ObjectLiteral } from 'typeorm/common/ObjectLiteral'; import { GraphQLResolveInfo } from 'graphql/type'; -import { Reaction } from '../entities/reaction'; +import { Reaction } from '../entities/reaction.js'; import { FilterField, OrderField, @@ -30,43 +32,43 @@ import { ReviewStatus, RevokeSteps, SortingField, -} from '../entities/project'; -import { ProjectStatus } from '../entities/projectStatus'; +} from '../entities/project.js'; +import { ProjectStatus } from '../entities/projectStatus.js'; import { CreateProjectInput, ImageUpload, UpdateProjectInput, -} from './types/project-input'; -import { pinFile } from '../middleware/pinataUtils'; -import { Category } from '../entities/category'; -import { Donation } from '../entities/donation'; -import { ProjectImage } from '../entities/projectImage'; -import { ApolloContext } from '../types/ApolloContext'; -import { publicSelectionFields, User } from '../entities/user'; -import { Context } from '../context'; -import SentryLogger from '../sentryLogger'; +} from './types/project-input.js'; +import { pinFile } from '../middleware/pinataUtils.js'; +import { Category } from '../entities/category.js'; +import { Donation } from '../entities/donation.js'; +import { ProjectImage } from '../entities/projectImage.js'; +import { ApolloContext } from '../types/ApolloContext.js'; +import { publicSelectionFields, User } from '../entities/user.js'; +import { Context } from '../context.js'; +import SentryLogger from '../sentryLogger.js'; import { errorMessages, i18n, translationErrorMessagesKeys, -} from '../utils/errorMessages'; +} from '../utils/errorMessages.js'; import { canUserVisitProject, validateProjectRelatedAddresses, validateProjectTitle, validateProjectTitleForEdit, validateProjectWalletAddress, -} from '../utils/validators/projectValidator'; -import { updateProjectUpdatesStatistics } from '../services/projectUpdatesService'; -import { logger } from '../utils/logger'; -import { getLoggedInUser } from '../services/authorizationServices'; +} from '../utils/validators/projectValidator.js'; +import { updateProjectUpdatesStatistics } from '../services/projectUpdatesService.js'; +import { logger } from '../utils/logger.js'; +import { getLoggedInUser } from '../services/authorizationServices.js'; import { getAppropriateSlug, getQualityScore, -} from '../services/projectService'; -import { Organization, ORGANIZATION_LABELS } from '../entities/organization'; -import { Token } from '../entities/token'; -import { findUserById } from '../repositories/userRepository'; +} from '../services/projectService.js'; +import { Organization, ORGANIZATION_LABELS } from '../entities/organization.js'; +import { Token } from '../entities/token.js'; +import { findUserById } from '../repositories/userRepository.js'; import { addBulkNewProjectAddress, addNewProjectAddress, @@ -74,8 +76,8 @@ import { getPurpleListAddresses, isWalletAddressInPurpleList, removeRecipientAddressOfProject, -} from '../repositories/projectAddressRepository'; -import { RelatedAddressInputType } from './types/ProjectVerificationUpdateInput'; +} from '../repositories/projectAddressRepository.js'; +import { RelatedAddressInputType } from './types/ProjectVerificationUpdateInput.js'; import { FilterProjectQueryInputParams, filterProjectsQuery, @@ -83,37 +85,37 @@ import { findProjectIdBySlug, totalProjectsPerDate, totalProjectsPerDateByMonthAndYear, -} from '../repositories/projectRepository'; -import { sortTokensByOrderAndAlphabets } from '../utils/tokenUtils'; -import { getNotificationAdapter } from '../adapters/adaptersFactory'; -import { NETWORK_IDS } from '../provider'; -import { getVerificationFormStatusByProjectId } from '../repositories/projectVerificationRepository'; +} from '../repositories/projectRepository.js'; +import { sortTokensByOrderAndAlphabets } from '../utils/tokenUtils.js'; +import { getNotificationAdapter } from '../adapters/adaptersFactory.js'; +import { NETWORK_IDS } from '../provider.js'; +import { getVerificationFormStatusByProjectId } from '../repositories/projectVerificationRepository.js'; import { resourcePerDateReportValidator, validateWithJoiSchema, -} from '../utils/validators/graphqlQueryValidators'; +} from '../utils/validators/graphqlQueryValidators.js'; import { refreshProjectFuturePowerView, refreshProjectPowerView, -} from '../repositories/projectPowerViewRepository'; -import { ResourcePerDateRange } from './donationResolver'; -import { findUserReactionsByProjectIds } from '../repositories/reactionRepository'; -import { AppDataSource } from '../orm'; -import { creteSlugFromProject, isSocialMediaEqual } from '../utils/utils'; -import { findCampaignBySlug } from '../repositories/campaignRepository'; -import { Campaign } from '../entities/campaign'; -import { FeaturedUpdate } from '../entities/featuredUpdate'; -import { PROJECT_UPDATE_CONTENT_MAX_LENGTH } from '../constants/validators'; -import { calculateGivbackFactor } from '../services/givbackService'; -import { ProjectBySlugResponse } from './types/projectResolver'; -import { ChainType } from '../types/network'; -import { findActiveQfRound } from '../repositories/qfRoundRepository'; -import { getAllProjectsRelatedToActiveCampaigns } from '../services/campaignService'; -import { getAppropriateNetworkId } from '../services/chains'; +} from '../repositories/projectPowerViewRepository.js'; +import { ResourcePerDateRange } from './donationResolver.js'; +import { findUserReactionsByProjectIds } from '../repositories/reactionRepository.js'; +import { AppDataSource } from '../orm.js'; +import { creteSlugFromProject, isSocialMediaEqual } from '../utils/utils.js'; +import { findCampaignBySlug } from '../repositories/campaignRepository.js'; +import { Campaign } from '../entities/campaign.js'; +import { FeaturedUpdate } from '../entities/featuredUpdate.js'; +import { PROJECT_UPDATE_CONTENT_MAX_LENGTH } from '../constants/validators.js'; +import { calculateGivbackFactor } from '../services/givbackService.js'; +import { ProjectBySlugResponse } from './types/projectResolver.js'; +import { ChainType } from '../types/network.js'; +import { findActiveQfRound } from '../repositories/qfRoundRepository.js'; +import { getAllProjectsRelatedToActiveCampaigns } from '../services/campaignService.js'; +import { getAppropriateNetworkId } from '../services/chains/index.js'; import { addBulkProjectSocialMedia, removeProjectSocialMedia, -} from '../repositories/projectSocialMediaRepository'; +} from '../repositories/projectSocialMediaRepository.js'; const projectUpdatsCacheDuration = 1000 * 60 * 60; @@ -635,7 +637,9 @@ export class ProjectResolver { private readonly projectUpdateRepository: Repository, private readonly projectStatusRepository: Repository, private readonly categoryRepository: Repository, + // @ts-expect-error as d private readonly userRepository: Repository, + // @ts-expect-error as d private readonly donationRepository: Repository, private readonly projectImageRepository: Repository, ) { diff --git a/src/resolvers/projectVerificationFormResolver.test.ts b/src/resolvers/projectVerificationFormResolver.test.ts index d06773e09..9e877ffcf 100644 --- a/src/resolvers/projectVerificationFormResolver.test.ts +++ b/src/resolvers/projectVerificationFormResolver.test.ts @@ -10,7 +10,7 @@ import { saveProjectDirectlyToDb, saveUserDirectlyToDb, sleep, -} from '../../test/testUtils'; +} from '../../test/testUtils.js'; import { createProjectVerificationFormMutation, getAllowedCountries, @@ -18,7 +18,7 @@ import { projectVerificationConfirmEmail, projectVerificationSendEmailConfirmation, updateProjectVerificationFormMutation, -} from '../../test/graphqlQueries'; +} from '../../test/graphqlQueries.js'; import { ManagingFunds, Milestones, @@ -28,19 +28,19 @@ import { ProjectContacts, ProjectRegistry, ProjectVerificationForm, -} from '../entities/projectVerificationForm'; -import { ProjStatus, ReviewStatus } from '../entities/project'; +} from '../entities/projectVerificationForm.js'; +import { ProjStatus, ReviewStatus } from '../entities/project.js'; import { createProjectVerificationForm, findProjectVerificationFormById, -} from '../repositories/projectVerificationRepository'; -import { errorMessages } from '../utils/errorMessages'; -import { NETWORK_IDS } from '../provider'; -import { countriesList, generateRandomString } from '../utils/utils'; -import { createSocialProfile } from '../repositories/socialProfileRepository'; -import { SOCIAL_NETWORKS } from '../entities/socialProfile'; -import { ChainType } from '../types/network'; -import { getDefaultSolanaChainId } from '../services/chains'; +} from '../repositories/projectVerificationRepository.js'; +import { errorMessages } from '../utils/errorMessages.js'; +import { NETWORK_IDS } from '../provider.js'; +import { countriesList, generateRandomString } from '../utils/utils.js'; +import { createSocialProfile } from '../repositories/socialProfileRepository.js'; +import { SOCIAL_NETWORKS } from '../entities/socialProfile.js'; +import { ChainType } from '../types/network.js'; +import { getDefaultSolanaChainId } from '../services/chains/index.js'; describe( 'createProjectVerification test cases', diff --git a/src/resolvers/projectVerificationFormResolver.ts b/src/resolvers/projectVerificationFormResolver.ts index b5a6e170d..ba442dccc 100644 --- a/src/resolvers/projectVerificationFormResolver.ts +++ b/src/resolvers/projectVerificationFormResolver.ts @@ -1,39 +1,39 @@ import { Arg, Ctx, Mutation, Query, Resolver } from 'type-graphql'; import * as jwt from 'jsonwebtoken'; import moment from 'moment'; -import { ApolloContext } from '../types/ApolloContext'; +import { ApolloContext } from '../types/ApolloContext.js'; import { errorMessages, i18n, translationErrorMessagesKeys, -} from '../utils/errorMessages'; +} from '../utils/errorMessages.js'; import { createProjectVerificationRequestValidator, getCurrentProjectVerificationRequestValidator, validateWithJoiSchema, -} from '../utils/validators/graphqlQueryValidators'; -import { logger } from '../utils/logger'; +} from '../utils/validators/graphqlQueryValidators.js'; +import { logger } from '../utils/logger.js'; import { findProjectById, findProjectBySlug, -} from '../repositories/projectRepository'; +} from '../repositories/projectRepository.js'; import { createProjectVerificationForm, findProjectVerificationFormByEmailConfirmationToken, findProjectVerificationFormById, getVerificationFormByProjectId, -} from '../repositories/projectVerificationRepository'; +} from '../repositories/projectVerificationRepository.js'; import { PROJECT_VERIFICATION_STATUSES, ProjectVerificationForm, PROJECT_VERIFICATION_STEPS, -} from '../entities/projectVerificationForm'; -import { updateProjectVerificationFormByUser } from '../services/projectVerificationFormService'; -import { ProjectVerificationUpdateInput } from './types/ProjectVerificationUpdateInput'; -import config from '../config'; -import { countriesList } from '../utils/utils'; -import { Country } from '../entities/Country'; -import { getNotificationAdapter } from '../adapters/adaptersFactory'; +} from '../entities/projectVerificationForm.js'; +import { updateProjectVerificationFormByUser } from '../services/projectVerificationFormService.js'; +import { ProjectVerificationUpdateInput } from './types/ProjectVerificationUpdateInput.js'; +import config from '../config.js'; +import { countriesList } from '../utils/utils.js'; +import { Country } from '../entities/Country.js'; +import { getNotificationAdapter } from '../adapters/adaptersFactory.js'; @Resolver(_of => ProjectVerificationForm) export class ProjectVerificationFormResolver { diff --git a/src/resolvers/qfRoundHistoryResolver.test.ts b/src/resolvers/qfRoundHistoryResolver.test.ts index d89e081cc..b08a31abe 100644 --- a/src/resolvers/qfRoundHistoryResolver.test.ts +++ b/src/resolvers/qfRoundHistoryResolver.test.ts @@ -9,11 +9,11 @@ import { saveDonationDirectlyToDb, saveProjectDirectlyToDb, saveUserDirectlyToDb, -} from '../../test/testUtils'; -import { Project } from '../entities/project'; -import { QfRound } from '../entities/qfRound'; -import { fillQfRoundHistory } from '../repositories/qfRoundHistoryRepository'; -import { getQfRoundHistoryQuery } from '../../test/graphqlQueries'; +} from '../../test/testUtils.js'; +import { Project } from '../entities/project.js'; +import { QfRound } from '../entities/qfRound.js'; +import { fillQfRoundHistory } from '../repositories/qfRoundHistoryRepository.js'; +import { getQfRoundHistoryQuery } from '../../test/graphqlQueries.js'; describe('Fetch getQfRoundHistory test cases', getQfRoundHistoryTestCases); diff --git a/src/resolvers/qfRoundHistoryResolver.ts b/src/resolvers/qfRoundHistoryResolver.ts index cecb48aaf..ac1df4ffc 100644 --- a/src/resolvers/qfRoundHistoryResolver.ts +++ b/src/resolvers/qfRoundHistoryResolver.ts @@ -1,6 +1,6 @@ import { Arg, Int, Query, Resolver } from 'type-graphql'; -import { QfRoundHistory } from '../entities/qfRoundHistory'; -import { getQfRoundHistory } from '../repositories/qfRoundHistoryRepository'; +import { QfRoundHistory } from '../entities/qfRoundHistory.js'; +import { getQfRoundHistory } from '../repositories/qfRoundHistoryRepository.js'; @Resolver(_of => QfRoundHistory) export class QfRoundHistoryResolver { diff --git a/src/resolvers/qfRoundResolver.test.ts b/src/resolvers/qfRoundResolver.test.ts index 946b278c1..15f3cf759 100644 --- a/src/resolvers/qfRoundResolver.test.ts +++ b/src/resolvers/qfRoundResolver.test.ts @@ -10,18 +10,18 @@ import { saveProjectDirectlyToDb, saveUserDirectlyToDb, SEED_DATA, -} from '../../test/testUtils'; -import { Project } from '../entities/project'; -import { QfRound } from '../entities/qfRound'; -import { refreshProjectEstimatedMatchingView } from '../services/projectViewsService'; +} from '../../test/testUtils.js'; +import { Project } from '../entities/project.js'; +import { QfRound } from '../entities/qfRound.js'; +import { refreshProjectEstimatedMatchingView } from '../services/projectViewsService.js'; import { fetchQFArchivedRounds, qfRoundStatsQuery, scoreUserAddressMutation, -} from '../../test/graphqlQueries'; -import { generateRandomString } from '../utils/utils'; -import { OrderDirection } from './projectResolver'; -import { QfArchivedRoundsSortType } from '../repositories/qfRoundRepository'; +} from '../../test/graphqlQueries.js'; +import { generateRandomString } from '../utils/utils.js'; +import { OrderDirection } from './projectResolver.js'; +import { QfArchivedRoundsSortType } from '../repositories/qfRoundRepository.js'; describe('Fetch estimatedMatching test cases', fetchEstimatedMatchingTestCases); describe('Fetch qfRoundStats test cases', fetchQfRoundStatesTestCases); diff --git a/src/resolvers/qfRoundResolver.ts b/src/resolvers/qfRoundResolver.ts index dfb931a44..ffac9fad6 100644 --- a/src/resolvers/qfRoundResolver.ts +++ b/src/resolvers/qfRoundResolver.ts @@ -11,7 +11,7 @@ import { } from 'type-graphql'; import { Service } from 'typedi'; import { Max, Min } from 'class-validator'; -import { User } from '../entities/user'; +import { User } from '../entities/user.js'; import { findActiveQfRound, findQfRounds, @@ -22,14 +22,14 @@ import { QfArchivedRoundsSortType, getQfRoundStats, getQfRoundTotalSqrtRootSumSquared, -} from '../repositories/qfRoundRepository'; -import { QfRound } from '../entities/qfRound'; -import { OrderDirection } from './projectResolver'; -import { getGitcoinAdapter } from '../adapters/adaptersFactory'; -import { logger } from '../utils/logger'; -import { i18n, translationErrorMessagesKeys } from '../utils/errorMessages'; -import { UserQfRoundModelScore } from '../entities/userQfRoundModelScore'; -import { findUserByWalletAddress } from '../repositories/userRepository'; +} from '../repositories/qfRoundRepository.js'; +import { QfRound } from '../entities/qfRound.js'; +import { OrderDirection } from './projectResolver.js'; +import { getGitcoinAdapter } from '../adapters/adaptersFactory.js'; +import { logger } from '../utils/logger.js'; +import { i18n, translationErrorMessagesKeys } from '../utils/errorMessages.js'; +import { UserQfRoundModelScore } from '../entities/userQfRoundModelScore.js'; +import { findUserByWalletAddress } from '../repositories/userRepository.js'; @ObjectType() export class QfRoundStatsResponse { diff --git a/src/resolvers/reactionResolver.test.ts b/src/resolvers/reactionResolver.test.ts index 624a5e08c..80545520d 100644 --- a/src/resolvers/reactionResolver.test.ts +++ b/src/resolvers/reactionResolver.test.ts @@ -6,15 +6,15 @@ import { PROJECT_UPDATE_SEED_DATA, SEED_DATA, dbIndependentTests, -} from '../../test/testUtils'; +} from '../../test/testUtils.js'; import { likeProjectQuery, likeProjectUpdateQuery, unlikeProjectQuery, unlikeProjectUpdateQuery, -} from '../../test/graphqlQueries'; -import { Project, ProjectUpdate } from '../entities/project'; -import { Reaction } from '../entities/reaction'; +} from '../../test/graphqlQueries.js'; +import { Project, ProjectUpdate } from '../entities/project.js'; +import { Reaction } from '../entities/reaction.js'; describe('like and unlike project test cases --->', likeUnlikeProjectTestCases); describe( diff --git a/src/resolvers/reactionResolver.ts b/src/resolvers/reactionResolver.ts index ac5faa82f..d9d516d5c 100644 --- a/src/resolvers/reactionResolver.ts +++ b/src/resolvers/reactionResolver.ts @@ -1,13 +1,13 @@ import { Arg, Ctx, Int, Mutation, Query, Resolver } from 'type-graphql'; -import { Reaction } from '../entities/reaction'; -import { Context } from '../context'; -import { Project, ProjectUpdate, ProjStatus } from '../entities/project'; -import { ApolloContext } from '../types/ApolloContext'; -import { i18n, translationErrorMessagesKeys } from '../utils/errorMessages'; -import { logger } from '../utils/logger'; -import { getNotificationAdapter } from '../adapters/adaptersFactory'; -import { findProjectById } from '../repositories/projectRepository'; -import { AppDataSource } from '../orm'; +import { Reaction } from '../entities/reaction.js'; +import { Context } from '../context.js'; +import { Project, ProjectUpdate, ProjStatus } from '../entities/project.js'; +import { ApolloContext } from '../types/ApolloContext.js'; +import { i18n, translationErrorMessagesKeys } from '../utils/errorMessages.js'; +import { logger } from '../utils/logger.js'; +import { getNotificationAdapter } from '../adapters/adaptersFactory.js'; +import { findProjectById } from '../repositories/projectRepository.js'; +import { AppDataSource } from '../orm.js'; @Resolver(_of => Reaction) export class ReactionResolver { diff --git a/src/resolvers/recurringDonationResolver.test.ts b/src/resolvers/recurringDonationResolver.test.ts index 48021ebc4..ecb13ae85 100644 --- a/src/resolvers/recurringDonationResolver.test.ts +++ b/src/resolvers/recurringDonationResolver.test.ts @@ -1,7 +1,7 @@ import moment from 'moment'; import { assert } from 'chai'; import axios from 'axios'; -import { NETWORK_IDS } from '../provider'; +import { NETWORK_IDS } from '../provider.js'; import { createProjectData, generateRandomEtheriumAddress, @@ -11,7 +11,7 @@ import { saveProjectDirectlyToDb, saveRecurringDonationDirectlyToDb, saveUserDirectlyToDb, -} from '../../test/testUtils'; +} from '../../test/testUtils.js'; import { createRecurringDonationQuery, fetchRecurringDonationsByProjectIdQuery, @@ -19,18 +19,18 @@ import { updateRecurringDonationQuery, updateRecurringDonationQueryById, updateRecurringDonationStatusMutation, -} from '../../test/graphqlQueries'; +} from '../../test/graphqlQueries.js'; describe( 'createRecurringDonation test cases', createRecurringDonationTestCases, ); -import { errorMessages } from '../utils/errorMessages'; -import { addNewAnchorAddress } from '../repositories/anchorContractAddressRepository'; -import { RECURRING_DONATION_STATUS } from '../entities/recurringDonation'; -import { QfRound } from '../entities/qfRound'; -import { generateRandomString } from '../utils/utils'; -import { ORGANIZATION_LABELS } from '../entities/organization'; +import { errorMessages } from '../utils/errorMessages.js'; +import { addNewAnchorAddress } from '../repositories/anchorContractAddressRepository.js'; +import { RECURRING_DONATION_STATUS } from '../entities/recurringDonation.js'; +import { QfRound } from '../entities/qfRound.js'; +import { generateRandomString } from '../utils/utils.js'; +import { ORGANIZATION_LABELS } from '../entities/organization.js'; describe( 'updateRecurringDonation test cases', diff --git a/src/resolvers/recurringDonationResolver.ts b/src/resolvers/recurringDonationResolver.ts index 6d1c5719b..ef1dec183 100644 --- a/src/resolvers/recurringDonationResolver.ts +++ b/src/resolvers/recurringDonationResolver.ts @@ -16,35 +16,35 @@ import { import { Brackets } from 'typeorm'; import { Service } from 'typedi'; import { Max, Min } from 'class-validator'; -import { AnchorContractAddress } from '../entities/anchorContractAddress'; -import { findProjectById } from '../repositories/projectRepository'; +import { AnchorContractAddress } from '../entities/anchorContractAddress.js'; +import { findProjectById } from '../repositories/projectRepository.js'; import { errorMessages, i18n, translationErrorMessagesKeys, -} from '../utils/errorMessages'; -import { findActiveAnchorAddress } from '../repositories/anchorContractAddressRepository'; -import { ApolloContext } from '../types/ApolloContext'; -import { findUserById } from '../repositories/userRepository'; +} from '../utils/errorMessages.js'; +import { findActiveAnchorAddress } from '../repositories/anchorContractAddressRepository.js'; +import { ApolloContext } from '../types/ApolloContext.js'; +import { findUserById } from '../repositories/userRepository.js'; import { RECURRING_DONATION_STATUS, RecurringDonation, -} from '../entities/recurringDonation'; +} from '../entities/recurringDonation.js'; import { createNewRecurringDonation, findRecurringDonationById, findRecurringDonationByProjectIdAndUserIdAndCurrency, updateRecurringDonation, -} from '../repositories/recurringDonationRepository'; -import { detectAddressChainType } from '../utils/networks'; -import { logger } from '../utils/logger'; +} from '../repositories/recurringDonationRepository.js'; +import { detectAddressChainType } from '../utils/networks.js'; +import { logger } from '../utils/logger.js'; import { resourcePerDateReportValidator, updateDonationQueryValidator, validateWithJoiSchema, -} from '../utils/validators/graphqlQueryValidators'; -import { sleep } from '../utils/utils'; -import SentryLogger from '../sentryLogger'; +} from '../utils/validators/graphqlQueryValidators.js'; +import { sleep } from '../utils/utils.js'; +import SentryLogger from '../sentryLogger.js'; import { updateRecurringDonationStatusWithNetwork, recurringDonationsCountPerDateRange, @@ -53,9 +53,9 @@ import { recurringDonationsStreamedCUsdTotalPerMonth, recurringDonationsTotalPerToken, recurringDonationsCountPerToken, -} from '../services/recurringDonationService'; -import { markDraftRecurringDonationStatusMatched } from '../repositories/draftRecurringDonationRepository'; -import { ResourcePerDateRange } from './donationResolver'; +} from '../services/recurringDonationService.js'; +import { markDraftRecurringDonationStatusMatched } from '../repositories/draftRecurringDonationRepository.js'; +import { ResourcePerDateRange } from './donationResolver.js'; @InputType() class RecurringDonationSortBy { @Field(_type => RecurringDonationSortField) diff --git a/src/resolvers/resolvers.ts b/src/resolvers/resolvers.ts index 1ed88468a..ec00995cf 100644 --- a/src/resolvers/resolvers.ts +++ b/src/resolvers/resolvers.ts @@ -1,26 +1,26 @@ -import { UserResolver } from './userResolver'; -import { ProjectResolver } from './projectResolver'; -import { MeResolver } from '../user/MeResolver'; -import { UploadResolver } from './uploadResolver'; -import { CategoryResolver } from './categoryResolver'; -import { DonationResolver } from './donationResolver'; -import { ReactionResolver } from './reactionResolver'; -import { StatusReasonResolver } from './statusReasonResolver'; -import { ProjectVerificationFormResolver } from './projectVerificationFormResolver'; -import { SocialProfilesResolver } from './socialProfilesResolver'; -import { PowerBoostingResolver } from './powerBoostingResolver'; -import { UserProjectPowerResolver } from './userProjectPowerResolver'; -import { GivPowerTestingResolver } from './givPowerTestingResolver'; -import { ProjectPowerResolver } from './projectPowerResolver'; -import { CampaignResolver } from './campaignResolver'; -import { ChainvineResolver } from './chainvineResolver'; -import { QfRoundResolver } from './qfRoundResolver'; -import { QfRoundHistoryResolver } from './qfRoundHistoryResolver'; -import { ProjectUserInstantPowerViewResolver } from './instantPowerResolver'; -import { AnchorContractAddressResolver } from './anchorContractAddressResolver'; -import { RecurringDonationResolver } from './recurringDonationResolver'; -import { DraftDonationResolver } from './draftDonationResolver'; -import { OnboardingFormResolver } from './onboardingFormResolver'; +import { UserResolver } from './userResolver.js'; +import { ProjectResolver } from './projectResolver.js'; +import { MeResolver } from '../user/MeResolver.js'; +import { UploadResolver } from './uploadResolver.js'; +import { CategoryResolver } from './categoryResolver.js'; +import { DonationResolver } from './donationResolver.js'; +import { ReactionResolver } from './reactionResolver.js'; +import { StatusReasonResolver } from './statusReasonResolver.js'; +import { ProjectVerificationFormResolver } from './projectVerificationFormResolver.js'; +import { SocialProfilesResolver } from './socialProfilesResolver.js'; +import { PowerBoostingResolver } from './powerBoostingResolver.js'; +import { UserProjectPowerResolver } from './userProjectPowerResolver.js'; +import { GivPowerTestingResolver } from './givPowerTestingResolver.js'; +import { ProjectPowerResolver } from './projectPowerResolver.js'; +import { CampaignResolver } from './campaignResolver.js'; +import { ChainvineResolver } from './chainvineResolver.js'; +import { QfRoundResolver } from './qfRoundResolver.js'; +import { QfRoundHistoryResolver } from './qfRoundHistoryResolver.js'; +import { ProjectUserInstantPowerViewResolver } from './instantPowerResolver.js'; +import { AnchorContractAddressResolver } from './anchorContractAddressResolver.js'; +import { RecurringDonationResolver } from './recurringDonationResolver.js'; +import { DraftDonationResolver } from './draftDonationResolver.js'; +import { OnboardingFormResolver } from './onboardingFormResolver.js'; // eslint-disable-next-line @typescript-eslint/ban-types export const getResolvers = (): Function[] => { diff --git a/src/resolvers/socialProfilesResolver.test.ts b/src/resolvers/socialProfilesResolver.test.ts index 0afe05808..19595b848 100644 --- a/src/resolvers/socialProfilesResolver.test.ts +++ b/src/resolvers/socialProfilesResolver.test.ts @@ -9,15 +9,15 @@ import { saveProjectVerificationFormDirectlyToDb, saveUserDirectlyToDb, SEED_DATA, -} from '../../test/testUtils'; +} from '../../test/testUtils.js'; import { addNewSocialProfileMutation, removeSocialProfileMutation, -} from '../../test/graphqlQueries'; -import { SOCIAL_NETWORKS } from '../entities/socialProfile'; -import { errorMessages } from '../utils/errorMessages'; -import { PROJECT_VERIFICATION_STATUSES } from '../entities/projectVerificationForm'; -import { createSocialProfile } from '../repositories/socialProfileRepository'; +} from '../../test/graphqlQueries.js'; +import { SOCIAL_NETWORKS } from '../entities/socialProfile.js'; +import { errorMessages } from '../utils/errorMessages.js'; +import { PROJECT_VERIFICATION_STATUSES } from '../entities/projectVerificationForm.js'; +import { createSocialProfile } from '../repositories/socialProfileRepository.js'; describe( 'addNewSocialProfile test cases', diff --git a/src/resolvers/socialProfilesResolver.ts b/src/resolvers/socialProfilesResolver.ts index 38e0eb9cf..54beefba7 100644 --- a/src/resolvers/socialProfilesResolver.ts +++ b/src/resolvers/socialProfilesResolver.ts @@ -1,15 +1,15 @@ import { Arg, Ctx, Int, Mutation, Resolver } from 'type-graphql'; -import { SocialProfile } from '../entities/socialProfile'; -import { ApolloContext } from '../types/ApolloContext'; -import { i18n, translationErrorMessagesKeys } from '../utils/errorMessages'; -import { findProjectVerificationFormById } from '../repositories/projectVerificationRepository'; +import { SocialProfile } from '../entities/socialProfile.js'; +import { ApolloContext } from '../types/ApolloContext.js'; +import { i18n, translationErrorMessagesKeys } from '../utils/errorMessages.js'; +import { findProjectVerificationFormById } from '../repositories/projectVerificationRepository.js'; import { findSocialProfileById, removeSocialProfileById, -} from '../repositories/socialProfileRepository'; -import { getSocialNetworkAdapter } from '../adapters/adaptersFactory'; -import { PROJECT_VERIFICATION_STATUSES } from '../entities/projectVerificationForm'; -import { setOauth2SocialProfileInRedis } from '../services/socialProfileService'; +} from '../repositories/socialProfileRepository.js'; +import { getSocialNetworkAdapter } from '../adapters/adaptersFactory.js'; +import { PROJECT_VERIFICATION_STATUSES } from '../entities/projectVerificationForm.js'; +import { setOauth2SocialProfileInRedis } from '../services/socialProfileService.js'; @Resolver(_of => SocialProfile) export class SocialProfilesResolver { diff --git a/src/resolvers/statusReasonResolver.test.ts b/src/resolvers/statusReasonResolver.test.ts index b611a5b5a..70e24c565 100644 --- a/src/resolvers/statusReasonResolver.test.ts +++ b/src/resolvers/statusReasonResolver.test.ts @@ -1,10 +1,10 @@ import { assert } from 'chai'; import axios from 'axios'; -import { graphqlUrl } from '../../test/testUtils'; -import { projectStatusReasonsQuery } from '../../test/graphqlQueries'; -import { ProjStatus } from '../entities/project'; -import { ProjectStatusReason } from '../entities/projectStatusReason'; -import { ProjectStatus } from '../entities/projectStatus'; +import { graphqlUrl } from '../../test/testUtils.js'; +import { projectStatusReasonsQuery } from '../../test/graphqlQueries.js'; +import { ProjStatus } from '../entities/project.js'; +import { ProjectStatusReason } from '../entities/projectStatusReason.js'; +import { ProjectStatus } from '../entities/projectStatus.js'; describe('getStatusReasons() test cases', getStatusReasonsTestCases); function getStatusReasonsTestCases() { diff --git a/src/resolvers/statusReasonResolver.ts b/src/resolvers/statusReasonResolver.ts index 596fb88cd..8275e3f68 100644 --- a/src/resolvers/statusReasonResolver.ts +++ b/src/resolvers/statusReasonResolver.ts @@ -1,10 +1,10 @@ import { Arg, Query, Resolver } from 'type-graphql'; -import { ProjectStatusReason } from '../entities/projectStatusReason'; +import { ProjectStatusReason } from '../entities/projectStatusReason.js'; import { findAllStatusReasons, findStatusReasonsByStatusId, -} from '../repositories/statusReasonRepository'; -import { logger } from '../utils/logger'; +} from '../repositories/statusReasonRepository.js'; +import { logger } from '../utils/logger.js'; @Resolver(_of => ProjectStatusReason) export class StatusReasonResolver { diff --git a/src/resolvers/types/ProjectVerificationUpdateInput.ts b/src/resolvers/types/ProjectVerificationUpdateInput.ts index b02ece474..9e658f8c7 100644 --- a/src/resolvers/types/ProjectVerificationUpdateInput.ts +++ b/src/resolvers/types/ProjectVerificationUpdateInput.ts @@ -1,6 +1,6 @@ import { Field, InputType } from 'type-graphql'; -import { ChainType } from '../../types/network'; -import { ProjectSocialMediaType } from '../../types/projectSocialMediaType'; +import { ChainType } from '../../types/network.js'; +import { ProjectSocialMediaType } from '../../types/projectSocialMediaType.js'; @InputType() class ProjectPersonalInfoInputType { diff --git a/src/resolvers/types/project-input.ts b/src/resolvers/types/project-input.ts index 251405c37..cc45e03d5 100644 --- a/src/resolvers/types/project-input.ts +++ b/src/resolvers/types/project-input.ts @@ -5,15 +5,15 @@ import { MaxLength } from 'class-validator'; import { ProjectSocialMediaInput, RelatedAddressInputType, -} from './ProjectVerificationUpdateInput'; +} from './ProjectVerificationUpdateInput.js'; import { IMAGE_LINK_MAX_SIZE, IMPACT_LOCATION_MAX_SIZE, PROJECT_DESCRIPTION_MAX_LENGTH, PROJECT_TITLE_MAX_LENGTH, -} from '../../constants/validators'; -import { errorMessages } from '../../utils/errorMessages'; +} from '../../constants/validators.js'; +import { errorMessages } from '../../utils/errorMessages.js'; @InputType() export class ImageUpload { diff --git a/src/resolvers/types/projectResolver.ts b/src/resolvers/types/projectResolver.ts index adae01ef2..214243a92 100644 --- a/src/resolvers/types/projectResolver.ts +++ b/src/resolvers/types/projectResolver.ts @@ -1,5 +1,5 @@ import { Field, ObjectType } from 'type-graphql'; -import { Project } from '../../entities/project'; +import { Project } from '../../entities/project.js'; @ObjectType() export class ProjectBySlugResponse extends Project { diff --git a/src/resolvers/types/userResolver.ts b/src/resolvers/types/userResolver.ts index 94a9c5761..3c3264651 100644 --- a/src/resolvers/types/userResolver.ts +++ b/src/resolvers/types/userResolver.ts @@ -1,5 +1,5 @@ import { Field, ObjectType } from 'type-graphql'; -import { User } from '../../entities/user'; +import { User } from '../../entities/user.js'; @ObjectType() export class UserByAddressResponse extends User { diff --git a/src/resolvers/uploadResolver.test.ts b/src/resolvers/uploadResolver.test.ts index 0ec08e446..03cca19d2 100644 --- a/src/resolvers/uploadResolver.test.ts +++ b/src/resolvers/uploadResolver.test.ts @@ -1,23 +1,21 @@ import { createReadStream, readFileSync } from 'fs'; +import path from 'path'; import { assert } from 'chai'; import sinon from 'sinon'; import axios from 'axios'; +import FormData from 'form-data'; import { traceImageUploadQuery, uploadImageToIpfsQuery, -} from '../../test/graphqlQueries'; +} from '../../test/graphqlQueries.js'; import { generateTestAccessToken, graphqlUrl, SEED_DATA, -} from '../../test/testUtils'; -import * as pinataUtils from '../middleware/pinataUtils'; -import { errorMessages } from '../utils/errorMessages'; -import { TraceImageOwnerType } from './uploadResolver'; -// eslint-disable-next-line @typescript-eslint/no-var-requires -const path = require('path'); -// eslint-disable-next-line @typescript-eslint/no-var-requires -const FormData = require('form-data'); +} from '../../test/testUtils.js'; +import * as pinataUtils from '../middleware/pinataUtils.js'; +import { errorMessages } from '../utils/errorMessages.js'; +import { TraceImageOwnerType } from './uploadResolver.js'; // test cases describe('upload() test cases', uploadTestCases); @@ -27,6 +25,8 @@ function uploadTestCases() { const IpfsHash = 'MockIpfsHash'; before(() => { sinon.stub(pinataUtils, 'pinFile').resolves({ + PinSize: 0, + Timestamp: '', IpfsHash, }); }); @@ -107,6 +107,8 @@ function traceImageUpload() { sinon.stub(pinataUtils, 'pinFileDataBase64').returns( Promise.resolve({ IpfsHash, + PinSize: 0, + Timestamp: '', }), ); }); diff --git a/src/resolvers/uploadResolver.ts b/src/resolvers/uploadResolver.ts index ffeca236a..6ba1a66bb 100644 --- a/src/resolvers/uploadResolver.ts +++ b/src/resolvers/uploadResolver.ts @@ -9,12 +9,12 @@ import { } from 'type-graphql'; import GraphQLUpload from 'graphql-upload/GraphQLUpload.js'; import { FileUpload } from 'graphql-upload/Upload.js'; -import { ApolloContext } from '../types/ApolloContext'; -import { pinFile, pinFileDataBase64 } from '../middleware/pinataUtils'; -import { logger } from '../utils/logger'; -import { getLoggedInUser } from '../services/authorizationServices'; -import { i18n, translationErrorMessagesKeys } from '../utils/errorMessages'; -import SentryLogger from '../sentryLogger'; +import { ApolloContext } from '../types/ApolloContext.js'; +import { pinFile, pinFileDataBase64 } from '../middleware/pinataUtils.js'; +import { logger } from '../utils/logger.js'; +import { getLoggedInUser } from '../services/authorizationServices.js'; +import { i18n, translationErrorMessagesKeys } from '../utils/errorMessages.js'; +import SentryLogger from '../sentryLogger.js'; @InputType() export class FileUploadInputType { diff --git a/src/resolvers/userProjectPowerResolver.test.ts b/src/resolvers/userProjectPowerResolver.test.ts index 5f4f7c403..6238ba157 100644 --- a/src/resolvers/userProjectPowerResolver.test.ts +++ b/src/resolvers/userProjectPowerResolver.test.ts @@ -6,20 +6,20 @@ import { graphqlUrl, saveProjectDirectlyToDb, saveUserDirectlyToDb, -} from '../../test/testUtils'; -import { getUserProjectPowerQuery } from '../../test/graphqlQueries'; -import { errorMessages } from '../utils/errorMessages'; -import { setPowerRound } from '../repositories/powerRoundRepository'; -import { refreshUserProjectPowerView } from '../repositories/userProjectPowerViewRepository'; +} from '../../test/testUtils.js'; +import { getUserProjectPowerQuery } from '../../test/graphqlQueries.js'; +import { errorMessages } from '../utils/errorMessages.js'; +import { setPowerRound } from '../repositories/powerRoundRepository.js'; +import { refreshUserProjectPowerView } from '../repositories/userProjectPowerViewRepository.js'; import { insertSinglePowerBoosting, takePowerBoostingSnapshot, -} from '../repositories/powerBoostingRepository'; -import { PowerBalanceSnapshot } from '../entities/powerBalanceSnapshot'; -import { PowerBoostingSnapshot } from '../entities/powerBoostingSnapshot'; -import { AppDataSource } from '../orm'; -import { addOrUpdatePowerSnapshotBalances } from '../repositories/powerBalanceSnapshotRepository'; -import { findPowerSnapshots } from '../repositories/powerSnapshotRepository'; +} from '../repositories/powerBoostingRepository.js'; +import { PowerBalanceSnapshot } from '../entities/powerBalanceSnapshot.js'; +import { PowerBoostingSnapshot } from '../entities/powerBoostingSnapshot.js'; +import { AppDataSource } from '../orm.js'; +import { addOrUpdatePowerSnapshotBalances } from '../repositories/powerBalanceSnapshotRepository.js'; +import { findPowerSnapshots } from '../repositories/powerSnapshotRepository.js'; describe('userProjectPowers test cases', userProjectPowersTestCases); diff --git a/src/resolvers/userProjectPowerResolver.ts b/src/resolvers/userProjectPowerResolver.ts index 9d66d426f..414a6c43a 100644 --- a/src/resolvers/userProjectPowerResolver.ts +++ b/src/resolvers/userProjectPowerResolver.ts @@ -11,10 +11,10 @@ import { } from 'type-graphql'; import { Max, Min } from 'class-validator'; import { Service } from 'typedi'; -import { i18n, translationErrorMessagesKeys } from '../utils/errorMessages'; -import { PowerBoosting } from '../entities/powerBoosting'; -import { UserProjectPowerView } from '../views/userProjectPowerView'; -import { getUserProjectPowers } from '../repositories/userProjectPowerViewRepository'; +import { i18n, translationErrorMessagesKeys } from '../utils/errorMessages.js'; +import { PowerBoosting } from '../entities/powerBoosting.js'; +import { UserProjectPowerView } from '../views/userProjectPowerView.js'; +import { getUserProjectPowers } from '../repositories/userProjectPowerViewRepository.js'; export enum UserPowerOrderDirection { ASC = 'ASC', diff --git a/src/resolvers/userResolver.test.ts b/src/resolvers/userResolver.test.ts index d996747f9..ce654725e 100644 --- a/src/resolvers/userResolver.test.ts +++ b/src/resolvers/userResolver.test.ts @@ -2,7 +2,7 @@ import axios from 'axios'; import { assert } from 'chai'; -import { User } from '../entities/user'; +import { User } from '../entities/user.js'; import { createDonationData, createProjectData, @@ -15,20 +15,20 @@ import { saveRecurringDonationDirectlyToDb, saveUserDirectlyToDb, SEED_DATA, -} from '../../test/testUtils'; +} from '../../test/testUtils.js'; import { refreshUserScores, updateUser, userByAddress, -} from '../../test/graphqlQueries'; -import { errorMessages } from '../utils/errorMessages'; -import { insertSinglePowerBoosting } from '../repositories/powerBoostingRepository'; -import { DONATION_STATUS } from '../entities/donation'; -import { getGitcoinAdapter } from '../adapters/adaptersFactory'; -import { updateUserTotalDonated } from '../services/userService'; -import { addNewAnchorAddress } from '../repositories/anchorContractAddressRepository'; -import { NETWORK_IDS } from '../provider'; -import { RECURRING_DONATION_STATUS } from '../entities/recurringDonation'; +} from '../../test/graphqlQueries.js'; +import { errorMessages } from '../utils/errorMessages.js'; +import { insertSinglePowerBoosting } from '../repositories/powerBoostingRepository.js'; +import { DONATION_STATUS } from '../entities/donation.js'; +import { getGitcoinAdapter } from '../adapters/adaptersFactory.js'; +import { updateUserTotalDonated } from '../services/userService.js'; +import { addNewAnchorAddress } from '../repositories/anchorContractAddressRepository.js'; +import { NETWORK_IDS } from '../provider.js'; +import { RECURRING_DONATION_STATUS } from '../entities/recurringDonation.js'; describe('updateUser() test cases', updateUserTestCases); describe('userByAddress() test cases', userByAddressTestCases); diff --git a/src/resolvers/userResolver.ts b/src/resolvers/userResolver.ts index 487f9ac28..cc1479c1b 100644 --- a/src/resolvers/userResolver.ts +++ b/src/resolvers/userResolver.ts @@ -9,27 +9,27 @@ import { } from 'type-graphql'; import { Repository } from 'typeorm'; -import { User } from '../entities/user'; -import { AccountVerificationInput } from './types/accountVerificationInput'; -import { ApolloContext } from '../types/ApolloContext'; -import { i18n, translationErrorMessagesKeys } from '../utils/errorMessages'; -import { validateEmail } from '../utils/validators/commonValidators'; +import { User } from '../entities/user.js'; +import { AccountVerificationInput } from './types/accountVerificationInput.js'; +import { ApolloContext } from '../types/ApolloContext.js'; +import { i18n, translationErrorMessagesKeys } from '../utils/errorMessages.js'; +import { validateEmail } from '../utils/validators/commonValidators.js'; import { findUserById, findUserByWalletAddress, -} from '../repositories/userRepository'; -import { createNewAccountVerification } from '../repositories/accountVerificationRepository'; -import { UserByAddressResponse } from './types/userResolver'; -import { AppDataSource } from '../orm'; +} from '../repositories/userRepository.js'; +import { createNewAccountVerification } from '../repositories/accountVerificationRepository.js'; +import { UserByAddressResponse } from './types/userResolver.js'; +import { AppDataSource } from '../orm.js'; import { getGitcoinAdapter, getNotificationAdapter, -} from '../adapters/adaptersFactory'; -import { logger } from '../utils/logger'; -import { isWalletAddressInPurpleList } from '../repositories/projectAddressRepository'; -import { addressHasDonated } from '../repositories/donationRepository'; -import { getOrttoPersonAttributes } from '../adapters/notifications/NotificationCenterAdapter'; -import { retrieveActiveQfRoundUserMBDScore } from '../repositories/qfRoundRepository'; +} from '../adapters/adaptersFactory.js'; +import { logger } from '../utils/logger.js'; +import { isWalletAddressInPurpleList } from '../repositories/projectAddressRepository.js'; +import { addressHasDonated } from '../repositories/donationRepository.js'; +import { getOrttoPersonAttributes } from '../adapters/notifications/NotificationCenterAdapter.js'; +import { retrieveActiveQfRoundUserMBDScore } from '../repositories/qfRoundRepository.js'; @ObjectType() class UserRelatedAddressResponse { @@ -42,6 +42,7 @@ class UserRelatedAddressResponse { @Resolver(_of => User) export class UserResolver { + // @ts-expect-error as d constructor(private readonly userRepository: Repository) { this.userRepository = AppDataSource.getDataSource().getRepository(User); } diff --git a/src/routers/apiGivRoutes.test.ts b/src/routers/apiGivRoutes.test.ts index 380fbe677..9ab682cee 100644 --- a/src/routers/apiGivRoutes.test.ts +++ b/src/routers/apiGivRoutes.test.ts @@ -5,10 +5,10 @@ import { generateRandomEtheriumAddress, generateRandomEvmTxHash, saveProjectDirectlyToDb, -} from '../../test/testUtils'; -import { createBasicAuthentication } from '../utils/utils'; -import { NETWORK_IDS } from '../provider'; -import { DONATION_STATUS } from '../entities/donation'; +} from '../../test/testUtils.js'; +import { createBasicAuthentication } from '../utils/utils.js'; +import { NETWORK_IDS } from '../provider.js'; +import { DONATION_STATUS } from '../entities/donation.js'; export const restUrl = 'http://localhost:4000/apigive'; diff --git a/src/routers/apiGivRoutes.ts b/src/routers/apiGivRoutes.ts index b05cbdc16..a927de926 100644 --- a/src/routers/apiGivRoutes.ts +++ b/src/routers/apiGivRoutes.ts @@ -1,21 +1,21 @@ import express, { Request, Response } from 'express'; -import { apiGivAuthentication } from '../middleware/apiGivAuthentication'; -import { findDonationsByTransactionId } from '../repositories/donationRepository'; -import { i18n, translationErrorMessagesKeys } from '../utils/errorMessages'; -import { Donation } from '../entities/donation'; -import { findProjectByWalletAddress } from '../repositories/projectRepository'; -import { findTokenByTokenAddress } from '../repositories/tokenRepository'; -import { ProjStatus } from '../entities/project'; -import { logger } from '../utils/logger'; -import { findTokenByNetworkAndSymbol } from '../utils/tokenUtils'; -import { ApiGivStandardError, handleExpressError } from './standardError'; -import { findUserByWalletAddress } from '../repositories/userRepository'; -import { User } from '../entities/user'; -import { updateProjectStatistics } from '../services/projectService'; +import { apiGivAuthentication } from '../middleware/apiGivAuthentication.js'; +import { findDonationsByTransactionId } from '../repositories/donationRepository.js'; +import { i18n, translationErrorMessagesKeys } from '../utils/errorMessages.js'; +import { Donation } from '../entities/donation.js'; +import { findProjectByWalletAddress } from '../repositories/projectRepository.js'; +import { findTokenByTokenAddress } from '../repositories/tokenRepository.js'; +import { ProjStatus } from '../entities/project.js'; +import { logger } from '../utils/logger.js'; +import { findTokenByNetworkAndSymbol } from '../utils/tokenUtils.js'; +import { ApiGivStandardError, handleExpressError } from './standardError.js'; +import { findUserByWalletAddress } from '../repositories/userRepository.js'; +import { User } from '../entities/user.js'; +import { updateProjectStatistics } from '../services/projectService.js'; import { updateUserTotalDonated, updateUserTotalReceived, -} from '../services/userService'; +} from '../services/userService.js'; export const apiGivRouter = express.Router(); apiGivRouter.post( diff --git a/src/routers/oauth2Callbacks.ts b/src/routers/oauth2Callbacks.ts index 2f64b8a43..1cb52d885 100644 --- a/src/routers/oauth2Callbacks.ts +++ b/src/routers/oauth2Callbacks.ts @@ -1,11 +1,11 @@ import express, { Request, Response } from 'express'; -import { logger } from '../utils/logger'; -import { SOCIAL_NETWORKS } from '../entities/socialProfile'; +import { logger } from '../utils/logger.js'; +import { SOCIAL_NETWORKS } from '../entities/socialProfile.js'; import { getProjectVerificationFormByState, oauth2CallbackHandler, -} from '../services/socialProfileService'; -import { findProjectVerificationFormById } from '../repositories/projectVerificationRepository'; +} from '../services/socialProfileService.js'; +import { findProjectVerificationFormById } from '../repositories/projectVerificationRepository.js'; export const oauth2CallbacksRouter = express.Router(); diff --git a/src/seedToken-ormconfig.ts b/src/seedToken-ormconfig.ts index ababf853f..e44ad9252 100644 --- a/src/seedToken-ormconfig.ts +++ b/src/seedToken-ormconfig.ts @@ -2,7 +2,7 @@ import * as path from 'path'; import * as dotenv from 'dotenv'; import { DataSourceOptions } from 'typeorm'; -import { getEntities } from './entities/entities'; +import { getEntities } from './entities/entities.js'; dotenv.config({ path: path.resolve(__dirname, `./config/${process.env.NODE_ENV || ''}.env`), }); @@ -21,4 +21,4 @@ const ormConfig: DataSourceOptions = { // }, }; -export = ormConfig; +export default ormConfig; diff --git a/src/sentryLogger.ts b/src/sentryLogger.ts index 14f1ebb38..91efa36d3 100644 --- a/src/sentryLogger.ts +++ b/src/sentryLogger.ts @@ -1,5 +1,5 @@ import * as Sentry from '@sentry/node'; -import config from './config'; +import config from './config.js'; const sentryId = config.get('SENTRY_ID').toString(); const sentryToken = config.get('SENTRY_TOKEN').toString(); diff --git a/src/server/adminJs/adminJs-types.ts b/src/server/adminJs/adminJs-types.ts index 4a13ece68..00c8d52a6 100644 --- a/src/server/adminJs/adminJs-types.ts +++ b/src/server/adminJs/adminJs-types.ts @@ -1,5 +1,5 @@ -import { User } from '../../entities/user'; -import { ReviewStatus } from '../../entities/project'; +import { User } from '../../entities/user.js'; +import { ReviewStatus } from '../../entities/project.js'; export interface AdminJsContextInterface { h: any; diff --git a/src/server/adminJs/adminJs.ts b/src/server/adminJs/adminJs.ts index 17e45c5f0..9ccbc992a 100644 --- a/src/server/adminJs/adminJs.ts +++ b/src/server/adminJs/adminJs.ts @@ -2,48 +2,48 @@ import adminJs, { ActionContext, AdminJSOptions } from 'adminjs'; import adminJsExpress from '@adminjs/express'; import { Database, Resource } from '@adminjs/typeorm'; import { IncomingMessage } from 'connect'; -import { User } from '../../entities/user'; -import config from '../../config'; -import { redis } from '../../redis'; -import { logger } from '../../utils/logger'; -import { findUserById } from '../../repositories/userRepository'; -import { fetchAdminAndValidatePassword } from '../../services/userService'; -import { campaignsTab } from './tabs/campaignsTab'; -import { broadcastNotificationTab } from './tabs/broadcastNotificationTab'; -import { mainCategoryTab } from './tabs/mainCategoryTab'; -import { categoryTab } from './tabs/categoryTab'; -import { projectsTab } from './tabs/projectsTab'; -import { organizationsTab } from './tabs/organizationsTab'; -import { usersTab } from './tabs/usersTab'; -import { projectStatusHistoryTab } from './tabs/projectStatusHistoryTab'; -import { projectStatusReasonTab } from './tabs/projectStatusReasonTab'; -import { projectAddressTab } from './tabs/projectAddressTab'; -import { projectStatusTab } from './tabs/projectStatusTab'; -import { projectUpdateTab } from './tabs/projectUpdateTab'; -import { thirdPartProjectImportTab } from './tabs/thirdPartProjectImportTab'; -import { featuredUpdateTab } from './tabs/featuredUpdateTab'; -import { generateTokenTab } from './tabs/tokenTab'; -import { donationTab } from './tabs/donationTab'; -import { projectVerificationTab } from './tabs/projectVerificationTab'; -import { qfRoundTab } from './tabs/qfRoundTab'; -import { qfRoundHistoryTab } from './tabs/qfRoundHistoryTab'; -import { SybilTab } from './tabs/sybilTab'; -import { ProjectFraudTab } from './tabs/projectFraudTab'; -import { RecurringDonationTab } from './tabs/recurringDonationTab'; -import { AnchorContractAddressTab } from './tabs/anchorContractAddressTab'; -// use redis for session data instead of in-memory storage -// eslint-disable-next-line @typescript-eslint/no-var-requires -const RedisStore = require('connect-redis').default; - -// eslint-disable-next-line @typescript-eslint/no-var-requires -const cookie = require('cookie'); -// eslint-disable-next-line @typescript-eslint/no-var-requires -const cookieParser = require('cookie-parser'); +import cookie from 'cookie'; +import cookieParser from 'cookie-parser'; +import session from 'express-session'; +import { User } from '../../entities/user.js'; +import config from '../../config.js'; +import { redis } from '../../redis.js'; +import { logger } from '../../utils/logger.js'; +import { findUserById } from '../../repositories/userRepository.js'; +import { fetchAdminAndValidatePassword } from '../../services/userService.js'; +import { campaignsTab } from './tabs/campaignsTab.js'; +import { broadcastNotificationTab } from './tabs/broadcastNotificationTab.js'; +import { mainCategoryTab } from './tabs/mainCategoryTab.js'; +import { categoryTab } from './tabs/categoryTab.js'; +import { projectsTab } from './tabs/projectsTab.js'; +import { organizationsTab } from './tabs/organizationsTab.js'; +import { usersTab } from './tabs/usersTab.js'; +import { projectStatusHistoryTab } from './tabs/projectStatusHistoryTab.js'; +import { projectStatusReasonTab } from './tabs/projectStatusReasonTab.js'; +import { projectAddressTab } from './tabs/projectAddressTab.js'; +import { projectStatusTab } from './tabs/projectStatusTab.js'; +import { projectUpdateTab } from './tabs/projectUpdateTab.js'; +import { thirdPartProjectImportTab } from './tabs/thirdPartProjectImportTab.js'; +import { featuredUpdateTab } from './tabs/featuredUpdateTab.js'; +import { generateTokenTab } from './tabs/tokenTab.js'; +import { donationTab } from './tabs/donationTab.js'; +import { projectVerificationTab } from './tabs/projectVerificationTab.js'; +import { qfRoundTab } from './tabs/qfRoundTab.js'; +import { qfRoundHistoryTab } from './tabs/qfRoundHistoryTab.js'; +import { SybilTab } from './tabs/sybilTab.js'; +import { ProjectFraudTab } from './tabs/projectFraudTab.js'; +import { RecurringDonationTab } from './tabs/recurringDonationTab.js'; +import { AnchorContractAddressTab } from './tabs/anchorContractAddressTab.js'; + const secret = config.get('ADMIN_BRO_COOKIE_SECRET') as string; const adminJsCookie = 'adminjs'; +// @ts-expect-error as d adminJs.registerAdapter({ Database, Resource }); export const getAdminJsRouter = async () => { + const RedisStoreModule = await import('connect-redis'); + const RedisStore = RedisStoreModule.default(session); + // @ts-expect-error as d return adminJsExpress.buildAuthenticatedRouter( await getadminJsInstance(), { @@ -94,6 +94,8 @@ export const extractAdminJsReferrerUrlParams = (req: ActionContext) => { // Get CurrentSession for external express middlewares export const getCurrentAdminJsSession = async (request: IncomingMessage) => { + const RedisStoreModule = await import('connect-redis'); + const RedisStore = RedisStoreModule.default(session); const cookieHeader = request.headers.cookie; const parsedCookies = cookie.parse(cookieHeader); const sessionStore = new RedisStore({ client: redis }); @@ -109,7 +111,8 @@ export const getCurrentAdminJsSession = async (request: IncomingMessage) => { if (err) { failure(err); } else { - success(sessionObject.adminUser); + // @ts-expect-error adminUser is defined + success(sessionObject?.adminUser); } }); }); @@ -199,6 +202,7 @@ const getResources = async (): Promise => { const getadminJsInstance = async () => { const resources = await getResources(); + // @ts-expect-error as d const adminJsInstance = new adminJs({ branding: { logo: 'https://i.imgur.com/cGKo1Tk.png', diff --git a/src/server/adminJs/adminJsPermissions.test.ts b/src/server/adminJs/adminJsPermissions.test.ts index 32a85072e..781a7d458 100644 --- a/src/server/adminJs/adminJsPermissions.test.ts +++ b/src/server/adminJs/adminJsPermissions.test.ts @@ -21,8 +21,8 @@ import { canAccessCampaignAction, canAccessSybilAction, canAccessProjectFraudAction, -} from './adminJsPermissions'; -import { UserRole } from '../../entities/user'; +} from './adminJsPermissions.js'; +import { UserRole } from '../../entities/user.js'; const roles = Object.freeze([ UserRole.ADMIN, diff --git a/src/server/adminJs/adminJsPermissions.ts b/src/server/adminJs/adminJsPermissions.ts index 334f3680f..05aab2a01 100644 --- a/src/server/adminJs/adminJsPermissions.ts +++ b/src/server/adminJs/adminJsPermissions.ts @@ -1,4 +1,4 @@ -import { UserRole } from '../../entities/user'; +import { UserRole } from '../../entities/user.js'; // Current Actions Enum export enum ResourceActions { diff --git a/src/server/adminJs/tabs/anchorContractAddressTab.ts b/src/server/adminJs/tabs/anchorContractAddressTab.ts index a4eff9f4e..2d352dfdb 100644 --- a/src/server/adminJs/tabs/anchorContractAddressTab.ts +++ b/src/server/adminJs/tabs/anchorContractAddressTab.ts @@ -1,4 +1,4 @@ -import { AnchorContractAddress } from '../../../entities/anchorContractAddress'; +import { AnchorContractAddress } from '../../../entities/anchorContractAddress.js'; export const AnchorContractAddressTab = { resource: AnchorContractAddress, diff --git a/src/server/adminJs/tabs/broadcastNorificationTab.test.ts b/src/server/adminJs/tabs/broadcastNorificationTab.tes.ts similarity index 89% rename from src/server/adminJs/tabs/broadcastNorificationTab.test.ts rename to src/server/adminJs/tabs/broadcastNorificationTab.tes.ts index 109915378..308043ef9 100644 --- a/src/server/adminJs/tabs/broadcastNorificationTab.test.ts +++ b/src/server/adminJs/tabs/broadcastNorificationTab.tes.ts @@ -1,9 +1,9 @@ import { assert } from 'chai'; import BroadcastNotification, { BROAD_CAST_NOTIFICATION_STATUS, -} from '../../../entities/broadcastNotification'; -import { findBroadcastNotificationById } from '../../../repositories/broadcastNotificationRepository'; -import { sendBroadcastNotification } from './broadcastNotificationTab'; +} from '../../../entities/broadcastNotification.js'; +import { findBroadcastNotificationById } from '../../../repositories/broadcastNotificationRepository.js'; +import { sendBroadcastNotification } from './broadcastNotificationTab.js'; describe( 'sendBroadcastNotification() test cases', diff --git a/src/server/adminJs/tabs/broadcastNotificationTab.ts b/src/server/adminJs/tabs/broadcastNotificationTab.ts index 3b2177a58..59d805388 100644 --- a/src/server/adminJs/tabs/broadcastNotificationTab.ts +++ b/src/server/adminJs/tabs/broadcastNotificationTab.ts @@ -2,22 +2,24 @@ import adminJs from 'adminjs'; import { ActionResponse, After, + // @ts-expect-error as d } from 'adminjs/src/backend/actions/action.interface'; +// @ts-expect-error as d import { RecordJSON } from 'adminjs/src/frontend/interfaces/record-json.interface'; import BroadcastNotification, { BROAD_CAST_NOTIFICATION_STATUS, -} from '../../../entities/broadcastNotification'; +} from '../../../entities/broadcastNotification.js'; import { canAccessBroadcastNotificationAction, ResourceActions, -} from '../adminJsPermissions'; +} from '../adminJsPermissions.js'; import { AdminJsContextInterface, AdminJsRequestInterface, -} from '../adminJs-types'; -import { getNotificationAdapter } from '../../../adapters/adaptersFactory'; -import { updateBroadcastNotificationStatus } from '../../../repositories/broadcastNotificationRepository'; -import { logger } from '../../../utils/logger'; +} from '../adminJs-types.js'; +import { getNotificationAdapter } from '../../../adapters/adaptersFactory.js'; +import { updateBroadcastNotificationStatus } from '../../../repositories/broadcastNotificationRepository.js'; +import { logger } from '../../../utils/logger.js'; export const sendBroadcastNotification = async ( response, @@ -119,6 +121,7 @@ export const broadcastNotificationTab = { edit: true, }, components: { + // @ts-expect-error as d edit: adminJs.bundle('./components/MDtoHTML'), }, }, diff --git a/src/server/adminJs/tabs/campaignsTab.ts b/src/server/adminJs/tabs/campaignsTab.ts index 4e25c8ede..ddf314743 100644 --- a/src/server/adminJs/tabs/campaignsTab.ts +++ b/src/server/adminJs/tabs/campaignsTab.ts @@ -1,8 +1,8 @@ -import { Campaign } from '../../../entities/campaign'; +import { Campaign } from '../../../entities/campaign.js'; import { canAccessCampaignAction, ResourceActions, -} from '../adminJsPermissions'; +} from '../adminJsPermissions.js'; export const campaignsTab = { resource: Campaign, diff --git a/src/server/adminJs/tabs/categoryTab.ts b/src/server/adminJs/tabs/categoryTab.ts index 39cf01341..aead13e76 100644 --- a/src/server/adminJs/tabs/categoryTab.ts +++ b/src/server/adminJs/tabs/categoryTab.ts @@ -1,8 +1,8 @@ -import { Category } from '../../../entities/category'; +import { Category } from '../../../entities/category.js'; import { canAccessCategoryAction, ResourceActions, -} from '../adminJsPermissions'; +} from '../adminJsPermissions.js'; export const categoryTab = { resource: Category, diff --git a/src/server/adminJs/tabs/donationTab.test.ts b/src/server/adminJs/tabs/donationTab.test.ts index 7d1980822..d6433e37d 100644 --- a/src/server/adminJs/tabs/donationTab.test.ts +++ b/src/server/adminJs/tabs/donationTab.test.ts @@ -4,19 +4,19 @@ import { generateRandomEtheriumAddress, saveProjectDirectlyToDb, saveUserDirectlyToDb, -} from '../../../../test/testUtils'; -import { NETWORK_IDS } from '../../../provider'; +} from '../../../../test/testUtils.js'; +import { NETWORK_IDS } from '../../../provider.js'; import { Donation, DONATION_STATUS, DONATION_TYPES, -} from '../../../entities/donation'; +} from '../../../entities/donation.js'; import { createDonation, FillPricesForDonationsWithoutPrice, -} from './donationTab'; -import { User } from '../../../entities/user'; -import { Project } from '../../../entities/project'; +} from './donationTab.js'; +import { User } from '../../../entities/user.js'; +import { Project } from '../../../entities/project.js'; describe('createDonation() test cases', createDonationTestCases); describe('updateDonationPrice() test cases', updateDonationPriceTestCases); diff --git a/src/server/adminJs/tabs/donationTab.ts b/src/server/adminJs/tabs/donationTab.ts index a2eb3779d..f2fc9c354 100644 --- a/src/server/adminJs/tabs/donationTab.ts +++ b/src/server/adminJs/tabs/donationTab.ts @@ -5,50 +5,45 @@ import { Donation, DONATION_STATUS, DONATION_TYPES, -} from '../../../entities/donation'; +} from '../../../entities/donation.js'; import { canAccessDonationAction, canAccessQfRoundHistoryAction, ResourceActions, -} from '../adminJsPermissions'; +} from '../adminJsPermissions.js'; import { AdminJsContextInterface, AdminJsRequestInterface, AdminJsDonationsQuery, - donationHeaders, -} from '../adminJs-types'; -import { messages } from '../../../utils/messages'; -import { logger } from '../../../utils/logger'; +} from '../adminJs-types.js'; +import { messages } from '../../../utils/messages.js'; +import { logger } from '../../../utils/logger.js'; import { findEvmTransactionByHash, getCsvAirdropTransactions, getGnosisSafeTransactions, -} from '../../../services/chains/evm/transactionService'; +} from '../../../services/chains/evm/transactionService.js'; import { i18n, translationErrorMessagesKeys, -} from '../../../utils/errorMessages'; -import { Project } from '../../../entities/project'; -import { calculateGivbackFactor } from '../../../services/givbackService'; -import { findUserByWalletAddress } from '../../../repositories/userRepository'; +} from '../../../utils/errorMessages.js'; +import { Project } from '../../../entities/project.js'; +import { calculateGivbackFactor } from '../../../services/givbackService.js'; +import { findUserByWalletAddress } from '../../../repositories/userRepository.js'; import { updateUserTotalDonated, updateUserTotalReceived, -} from '../../../services/userService'; -import { NETWORK_IDS } from '../../../provider'; -import { - initExportSpreadsheet, - addDonationsSheetToSpreadsheet, -} from '../../../services/googleSheets'; -import { extractAdminJsReferrerUrlParams } from '../adminJs'; -import { getTwitterDonations } from '../../../services/Idriss/contractDonations'; +} from '../../../services/userService.js'; +import { NETWORK_IDS } from '../../../provider.js'; + +import { getTwitterDonations } from '../../../services/Idriss/contractDonations.js'; import { NetworkTransactionInfo, TransactionDetailInput, -} from '../../../services/chains'; -import { updateProjectStatistics } from '../../../services/projectService'; -import { CoingeckoPriceAdapter } from '../../../adapters/price/CoingeckoPriceAdapter'; -import { Token } from '../../../entities/token'; +} from '../../../services/chains/index.js'; +import { updateProjectStatistics } from '../../../services/projectService.js'; +import { CoingeckoPriceAdapter } from '../../../adapters/price/CoingeckoPriceAdapter.js'; +import { Token } from '../../../entities/token.js'; export const createDonation = async ( request: AdminJsRequestInterface, @@ -356,83 +351,83 @@ export const importDonationsFromIdrissTwitter = async ( } }; -export const exportDonationsWithFiltersToCsv = async ( - _request: ActionContext, - _response, - context: AdminJsContextInterface, -) => { - try { - const { records } = context; - const queryStrings = extractAdminJsReferrerUrlParams(_request); - const projectsQuery = buildDonationsQuery(queryStrings); - const projects = await projectsQuery.getMany(); - - await sendDonationsToGoogleSheet(projects); - - return { - redirectUrl: '/admin/resources/Donation', - records, - notice: { - message: `Donation(s) successfully exported`, - type: 'success', - }, - }; - } catch (e) { - logger.error('exportDonationsWithFiltersToCsv() error', e); - return { - redirectUrl: '/admin/resources/Donation', - record: {}, - notice: { - message: e.message, - type: 'danger', - }, - }; - } -}; +// export const exportDonationsWithFiltersToCsv = async ( +// _request: ActionContext, +// _response, +// context: AdminJsContextInterface, +// ) => { +// try { +// const { records } = context; +// const queryStrings = extractAdminJsReferrerUrlParams(_request); +// const projectsQuery = buildDonationsQuery(queryStrings); +// const projects = await projectsQuery.getMany(); +// +// await sendDonationsToGoogleSheet(projects); +// +// return { +// redirectUrl: '/admin/resources/Donation', +// records, +// notice: { +// message: `Donation(s) successfully exported`, +// type: 'success', +// }, +// }; +// } catch (e) { +// logger.error('exportDonationsWithFiltersToCsv() error', e); +// return { +// redirectUrl: '/admin/resources/Donation', +// record: {}, +// notice: { +// message: e.message, +// type: 'danger', +// }, +// }; +// } +// }; // Spreadsheet filters included -const sendDonationsToGoogleSheet = async ( - donations: Donation[], -): Promise => { - const spreadsheet = await initExportSpreadsheet(); - - // parse data and set headers - const donationRows = donations.map((donation: Donation) => { - return { - id: donation.id, - transactionId: donation.transactionId, - transactionNetworkId: donation.transactionNetworkId, - isProjectVerified: Boolean(donation.isProjectVerified), - status: donation.status, - toWalletAddress: donation.toWalletAddress, - fromWalletAddress: donation.fromWalletAddress, - tokenAddress: donation.tokenAddress || '', - currency: donation.currency, - anonymous: Boolean(donation.anonymous), - amount: donation.amount, - isFiat: Boolean(donation.isFiat), - isCustomToken: Boolean(donation.isCustomToken), - valueEth: donation.valueEth, - valueUsd: donation.valueUsd, - priceEth: donation.priceEth, - priceUsd: donation.priceUsd, - projectId: donation?.project?.id || '', - userId: donation?.user?.id || '', - contactEmail: donation?.contactEmail || '', - createdAt: donation?.createdAt.toISOString(), - referrerWallet: donation?.referrerWallet || '', - isTokenEligibleForGivback: Boolean(donation?.isTokenEligibleForGivback), - qfRoundId: donation?.qfRound?.id || '', - qfRoundUserScore: donation?.qfRoundUserScore || '', - }; - }); - - await addDonationsSheetToSpreadsheet( - spreadsheet, - donationHeaders, - donationRows, - ); -}; +// const sendDonationsToGoogleSheet = async ( +// donations: Donation[], +// ): Promise => { +// const spreadsheet = await initExportSpreadsheet(); +// +// // parse data and set headers +// const donationRows = donations.map((donation: Donation) => { +// return { +// id: donation.id, +// transactionId: donation.transactionId, +// transactionNetworkId: donation.transactionNetworkId, +// isProjectVerified: Boolean(donation.isProjectVerified), +// status: donation.status, +// toWalletAddress: donation.toWalletAddress, +// fromWalletAddress: donation.fromWalletAddress, +// tokenAddress: donation.tokenAddress || '', +// currency: donation.currency, +// anonymous: Boolean(donation.anonymous), +// amount: donation.amount, +// isFiat: Boolean(donation.isFiat), +// isCustomToken: Boolean(donation.isCustomToken), +// valueEth: donation.valueEth, +// valueUsd: donation.valueUsd, +// priceEth: donation.priceEth, +// priceUsd: donation.priceUsd, +// projectId: donation?.project?.id || '', +// userId: donation?.user?.id || '', +// contactEmail: donation?.contactEmail || '', +// createdAt: donation?.createdAt.toISOString(), +// referrerWallet: donation?.referrerWallet || '', +// isTokenEligibleForGivback: Boolean(donation?.isTokenEligibleForGivback), +// qfRoundId: donation?.qfRound?.id || '', +// qfRoundUserScore: donation?.qfRoundUserScore || '', +// }; +// }); +// +// await addDonationsSheetToSpreadsheet( +// spreadsheet, +// donationHeaders, +// donationRows, +// ); +// }; export const donationTab = { resource: Donation, @@ -795,17 +790,17 @@ export const donationTab = { isAccessible: ({ currentAdmin }) => canAccessDonationAction({ currentAdmin }, ResourceActions.NEW), }, - exportFilterToCsv: { - actionType: 'resource', - isVisible: true, - isAccessible: ({ currentAdmin }) => - canAccessDonationAction( - { currentAdmin }, - ResourceActions.EXPORT_FILTER_TO_CSV, - ), - handler: exportDonationsWithFiltersToCsv, - component: false, - }, + // exportFilterToCsv: { + // actionType: 'resource', + // isVisible: true, + // isAccessible: ({ currentAdmin }) => + // canAccessDonationAction( + // { currentAdmin }, + // ResourceActions.EXPORT_FILTER_TO_CSV, + // ), + // handler: exportDonationsWithFiltersToCsv, + // component: false, + // }, importIdrissDonations: { actionType: 'resource', isVisible: true, diff --git a/src/server/adminJs/tabs/featuredUpdateTab.ts b/src/server/adminJs/tabs/featuredUpdateTab.ts index 0d3f82aa0..2e686cec0 100644 --- a/src/server/adminJs/tabs/featuredUpdateTab.ts +++ b/src/server/adminJs/tabs/featuredUpdateTab.ts @@ -1,8 +1,8 @@ -import { FeaturedUpdate } from '../../../entities/featuredUpdate'; +import { FeaturedUpdate } from '../../../entities/featuredUpdate.js'; import { canAccessFeaturedUpdateAction, ResourceActions, -} from '../adminJsPermissions'; +} from '../adminJsPermissions.js'; export const featuredUpdateTab = { resource: FeaturedUpdate, diff --git a/src/server/adminJs/tabs/mainCategoryTab.ts b/src/server/adminJs/tabs/mainCategoryTab.ts index 2cc7b833c..cbd2cdf8c 100644 --- a/src/server/adminJs/tabs/mainCategoryTab.ts +++ b/src/server/adminJs/tabs/mainCategoryTab.ts @@ -1,8 +1,8 @@ -import { MainCategory } from '../../../entities/mainCategory'; +import { MainCategory } from '../../../entities/mainCategory.js'; import { canAccessMainCategoryAction, ResourceActions, -} from '../adminJsPermissions'; +} from '../adminJsPermissions.js'; export const mainCategoryTab = { resource: MainCategory, diff --git a/src/server/adminJs/tabs/organizationsTab.ts b/src/server/adminJs/tabs/organizationsTab.ts index 1bc114106..ba0937c09 100644 --- a/src/server/adminJs/tabs/organizationsTab.ts +++ b/src/server/adminJs/tabs/organizationsTab.ts @@ -1,8 +1,8 @@ -import { Organization } from '../../../entities/organization'; +import { Organization } from '../../../entities/organization.js'; import { canAccessOrganizationAction, ResourceActions, -} from '../adminJsPermissions'; +} from '../adminJsPermissions.js'; export const organizationsTab = { resource: Organization, diff --git a/src/server/adminJs/tabs/projectAddressTab.ts b/src/server/adminJs/tabs/projectAddressTab.ts index f2d6f7e2d..934378771 100644 --- a/src/server/adminJs/tabs/projectAddressTab.ts +++ b/src/server/adminJs/tabs/projectAddressTab.ts @@ -1,8 +1,8 @@ -import { ProjectAddress } from '../../../entities/projectAddress'; +import { ProjectAddress } from '../../../entities/projectAddress.js'; import { canAccessProjectAddressAction, ResourceActions, -} from '../adminJsPermissions'; +} from '../adminJsPermissions.js'; export const projectAddressTab = { resource: ProjectAddress, diff --git a/src/server/adminJs/tabs/projectFraudTab.test.ts b/src/server/adminJs/tabs/projectFraudTab.test.ts index 9fea0e9a2..b904238b9 100644 --- a/src/server/adminJs/tabs/projectFraudTab.test.ts +++ b/src/server/adminJs/tabs/projectFraudTab.test.ts @@ -5,10 +5,10 @@ import { generateRandomEtheriumAddress, saveProjectDirectlyToDb, saveUserDirectlyToDb, -} from '../../../../test/testUtils'; -import { QfRound } from '../../../entities/qfRound'; -import { createProjectFraud } from './projectFraudTab'; -import { errorMessages } from '../../../utils/errorMessages'; +} from '../../../../test/testUtils.js'; +import { QfRound } from '../../../entities/qfRound.js'; +import { createProjectFraud } from './projectFraudTab.js'; +import { errorMessages } from '../../../utils/errorMessages.js'; describe('createSybil test cases', createSybilTestCases); diff --git a/src/server/adminJs/tabs/projectFraudTab.ts b/src/server/adminJs/tabs/projectFraudTab.ts index 7b886f092..1624da29f 100644 --- a/src/server/adminJs/tabs/projectFraudTab.ts +++ b/src/server/adminJs/tabs/projectFraudTab.ts @@ -2,12 +2,12 @@ import csv from 'csvtojson'; import { canAccessProjectFraudAction, ResourceActions, -} from '../adminJsPermissions'; -import { AdminJsRequestInterface } from '../adminJs-types'; -import { logger } from '../../../utils/logger'; -import { messages } from '../../../utils/messages'; -import { ProjectFraud } from '../../../entities/projectFraud'; -import { errorMessages } from '../../../utils/errorMessages'; +} from '../adminJsPermissions.js'; +import { AdminJsRequestInterface } from '../adminJs-types.js'; +import { logger } from '../../../utils/logger.js'; +import { messages } from '../../../utils/messages.js'; +import { ProjectFraud } from '../../../entities/projectFraud.js'; +import { errorMessages } from '../../../utils/errorMessages.js'; export const createProjectFraud = async ( request: AdminJsRequestInterface, diff --git a/src/server/adminJs/tabs/projectStatusHistoryTab.ts b/src/server/adminJs/tabs/projectStatusHistoryTab.ts index 5693ca6f1..70a4740e0 100644 --- a/src/server/adminJs/tabs/projectStatusHistoryTab.ts +++ b/src/server/adminJs/tabs/projectStatusHistoryTab.ts @@ -1,8 +1,8 @@ -import { ProjectStatusHistory } from '../../../entities/projectStatusHistory'; +import { ProjectStatusHistory } from '../../../entities/projectStatusHistory.js'; import { canAccessProjectStatusHistoryAction, ResourceActions, -} from '../adminJsPermissions'; +} from '../adminJsPermissions.js'; export const projectStatusHistoryTab = { resource: ProjectStatusHistory, diff --git a/src/server/adminJs/tabs/projectStatusReasonTab.ts b/src/server/adminJs/tabs/projectStatusReasonTab.ts index ccfd1c0c7..5db92aee4 100644 --- a/src/server/adminJs/tabs/projectStatusReasonTab.ts +++ b/src/server/adminJs/tabs/projectStatusReasonTab.ts @@ -1,8 +1,8 @@ -import { ProjectStatusReason } from '../../../entities/projectStatusReason'; +import { ProjectStatusReason } from '../../../entities/projectStatusReason.js'; import { canAccessProjectStatusReasonAction, ResourceActions, -} from '../adminJsPermissions'; +} from '../adminJsPermissions.js'; export const projectStatusReasonTab = { resource: ProjectStatusReason, diff --git a/src/server/adminJs/tabs/projectStatusTab.ts b/src/server/adminJs/tabs/projectStatusTab.ts index 4145dc92a..b6ed17f28 100644 --- a/src/server/adminJs/tabs/projectStatusTab.ts +++ b/src/server/adminJs/tabs/projectStatusTab.ts @@ -1,8 +1,8 @@ -import { ProjectStatus } from '../../../entities/projectStatus'; +import { ProjectStatus } from '../../../entities/projectStatus.js'; import { canAccessProjectStatusAction, ResourceActions, -} from '../adminJsPermissions'; +} from '../adminJsPermissions.js'; export const projectStatusTab = { resource: ProjectStatus, diff --git a/src/server/adminJs/tabs/projectUpdateTab.ts b/src/server/adminJs/tabs/projectUpdateTab.ts index 1882f088d..f61b61d83 100644 --- a/src/server/adminJs/tabs/projectUpdateTab.ts +++ b/src/server/adminJs/tabs/projectUpdateTab.ts @@ -1,10 +1,10 @@ import { ActionResponse, After } from 'adminjs'; -import { Project, ProjectUpdate } from '../../../entities/project'; +import { Project, ProjectUpdate } from '../../../entities/project.js'; import { canAccessProjectUpdateAction, ResourceActions, -} from '../adminJsPermissions'; -import { addFeaturedProjectUpdate } from './projectsTab'; +} from '../adminJsPermissions.js'; +import { addFeaturedProjectUpdate } from './projectsTab.js'; export const setProjectsTitleAndSlug: After = async request => { if (Number(request?.records?.length) > 0) { diff --git a/src/server/adminJs/tabs/projectVerificationTab.ts b/src/server/adminJs/tabs/projectVerificationTab.ts index 169cf453e..681f165d6 100644 --- a/src/server/adminJs/tabs/projectVerificationTab.ts +++ b/src/server/adminJs/tabs/projectVerificationTab.ts @@ -1,42 +1,44 @@ import adminJs from 'adminjs'; +// @ts-expect-error as d import { RecordJSON } from 'adminjs/src/frontend/interfaces/record-json.interface'; import { ActionResponse, After, + // @ts-expect-error as d } from 'adminjs/src/backend/actions/action.interface'; import { PROJECT_VERIFICATION_STATUSES, ProjectVerificationForm, -} from '../../../entities/projectVerificationForm'; +} from '../../../entities/projectVerificationForm.js'; import { canAccessProjectVerificationFormAction, ResourceActions, -} from '../adminJsPermissions'; +} from '../adminJsPermissions.js'; import { AdminJsContextInterface, AdminJsRequestInterface, -} from '../adminJs-types'; +} from '../adminJs-types.js'; import { findProjectVerificationFormById, makeFormDraft, verifyForm, verifyMultipleForms, -} from '../../../repositories/projectVerificationRepository'; +} from '../../../repositories/projectVerificationRepository.js'; import { i18n, translationErrorMessagesKeys, -} from '../../../utils/errorMessages'; +} from '../../../utils/errorMessages.js'; import { findProjectById, updateProjectWithVerificationForm, verifyMultipleProjects, verifyProject, -} from '../../../repositories/projectRepository'; -import { getNotificationAdapter } from '../../../adapters/adaptersFactory'; -import { logger } from '../../../utils/logger'; -import { Project } from '../../../entities/project'; -import { fillSocialProfileAndQfRounds } from './projectsTab'; +} from '../../../repositories/projectRepository.js'; +import { getNotificationAdapter } from '../../../adapters/adaptersFactory.js'; +import { logger } from '../../../utils/logger.js'; +import { Project } from '../../../entities/project.js'; +import { fillSocialProfileAndQfRounds } from './projectsTab.js'; const extractLastComment = (verificationForm: ProjectVerificationForm) => { const commentsSorted = verificationForm.commentsSection?.comments?.sort( @@ -412,6 +414,7 @@ export const projectVerificationTab = { new: false, }, components: { + // @ts-expect-error as d show: adminJs.bundle('./components/VerificationFormSocials'), }, }, @@ -438,6 +441,7 @@ export const projectVerificationTab = { new: false, }, components: { + // @ts-expect-error as d show: adminJs.bundle('./components/VerificationFormProjectRegistry'), }, }, @@ -470,6 +474,7 @@ export const projectVerificationTab = { new: false, }, components: { + // @ts-expect-error as d show: adminJs.bundle('./components/VerificationFormMilestones'), }, }, diff --git a/src/server/adminJs/tabs/projectsTab.test.ts b/src/server/adminJs/tabs/projectsTab.tes.ts similarity index 94% rename from src/server/adminJs/tabs/projectsTab.test.ts rename to src/server/adminJs/tabs/projectsTab.tes.ts index 832c5d930..38e142fe7 100644 --- a/src/server/adminJs/tabs/projectsTab.test.ts +++ b/src/server/adminJs/tabs/projectsTab.tes.ts @@ -6,40 +6,39 @@ import { saveUserDirectlyToDb, SEED_DATA, sleep, -} from '../../../../test/testUtils'; +} from '../../../../test/testUtils.js'; import { Project, ProjectUpdate, ProjStatus, ReviewStatus, RevokeSteps, -} from '../../../entities/project'; -import { User } from '../../../entities/user'; -import { findOneProjectStatusHistory } from '../../../repositories/projectSatusHistoryRepository'; -import { HISTORY_DESCRIPTIONS } from '../../../entities/projectStatusHistory'; +} from '../../../entities/project.js'; +import { User } from '../../../entities/user.js'; +import { findOneProjectStatusHistory } from '../../../repositories/projectSatusHistoryRepository.js'; +import { HISTORY_DESCRIPTIONS } from '../../../entities/projectStatusHistory.js'; import { createProjectVerificationForm, getVerificationFormByProjectId, -} from '../../../repositories/projectVerificationRepository'; +} from '../../../repositories/projectVerificationRepository.js'; import { PROJECT_VERIFICATION_STATUSES, PROJECT_VERIFICATION_STEPS, -} from '../../../entities/projectVerificationForm'; -import { findUserById } from '../../../repositories/userRepository'; +} from '../../../entities/projectVerificationForm.js'; +import { findUserById } from '../../../repositories/userRepository.js'; import { findProjectById, verifyMultipleProjects, -} from '../../../repositories/projectRepository'; -import { FeaturedUpdate } from '../../../entities/featuredUpdate'; +} from '../../../repositories/projectRepository.js'; +import { FeaturedUpdate } from '../../../entities/featuredUpdate.js'; import { addFeaturedProjectUpdate, - exportProjectsWithFiltersToCsv, listDelist, updateStatusOfProjects, verifyProjects, -} from './projectsTab'; -import { messages } from '../../../utils/messages'; -import { ProjectStatus } from '../../../entities/projectStatus'; +} from './projectsTab.js'; +import { messages } from '../../../utils/messages.js'; +import { ProjectStatus } from '../../../entities/projectStatus.js'; describe( 'verifyMultipleProjects() test cases', @@ -739,42 +738,42 @@ function verifyProjectsTestCases() { } function exportProjectsWithFiltersToCsvTestCases() { - it('should return error because google api key is not set', async () => { - const project = await saveProjectDirectlyToDb({ - ...createProjectData(), - title: String(new Date().getTime()), - slug: String(new Date().getTime()), - verified: true, - listed: false, - reviewStatus: ReviewStatus.NotListed, - }); - const adminUser = await findUserById(SEED_DATA.ADMIN_USER.id); - const result = await exportProjectsWithFiltersToCsv( - { - query: { - recordIds: '', - }, - payload: {}, - record: {}, - }, - { - query: { - recordIds: String(project.id), - }, - }, - { - currentAdmin: adminUser as User, - h: {}, - resource: {}, - records: [], - }, - ); - - assert.equal(result?.notice.type, 'danger'); - // If we set GOOGLE_SPREADSHEETS_PRIVATE_KEY,GOOGLE_SPREADSHEETS_CLIENT_EMAIL,GOOGLE_PROJECT_EXPORTS_SPREADSHEET_ID - // to .env.test we would not get this error anymore - assert.equal(result?.notice.message, 'No key or keyFile set.'); - }); + // it('should return error because google api key is not set', async () => { + // const project = await saveProjectDirectlyToDb({ + // ...createProjectData(), + // title: String(new Date().getTime()), + // slug: String(new Date().getTime()), + // verified: true, + // listed: false, + // reviewStatus: ReviewStatus.NotListed, + // }); + // const adminUser = await findUserById(SEED_DATA.ADMIN_USER.id); + // const result = await exportProjectsWithFiltersToCsv( + // { + // query: { + // recordIds: '', + // }, + // payload: {}, + // record: {}, + // }, + // { + // query: { + // recordIds: String(project.id), + // }, + // }, + // { + // currentAdmin: adminUser as User, + // h: {}, + // resource: {}, + // records: [], + // }, + // ); + // + // assert.equal(result?.notice.type, 'danger'); + // // If we set GOOGLE_SPREADSHEETS_PRIVATE_KEY,GOOGLE_SPREADSHEETS_CLIENT_EMAIL,GOOGLE_PROJECT_EXPORTS_SPREADSHEET_ID + // // to .env.test we would not get this error anymore + // assert.equal(result?.notice.message, 'No key or keyFile set.'); + // }); } function addToFeaturedProjectUpdateTestCases() { diff --git a/src/server/adminJs/tabs/projectsTab.ts b/src/server/adminJs/tabs/projectsTab.ts index 4ad849d95..adeb48353 100644 --- a/src/server/adminJs/tabs/projectsTab.ts +++ b/src/server/adminJs/tabs/projectsTab.ts @@ -3,7 +3,9 @@ import { SelectQueryBuilder } from 'typeorm'; import { ActionResponse, After, + // @ts-expect-error as d } from 'adminjs/src/backend/actions/action.interface'; +// @ts-expect-error as d import { RecordJSON } from 'adminjs/src/frontend/interfaces/record-json.interface'; import { Project, @@ -11,48 +13,45 @@ import { ProjStatus, ReviewStatus, RevokeSteps, -} from '../../../entities/project'; -import { canAccessProjectAction, ResourceActions } from '../adminJsPermissions'; +} from '../../../entities/project.js'; +import { + canAccessProjectAction, + ResourceActions, +} from '../adminJsPermissions.js'; import { findProjectById, findProjectsByIdArray, -} from '../../../repositories/projectRepository'; -import { NOTIFICATIONS_EVENT_NAMES } from '../../../analytics/analytics'; -import { HISTORY_DESCRIPTIONS } from '../../../entities/projectStatusHistory'; -import { getNotificationAdapter } from '../../../adapters/adaptersFactory'; -import { changeUserBoostingsAfterProjectCancelled } from '../../../services/powerBoostingService'; -import { refreshUserProjectPowerView } from '../../../repositories/userProjectPowerViewRepository'; +} from '../../../repositories/projectRepository.js'; +import { NOTIFICATIONS_EVENT_NAMES } from '../../../analytics/analytics.js'; +import { HISTORY_DESCRIPTIONS } from '../../../entities/projectStatusHistory.js'; +import { getNotificationAdapter } from '../../../adapters/adaptersFactory.js'; +import { changeUserBoostingsAfterProjectCancelled } from '../../../services/powerBoostingService.js'; +import { refreshUserProjectPowerView } from '../../../repositories/userProjectPowerViewRepository.js'; import { refreshProjectFuturePowerView, refreshProjectPowerView, -} from '../../../repositories/projectPowerViewRepository'; -import { logger } from '../../../utils/logger'; -import { findSocialProfilesByProjectId } from '../../../repositories/socialProfileRepository'; -import { findProjectUpdatesByProjectId } from '../../../repositories/projectUpdateRepository'; +} from '../../../repositories/projectPowerViewRepository.js'; +import { logger } from '../../../utils/logger.js'; +import { findSocialProfilesByProjectId } from '../../../repositories/socialProfileRepository.js'; +import { findProjectUpdatesByProjectId } from '../../../repositories/projectUpdateRepository.js'; import { AdminJsContextInterface, AdminJsProjectsQuery, AdminJsRequestInterface, - projectHeaders, -} from '../adminJs-types'; -import { ProjectStatus } from '../../../entities/projectStatus'; -import { messages } from '../../../utils/messages'; -import { - addProjectsSheetToSpreadsheet, - initExportSpreadsheet, -} from '../../../services/googleSheets'; -import { NETWORKS_IDS_TO_NAME } from '../../../provider'; +} from '../adminJs-types.js'; +import { ProjectStatus } from '../../../entities/projectStatus.js'; +import { messages } from '../../../utils/messages.js'; + import { getVerificationFormByProjectId, makeFormDraft, makeFormVerified, -} from '../../../repositories/projectVerificationRepository'; -import { FeaturedUpdate } from '../../../entities/featuredUpdate'; -import { findActiveQfRound } from '../../../repositories/qfRoundRepository'; -import { User } from '../../../entities/user'; -import { refreshProjectEstimatedMatchingView } from '../../../services/projectViewsService'; -import { extractAdminJsReferrerUrlParams } from '../adminJs'; -import { relateManyProjectsToQfRound } from '../../../repositories/qfRoundRepository2'; +} from '../../../repositories/projectVerificationRepository.js'; +import { FeaturedUpdate } from '../../../entities/featuredUpdate.js'; +import { findActiveQfRound } from '../../../repositories/qfRoundRepository.js'; +import { User } from '../../../entities/user.js'; +import { refreshProjectEstimatedMatchingView } from '../../../services/projectViewsService.js'; +import { relateManyProjectsToQfRound } from '../../../repositories/qfRoundRepository2.js'; // add queries depending on which filters were selected export const buildProjectsQuery = ( @@ -460,44 +459,44 @@ export const fillSocialProfileAndQfRounds: After< return response; }; -const sendProjectsToGoogleSheet = async ( - projects: Project[], -): Promise => { - const spreadsheet = await initExportSpreadsheet(); - - // parse data and set headers - const projectRows = projects.map((project: Project) => { - const projectAddresses = project.addresses || []; - - return { - id: project.id, - title: project.title, - slug: project.slug, - admin: project.adminUserId, - creationDate: project.creationDate, - updatedAt: project.updatedAt, - impactLocation: project.impactLocation || '', - walletAddress: project.walletAddress, - statusId: project.statusId, - qualityScore: project.qualityScore, - verified: Boolean(project.verified), - listed: Boolean(project.listed), - reviewStatus: project.reviewStatus, - totalDonations: project.totalDonations, - totalProjectUpdates: project.totalProjectUpdates, - website: project.website || '', - email: project?.adminUser?.email || '', - firstWalletAddress: projectAddresses![0]?.address, - firstWalletAddressNetwork: - NETWORKS_IDS_TO_NAME[projectAddresses![0]?.networkId] || '', - secondWalletAddress: projectAddresses![1]?.address || '', - secondWalletAddressNetwork: - NETWORKS_IDS_TO_NAME[projectAddresses![1]?.networkId] || '', - }; - }); - - await addProjectsSheetToSpreadsheet(spreadsheet, projectHeaders, projectRows); -}; +// const sendProjectsToGoogleSheet = async ( +// projects: Project[], +// ): Promise => { +// const spreadsheet = await initExportSpreadsheet(); +// +// // parse data and set headers +// const projectRows = projects.map((project: Project) => { +// const projectAddresses = project.addresses || []; +// +// return { +// id: project.id, +// title: project.title, +// slug: project.slug, +// admin: project.adminUserId, +// creationDate: project.creationDate, +// updatedAt: project.updatedAt, +// impactLocation: project.impactLocation || '', +// walletAddress: project.walletAddress, +// statusId: project.statusId, +// qualityScore: project.qualityScore, +// verified: Boolean(project.verified), +// listed: Boolean(project.listed), +// reviewStatus: project.reviewStatus, +// totalDonations: project.totalDonations, +// totalProjectUpdates: project.totalProjectUpdates, +// website: project.website || '', +// email: project?.adminUser?.email || '', +// firstWalletAddress: projectAddresses![0]?.address, +// firstWalletAddressNetwork: +// NETWORKS_IDS_TO_NAME[projectAddresses![0]?.networkId] || '', +// secondWalletAddress: projectAddresses![1]?.address || '', +// secondWalletAddressNetwork: +// NETWORKS_IDS_TO_NAME[projectAddresses![1]?.networkId] || '', +// }; +// }); +// +// await addProjectsSheetToSpreadsheet(spreadsheet, projectHeaders, projectRows); +// }; export const listDelist = async ( context: AdminJsContextInterface, @@ -578,39 +577,40 @@ export const listDelist = async ( }; }; -export const exportProjectsWithFiltersToCsv = async ( - _request, - _response, - context: AdminJsContextInterface, -) => { - try { - const { records } = context; - const queryStrings = extractAdminJsReferrerUrlParams(_request); - const projectsQuery = buildProjectsQuery(queryStrings); - const projects = await projectsQuery.getMany(); - - await sendProjectsToGoogleSheet(projects); +// export const exportProjectsWithFiltersToCsv = async ( +// _request, +// _response, +// context: AdminJsContextInterface, +// ) => { +// try { +// const { records } = context; +// const queryStrings = extractAdminJsReferrerUrlParams(_request); +// const projectsQuery = buildProjectsQuery(queryStrings); +// const projects = await projectsQuery.getMany(); +// +// await sendProjectsToGoogleSheet(projects); +// +// return { +// redirectUrl: '/admin/resources/Project', +// records, +// notice: { +// message: `Project(s) successfully exported`, +// type: 'success', +// }, +// }; +// } catch (e) { +// logger.error('exportProjectsWithFiltersToCsv() error', e); +// return { +// redirectUrl: '/admin/resources/Project', +// record: {}, +// notice: { +// message: e.message, +// type: 'danger', +// }, +// }; +// } +// }; - return { - redirectUrl: '/admin/resources/Project', - records, - notice: { - message: `Project(s) successfully exported`, - type: 'success', - }, - }; - } catch (e) { - logger.error('exportProjectsWithFiltersToCsv() error', e); - return { - redirectUrl: '/admin/resources/Project', - record: {}, - notice: { - message: e.message, - type: 'danger', - }, - }; - } -}; export const projectsTab = { resource: Project, options: { @@ -659,6 +659,7 @@ export const projectsTab = { new: false, }, components: { + // @ts-expect-error as d show: adminJs.bundle('./components/VerificationFormSocials'), }, }, @@ -743,6 +744,7 @@ export const projectsTab = { }, components: { + // @ts-expect-error migrate to ESM show: adminJs.bundle('./components/ClickableLink'), }, }, @@ -821,6 +823,7 @@ export const projectsTab = { new: false, }, components: { + // @ts-expect-error as d show: adminJs.bundle('./components/ListProjectAddresses'), }, }, @@ -847,6 +850,7 @@ export const projectsTab = { edit: false, }, components: { + // @ts-expect-error as d show: adminJs.bundle('./components/ProjectUpdates'), }, }, @@ -859,6 +863,7 @@ export const projectsTab = { edit: false, }, components: { + // @ts-expect-error as d show: adminJs.bundle('./components/QfRoundsInProject'), }, }, @@ -1117,17 +1122,17 @@ export const projectsTab = { return request; }, }, - exportFilterToCsv: { - actionType: 'resource', - isVisible: true, - isAccessible: ({ currentAdmin }) => - canAccessProjectAction( - { currentAdmin }, - ResourceActions.EXPORT_FILTER_TO_CSV, - ), - handler: exportProjectsWithFiltersToCsv, - component: false, - }, + // exportFilterToCsv: { + // actionType: 'resource', + // isVisible: true, + // isAccessible: ({ currentAdmin }) => + // canAccessProjectAction( + // { currentAdmin }, + // ResourceActions.EXPORT_FILTER_TO_CSV, + // ), + // handler: exportProjectsWithFiltersToCsv, + // component: false, + // }, listProject: { actionType: 'bulk', isVisible: true, diff --git a/src/server/adminJs/tabs/qfRoundHistoryTab.ts b/src/server/adminJs/tabs/qfRoundHistoryTab.ts index d4fadb5cf..137ba8a0a 100644 --- a/src/server/adminJs/tabs/qfRoundHistoryTab.ts +++ b/src/server/adminJs/tabs/qfRoundHistoryTab.ts @@ -1,16 +1,16 @@ import { canAccessQfRoundHistoryAction, ResourceActions, -} from '../adminJsPermissions'; +} from '../adminJsPermissions.js'; -import { QfRoundHistory } from '../../../entities/qfRoundHistory'; +import { QfRoundHistory } from '../../../entities/qfRoundHistory.js'; import { AdminJsContextInterface, AdminJsRequestInterface, -} from '../adminJs-types'; +} from '../adminJs-types.js'; -import { fillQfRoundHistory } from '../../../repositories/qfRoundHistoryRepository'; -import { insertDonationsFromQfRoundHistory } from '../../../services/donationService'; +import { fillQfRoundHistory } from '../../../repositories/qfRoundHistoryRepository.js'; +import { insertDonationsFromQfRoundHistory } from '../../../services/donationService.js'; export const updateQfRoundHistory = async ( _request: AdminJsRequestInterface, diff --git a/src/server/adminJs/tabs/qfRoundTab.ts b/src/server/adminJs/tabs/qfRoundTab.ts index c570ce37f..d4eb0fe7f 100644 --- a/src/server/adminJs/tabs/qfRoundTab.ts +++ b/src/server/adminJs/tabs/qfRoundTab.ts @@ -2,32 +2,33 @@ import fs from 'fs'; import { ActionResponse, After, + // @ts-expect-error as d } from 'adminjs/src/backend/actions/action.interface'; import adminJs, { ValidationError } from 'adminjs'; +// @ts-expect-error as d import { RecordJSON } from 'adminjs/src/frontend/interfaces/record-json.interface'; -import { QfRound } from '../../../entities/qfRound'; -import { canAccessQfRoundAction, ResourceActions } from '../adminJsPermissions'; +import { QfRound } from '../../../entities/qfRound.js'; +import { + canAccessQfRoundAction, + ResourceActions, +} from '../adminJsPermissions.js'; import { - getQfRoundActualDonationDetails, refreshProjectActualMatchingView, refreshProjectEstimatedMatchingView, -} from '../../../services/projectViewsService'; +} from '../../../services/projectViewsService.js'; import { AdminJsContextInterface, AdminJsRequestInterface, -} from '../adminJs-types'; -import { isQfRoundHasEnded } from '../../../services/qfRoundService'; +} from '../adminJs-types.js'; +import { isQfRoundHasEnded } from '../../../services/qfRoundService.js'; import { findQfRoundById, getRelatedProjectsOfQfRound, -} from '../../../repositories/qfRoundRepository'; -import { NETWORK_IDS } from '../../../provider'; -import { logger } from '../../../utils/logger'; -import { messages } from '../../../utils/messages'; -import { addQfRoundDonationsSheetToSpreadsheet } from '../../../services/googleSheets'; -import { errorMessages } from '../../../utils/errorMessages'; -import { relateManyProjectsToQfRound } from '../../../repositories/qfRoundRepository2'; -import { pinFile } from '../../../middleware/pinataUtils'; +} from '../../../repositories/qfRoundRepository.js'; +import { NETWORK_IDS } from '../../../provider.js'; +import { errorMessages } from '../../../utils/errorMessages.js'; +import { relateManyProjectsToQfRound } from '../../../repositories/qfRoundRepository2.js'; +import { pinFile } from '../../../middleware/pinataUtils.js'; let initialProjectIds: number[] = []; @@ -71,40 +72,40 @@ export const fillProjects: After = async ( return response; }; -const returnAllQfRoundDonationAnalysis = async ( - context: AdminJsContextInterface, - request: AdminJsRequestInterface, -) => { - const { record, currentAdmin } = context; - const qfRoundId = Number(request?.params?.recordId); - let type = 'success'; - logger.debug( - 'returnAllQfRoundDonationAnalysis() has been called, qfRoundId', - qfRoundId, - ); - let message = messages.QF_ROUND_DATA_UPLOAD_IN_GOOGLE_SHEET_SUCCESSFULLY; - try { - const qfRoundDonationsRows = - await getQfRoundActualDonationDetails(qfRoundId); - logger.debug('qfRoundDonationsRows', qfRoundDonationsRows); - await addQfRoundDonationsSheetToSpreadsheet({ - rows: qfRoundDonationsRows, - qfRoundId, - }); - } catch (e) { - logger.error('returnAllQfRoundDonationAnalysis() error', e); - message = e.message; - type = 'danger'; - } - - return { - record: record.toJSON(currentAdmin), - notice: { - message, - type, - }, - }; -}; +// const returnAllQfRoundDonationAnalysis = async ( +// context: AdminJsContextInterface, +// request: AdminJsRequestInterface, +// ) => { +// const { record, currentAdmin } = context; +// const qfRoundId = Number(request?.params?.recordId); +// let type = 'success'; +// logger.debug( +// 'returnAllQfRoundDonationAnalysis() has been called, qfRoundId', +// qfRoundId, +// ); +// let message = messages.QF_ROUND_DATA_UPLOAD_IN_GOOGLE_SHEET_SUCCESSFULLY; +// try { +// const qfRoundDonationsRows = +// await getQfRoundActualDonationDetails(qfRoundId); +// logger.debug('qfRoundDonationsRows', qfRoundDonationsRows); +// await addQfRoundDonationsSheetToSpreadsheet({ +// rows: qfRoundDonationsRows, +// qfRoundId, +// }); +// } catch (e) { +// logger.error('returnAllQfRoundDonationAnalysis() error', e); +// message = e.message; +// type = 'danger'; +// } +// +// return { +// record: record.toJSON(currentAdmin), +// notice: { +// message, +// type, +// }, +// }; +// }; async function handleSponsorsImgs(payload: { [key: string]: any; @@ -307,6 +308,7 @@ export const qfRoundTab = { edit: false, }, components: { + // @ts-expect-error as d show: adminJs.bundle('./components/ProjectsInQfRound'), }, }, @@ -319,6 +321,7 @@ export const qfRoundTab = { edit: true, }, components: { + // @ts-expect-error as d edit: adminJs.bundle('./components/QFRoundBannerBg'), }, }, @@ -331,6 +334,7 @@ export const qfRoundTab = { edit: true, }, components: { + // @ts-expect-error as d edit: adminJs.bundle('./components/QFRoundSponsorsImgs'), }, }, @@ -390,20 +394,20 @@ export const qfRoundTab = { after: refreshMaterializedViews, }, - returnAllDonationData: { - // https://docs.adminjs.co/basics/action#record-type-actions - actionType: 'record', - isVisible: true, - isAccessible: ({ currentAdmin }) => - canAccessQfRoundAction( - { currentAdmin }, - ResourceActions.RETURN_ALL_DONATIONS_DATA, - ), - handler: async (request, response, context) => { - return returnAllQfRoundDonationAnalysis(context, request); - }, - component: false, - }, + // returnAllDonationData: { + // // https://docs.adminjs.co/basics/action#record-type-actions + // actionType: 'record', + // isVisible: true, + // isAccessible: ({ currentAdmin }) => + // canAccessQfRoundAction( + // { currentAdmin }, + // ResourceActions.RETURN_ALL_DONATIONS_DATA, + // ), + // handler: async (request, response, context) => { + // return returnAllQfRoundDonationAnalysis(context, request); + // }, + // component: false, + // }, }, }, }; diff --git a/src/server/adminJs/tabs/recurringDonationTab.ts b/src/server/adminJs/tabs/recurringDonationTab.ts index 8816895c9..3df041e49 100644 --- a/src/server/adminJs/tabs/recurringDonationTab.ts +++ b/src/server/adminJs/tabs/recurringDonationTab.ts @@ -1,4 +1,4 @@ -import { RecurringDonation } from '../../../entities/recurringDonation'; +import { RecurringDonation } from '../../../entities/recurringDonation.js'; export const RecurringDonationTab = { resource: RecurringDonation, diff --git a/src/server/adminJs/tabs/sybilTab.test.ts b/src/server/adminJs/tabs/sybilTab.test.ts index ceff58156..acb74fcab 100644 --- a/src/server/adminJs/tabs/sybilTab.test.ts +++ b/src/server/adminJs/tabs/sybilTab.test.ts @@ -3,11 +3,11 @@ import { assert } from 'chai'; import { generateRandomEtheriumAddress, saveUserDirectlyToDb, -} from '../../../../test/testUtils'; -import { QfRound } from '../../../entities/qfRound'; -import { createSybil } from './sybilTab'; -import { errorMessages } from '../../../utils/errorMessages'; -import { Sybil } from '../../../entities/sybil'; +} from '../../../../test/testUtils.js'; +import { QfRound } from '../../../entities/qfRound.js'; +import { createSybil } from './sybilTab.js'; +import { errorMessages } from '../../../utils/errorMessages.js'; +import { Sybil } from '../../../entities/sybil.js'; describe('createSybil test cases', createSybilTestCases); diff --git a/src/server/adminJs/tabs/sybilTab.ts b/src/server/adminJs/tabs/sybilTab.ts index 4373f6f45..e1b98cd0e 100644 --- a/src/server/adminJs/tabs/sybilTab.ts +++ b/src/server/adminJs/tabs/sybilTab.ts @@ -1,11 +1,14 @@ import csv from 'csvtojson'; -import { Sybil } from '../../../entities/sybil'; -import { canAccessSybilAction, ResourceActions } from '../adminJsPermissions'; -import { AdminJsRequestInterface } from '../adminJs-types'; -import { logger } from '../../../utils/logger'; -import { messages } from '../../../utils/messages'; -import { errorMessages } from '../../../utils/errorMessages'; -import { findUserByWalletAddress } from '../../../repositories/userRepository'; +import { Sybil } from '../../../entities/sybil.js'; +import { + canAccessSybilAction, + ResourceActions, +} from '../adminJsPermissions.js'; +import { AdminJsRequestInterface } from '../adminJs-types.js'; +import { logger } from '../../../utils/logger.js'; +import { messages } from '../../../utils/messages.js'; +import { errorMessages } from '../../../utils/errorMessages.js'; +import { findUserByWalletAddress } from '../../../repositories/userRepository.js'; export const createSybil = async ( request: AdminJsRequestInterface, diff --git a/src/server/adminJs/tabs/thirdPartProjectImportTab.ts b/src/server/adminJs/tabs/thirdPartProjectImportTab.ts index d867fbf96..a88a5e7d4 100644 --- a/src/server/adminJs/tabs/thirdPartProjectImportTab.ts +++ b/src/server/adminJs/tabs/thirdPartProjectImportTab.ts @@ -1,18 +1,18 @@ -import { ThirdPartyProjectImport } from '../../../entities/thirdPartyProjectImport'; +import { ThirdPartyProjectImport } from '../../../entities/thirdPartyProjectImport.js'; import { canAccessThirdPartyProjectImportAction, ResourceActions, -} from '../adminJsPermissions'; -import { AdminJsRequestInterface } from '../adminJs-types'; -import { logger } from '../../../utils/logger'; +} from '../adminJsPermissions.js'; +import { AdminJsRequestInterface } from '../adminJs-types.js'; +import { logger } from '../../../utils/logger.js'; import { createProjectFromChangeNonProfit, getChangeNonProfitByNameOrIEN, -} from '../../../services/changeAPI/nonProfits'; +} from '../../../services/changeAPI/nonProfits.js'; import { i18n, translationErrorMessagesKeys, -} from '../../../utils/errorMessages'; +} from '../../../utils/errorMessages.js'; export const importThirdPartyProject = async ( request: AdminJsRequestInterface, diff --git a/src/server/adminJs/tabs/thirdPartyProjectImport.test.ts b/src/server/adminJs/tabs/thirdPartyProjectImport.test.ts index 1dd397f6c..0c1acbfca 100644 --- a/src/server/adminJs/tabs/thirdPartyProjectImport.test.ts +++ b/src/server/adminJs/tabs/thirdPartyProjectImport.test.ts @@ -1,16 +1,16 @@ import { assert } from 'chai'; import sinon from 'sinon'; -import { findUserById } from '../../../repositories/userRepository'; +import { findUserById } from '../../../repositories/userRepository.js'; import { generateRandomEtheriumAddress, SEED_DATA, -} from '../../../../test/testUtils'; -import * as ChangeAPI from '../../../services/changeAPI/nonProfits'; -import { errorMessages } from '../../../utils/errorMessages'; -import { User } from '../../../entities/user'; -import { Project } from '../../../entities/project'; -import { ProjectAddress } from '../../../entities/projectAddress'; -import { importThirdPartyProject } from './thirdPartProjectImportTab'; +} from '../../../../test/testUtils.js'; +import * as ChangeAPI from '../../../services/changeAPI/nonProfits.js'; +import { errorMessages } from '../../../utils/errorMessages.js'; +import { User } from '../../../entities/user.js'; +import { Project } from '../../../entities/project.js'; +import { ProjectAddress } from '../../../entities/projectAddress.js'; +import { importThirdPartyProject } from './thirdPartProjectImportTab.js'; describe( 'importThirdPartyProject() test cases', diff --git a/src/server/adminJs/tabs/tokenTab.test.ts b/src/server/adminJs/tabs/tokenTab.test.ts index 7963c744c..f79d2cc91 100644 --- a/src/server/adminJs/tabs/tokenTab.test.ts +++ b/src/server/adminJs/tabs/tokenTab.test.ts @@ -1,17 +1,17 @@ import { assert } from 'chai'; -import { generateRandomEvmTxHash } from '../../../../test/testUtils'; -import { findTokenByTokenAddress } from '../../../repositories/tokenRepository'; +import { generateRandomEvmTxHash } from '../../../../test/testUtils.js'; +import { findTokenByTokenAddress } from '../../../repositories/tokenRepository.js'; import { Organization, ORGANIZATION_LABELS, -} from '../../../entities/organization'; -import { Token } from '../../../entities/token'; +} from '../../../entities/organization.js'; +import { Token } from '../../../entities/token.js'; import { createToken, generateOrganizationList, linkOrganizations, permute, -} from './tokenTab'; +} from './tokenTab.js'; describe('createToken() test cases', createTokenTestCases); describe('linkOrganizations() test cases', linkOrganizationsTestCases); diff --git a/src/server/adminJs/tabs/tokenTab.ts b/src/server/adminJs/tabs/tokenTab.ts index 937e4ecbf..ae597af61 100644 --- a/src/server/adminJs/tabs/tokenTab.ts +++ b/src/server/adminJs/tabs/tokenTab.ts @@ -1,12 +1,16 @@ import adminJs from 'adminjs'; +// @ts-expect-error as d import { RecordJSON } from 'adminjs/src/frontend/interfaces/record-json.interface'; -import { Token } from '../../../entities/token'; -import { NETWORK_IDS } from '../../../provider'; -import { canAccessTokenAction, ResourceActions } from '../adminJsPermissions'; -import { AdminJsRequestInterface } from '../adminJs-types'; -import { Organization } from '../../../entities/organization'; -import { logger } from '../../../utils/logger'; -import { findTokenByTokenId } from '../../../repositories/tokenRepository'; +import { Token } from '../../../entities/token.js'; +import { NETWORK_IDS } from '../../../provider.js'; +import { + canAccessTokenAction, + ResourceActions, +} from '../adminJsPermissions.js'; +import { AdminJsRequestInterface } from '../adminJs-types.js'; +import { Organization } from '../../../entities/organization.js'; +import { logger } from '../../../utils/logger.js'; +import { findTokenByTokenId } from '../../../repositories/tokenRepository.js'; // generates orderly permutations and maps then into an array which is later flatten into 1 dimension // Current length is the length of selected items from the total items @@ -252,7 +256,9 @@ export const generateTokenTab = async () => { list: true, }, components: { + // @ts-expect-error as d show: adminJs.bundle('./components/ListOrganizationsNames'), + // @ts-expect-error as d list: adminJs.bundle('./components/ListOrganizationsNames'), }, availableValues: await generateOrganizationList(), diff --git a/src/server/adminJs/tabs/usersTab.ts b/src/server/adminJs/tabs/usersTab.ts index 60d75a380..e5aa2877f 100644 --- a/src/server/adminJs/tabs/usersTab.ts +++ b/src/server/adminJs/tabs/usersTab.ts @@ -1,8 +1,7 @@ -import { User } from '../../../entities/user'; -import { canAccessUserAction, ResourceActions } from '../adminJsPermissions'; -import { logger } from '../../../utils/logger'; -// eslint-disable-next-line @typescript-eslint/no-var-requires -const bcrypt = require('bcrypt'); +import bcrypt from 'bcrypt'; +import { User } from '../../../entities/user.js'; +import { canAccessUserAction, ResourceActions } from '../adminJsPermissions.js'; +import { logger } from '../../../utils/logger.js'; export const usersTab = { resource: User, diff --git a/src/server/bootstrap.ts b/src/server/bootstrap.ts index 23e631fd4..9d58b795a 100644 --- a/src/server/bootstrap.ts +++ b/src/server/bootstrap.ts @@ -10,73 +10,73 @@ import express, { json, Request } from 'express'; import { Container } from 'typedi'; import { Resource } from '@adminjs/typeorm'; import { validate } from 'class-validator'; -import { ModuleThread, Pool, spawn, Worker } from 'threads'; +// import { ModuleThread, Pool, spawn, Worker } from 'threads'; import { DataSource } from 'typeorm'; import cors from 'cors'; import bodyParser from 'body-parser'; import graphqlUploadExpress from 'graphql-upload/graphqlUploadExpress.js'; import { ApolloServerPluginLandingPageDisabled } from '@apollo/server/plugin/disabled'; import { ApolloServerErrorCode } from '@apollo/server/errors'; -import config from '../config'; -import { handleStripeWebhook } from '../utils/stripe'; -import createSchema from './createSchema'; -import SentryLogger from '../sentryLogger'; - -import { runCheckPendingDonationsCronJob } from '../services/cronJobs/syncDonationsWithNetwork'; -import { runCheckPendingProjectListingCronJob } from '../services/cronJobs/syncProjectsRequiredForListing'; -import { runCheckProjectVerificationStatus } from '../services/cronJobs/checkProjectVerificationStatus'; -import { webhookHandler } from '../services/transak/webhookHandler'; - -import { adminJsRootPath, getAdminJsRouter } from './adminJs/adminJs'; -import { redis } from '../redis'; -import { logger } from '../utils/logger'; -import { runNotifyMissingDonationsCronJob } from '../services/cronJobs/notifyDonationsWithSegment'; +import config from '../config.js'; +import { handleStripeWebhook } from '../utils/stripe.js'; +import createSchema from './createSchema.js'; +import SentryLogger from '../sentryLogger.js'; + +import { runCheckPendingDonationsCronJob } from '../services/cronJobs/syncDonationsWithNetwork.js'; +import { runCheckPendingProjectListingCronJob } from '../services/cronJobs/syncProjectsRequiredForListing.js'; +import { runCheckProjectVerificationStatus } from '../services/cronJobs/checkProjectVerificationStatus.js'; +import { webhookHandler } from '../services/transak/webhookHandler.js'; + +import { redis } from '../redis.js'; +import { logger } from '../utils/logger.js'; +import { runNotifyMissingDonationsCronJob } from '../services/cronJobs/notifyDonationsWithSegment.js'; import { i18n, setI18nLocaleForRequest, translationErrorMessagesKeys, -} from '../utils/errorMessages'; -import { apiGivRouter } from '../routers/apiGivRoutes'; -import { authorizationHandler } from '../services/authorizationServices'; +} from '../utils/errorMessages.js'; +import { apiGivRouter } from '../routers/apiGivRoutes.js'; +import { authorizationHandler } from '../services/authorizationServices.js'; import { oauth2CallbacksRouter, SOCIAL_PROFILES_PREFIX, -} from '../routers/oauth2Callbacks'; +} from '../routers/oauth2Callbacks.js'; import { dropDbCronExtension, schedulePowerBoostingSnapshot, schedulePowerSnapshotsHistory, -} from '../repositories/dbCronRepository'; -import { runFillPowerSnapshotBalanceCronJob } from '../services/cronJobs/fillSnapshotBalances'; -import { runUpdatePowerRoundCronJob } from '../services/cronJobs/updatePowerRoundJob'; -import { onramperWebhookHandler } from '../services/onramper/webhookHandler'; -import { AppDataSource, CronDataSource } from '../orm'; -import { ApolloContext } from '../types/ApolloContext'; -import { ProjectResolverWorker } from '../workers/projectsResolverWorker'; - -import { runInstantBoostingUpdateCronJob } from '../services/cronJobs/instantBoostingUpdateJob'; -import { refreshProjectEstimatedMatchingView } from '../services/projectViewsService'; -import { isTestEnv } from '../utils/utils'; -import { runCheckActiveStatusOfQfRounds } from '../services/cronJobs/checkActiveStatusQfRounds'; -import { runUpdateProjectCampaignsCacheJob } from '../services/cronJobs/updateProjectCampaignsCacheJob'; -import { corsOptions } from './cors'; -import { runSyncLostDonations } from '../services/cronJobs/importLostDonationsJob'; -import { runSyncBackupServiceDonations } from '../services/cronJobs/backupDonationImportJob'; -import { runUpdateRecurringDonationStream } from '../services/cronJobs/updateStreamOldRecurringDonationsJob'; -import { runDraftDonationMatchWorkerJob } from '../services/cronJobs/draftDonationMatchingJob'; -import { runCheckUserSuperTokenBalancesJob } from '../services/cronJobs/checkUserSuperTokenBalancesJob'; -import { runCheckPendingRecurringDonationsCronJob } from '../services/cronJobs/syncRecurringDonationsWithNetwork'; +} from '../repositories/dbCronRepository.js'; +import { runFillPowerSnapshotBalanceCronJob } from '../services/cronJobs/fillSnapshotBalances.js'; +import { runUpdatePowerRoundCronJob } from '../services/cronJobs/updatePowerRoundJob.js'; +import { onramperWebhookHandler } from '../services/onramper/webhookHandler.js'; +import { AppDataSource, CronDataSource } from '../orm.js'; +import { ApolloContext } from '../types/ApolloContext.js'; + +// import { ProjectResolverWorker } from '../workers/projectsResolverWorker.js'; + +import { runInstantBoostingUpdateCronJob } from '../services/cronJobs/instantBoostingUpdateJob.js'; +import { refreshProjectEstimatedMatchingView } from '../services/projectViewsService.js'; +import { isTestEnv } from '../utils/utils.js'; +import { runCheckActiveStatusOfQfRounds } from '../services/cronJobs/checkActiveStatusQfRounds.js'; +import { runUpdateProjectCampaignsCacheJob } from '../services/cronJobs/updateProjectCampaignsCacheJob.js'; +import { corsOptions } from './cors.js'; +import { runSyncLostDonations } from '../services/cronJobs/importLostDonationsJob.js'; +import { runSyncBackupServiceDonations } from '../services/cronJobs/backupDonationImportJob.js'; +import { runUpdateRecurringDonationStream } from '../services/cronJobs/updateStreamOldRecurringDonationsJob.js'; +import { runDraftDonationMatchWorkerJob } from '../services/cronJobs/draftDonationMatchingJob.js'; +import { runCheckUserSuperTokenBalancesJob } from '../services/cronJobs/checkUserSuperTokenBalancesJob.js'; +import { runCheckPendingRecurringDonationsCronJob } from '../services/cronJobs/syncRecurringDonationsWithNetwork.js'; Resource.validate = validate; -const options = { - concurrency: Number( - process.env.PROJECT_FILTERS_THREADS_POOL_CONCURRENCY || 1, - ), - name: - process.env.PROJECT_FILTERS_THREADS_POOL_NAME || 'ProjectFiltersThreadPool', - size: Number(process.env.PROJECT_FILTERS_THREADS_POOL_SIZE || 4), -}; +// const options = { +// concurrency: Number( +// process.env.PROJECT_FILTERS_THREADS_POOL_CONCURRENCY || 1, +// ), +// name: +// process.env.PROJECT_FILTERS_THREADS_POOL_NAME || 'ProjectFiltersThreadPool', +// size: Number(process.env.PROJECT_FILTERS_THREADS_POOL_SIZE || 4), +// }; export async function bootstrap() { try { @@ -111,11 +111,11 @@ export async function bootstrap() { const schema = await createSchema(); // instantiate pool once and pass as context - const projectsFiltersThreadPool: Pool> = - Pool( - () => spawn(new Worker('../workers/projectsResolverWorker')), - options, - ); + // const projectsFiltersThreadPool: Pool> = + // Pool( + // () => spawn(new Worker('../workers/projectsResolverWorker')), + // options, + // ); const apolloServerPlugins = [ process.env.DISABLE_APOLLO_PLAYGROUND !== 'true' @@ -220,6 +220,7 @@ export async function bootstrap() { ); app.use( '/graphql', + // @ts-expect-error as d graphqlUploadExpress({ maxFileSize: (config.get('UPLOAD_FILE_MAX_SIZE') as number) || 2000000, maxFiles: 10, @@ -260,7 +261,7 @@ export async function bootstrap() { } const apolloContext: ApolloContext = { - projectsFiltersThreadPool, + // projectsFiltersThreadPool, req: { user, auth }, }; return apolloContext; @@ -298,7 +299,7 @@ export async function bootstrap() { }); // AdminJs! - app.use(adminJsRootPath, await getAdminJsRouter()); + // app.use(adminJsRootPath, await getAdminJsRouter()); } catch (err) { logger.fatal('bootstrap() error', err); } diff --git a/src/server/cors.ts b/src/server/cors.ts index 56ed36712..c5b0100b5 100644 --- a/src/server/cors.ts +++ b/src/server/cors.ts @@ -1,5 +1,5 @@ -import config from '../config'; -import { logger } from '../utils/logger'; +import config from '../config.js'; +import { logger } from '../utils/logger.js'; const whitelistHostnames: string[] = ( config.get('HOSTNAME_WHITELIST') as string diff --git a/src/server/createSchema.ts b/src/server/createSchema.ts index 88cd44004..6900a6e5a 100644 --- a/src/server/createSchema.ts +++ b/src/server/createSchema.ts @@ -2,9 +2,9 @@ import * as TypeGraphQL from 'type-graphql'; import { Container } from 'typedi'; import { GraphQLSchema } from 'graphql'; import { NonEmptyArray } from 'type-graphql'; -import { userCheck } from '../auth/userCheck'; -import { getResolvers } from '../resolvers/resolvers'; -import config from '../config'; +import { userCheck } from '../auth/userCheck.js'; +import { getResolvers } from '../resolvers/resolvers.js'; +import config from '../config.js'; const createSchema = async (): Promise => { // James: removing for safety. We shouldn't need to do this again except on a local dev machine diff --git a/src/services/Idriss/contractDonations.ts b/src/services/Idriss/contractDonations.ts index feb540782..e7d53b11a 100644 --- a/src/services/Idriss/contractDonations.ts +++ b/src/services/Idriss/contractDonations.ts @@ -1,31 +1,34 @@ import { ethers } from 'ethers'; import moment from 'moment'; import axios from 'axios'; -import { isTransactionHashStored } from '../../repositories/donationRepository'; -import { DONATION_ORIGINS, Donation } from '../../entities/donation'; -import { findProjectByWalletAddressAndNetwork } from '../../repositories/projectRepository'; -import { NETWORK_IDS } from '../../provider'; -import { i18n, translationErrorMessagesKeys } from '../../utils/errorMessages'; -import { ProjStatus } from '../../entities/project'; -import { Token } from '../../entities/token'; +import { isTransactionHashStored } from '../../repositories/donationRepository.js'; +import { DONATION_ORIGINS, Donation } from '../../entities/donation.js'; +import { findProjectByWalletAddressAndNetwork } from '../../repositories/projectRepository.js'; +import { NETWORK_IDS } from '../../provider.js'; +import { + i18n, + translationErrorMessagesKeys, +} from '../../utils/errorMessages.js'; +import { ProjStatus } from '../../entities/project.js'; +import { Token } from '../../entities/token.js'; import { getMonoSwapTokenPrices, isTokenAcceptableForProject, -} from '../donationService'; -import { findProjectRecipientAddressByNetworkId } from '../../repositories/projectAddressRepository'; -import { relatedActiveQfRoundForProject } from '../qfRoundService'; +} from '../donationService.js'; +import { findProjectRecipientAddressByNetworkId } from '../../repositories/projectAddressRepository.js'; +import { relatedActiveQfRoundForProject } from '../qfRoundService.js'; import { createUserWithPublicAddress, findUserByWalletAddress, -} from '../../repositories/userRepository'; -import { logger } from '../../utils/logger'; -import { getGitcoinAdapter } from '../../adapters/adaptersFactory'; -import { calculateGivbackFactor } from '../givbackService'; +} from '../../repositories/userRepository.js'; +import { logger } from '../../utils/logger.js'; +import { getGitcoinAdapter } from '../../adapters/adaptersFactory.js'; +import { calculateGivbackFactor } from '../givbackService.js'; import { updateUserTotalDonated, updateUserTotalReceived, -} from '../userService'; -import { updateProjectStatistics } from '../projectService'; +} from '../userService.js'; +import { updateProjectStatistics } from '../projectService.js'; // contract address const IDRISS_SUBSQUID_SUBGRAPH_URL = diff --git a/src/services/actualMatchingFundView.test.ts b/src/services/actualMatchingFundView.test.ts index 6c157c5c5..045470f0f 100644 --- a/src/services/actualMatchingFundView.test.ts +++ b/src/services/actualMatchingFundView.test.ts @@ -1,7 +1,7 @@ import moment from 'moment'; import { assert } from 'chai'; -import { QfRound } from '../entities/qfRound'; -import { Project } from '../entities/project'; +import { QfRound } from '../entities/qfRound.js'; +import { Project } from '../entities/project.js'; import { createDonationData, createProjectData, @@ -9,16 +9,16 @@ import { saveDonationDirectlyToDb, saveProjectDirectlyToDb, saveUserDirectlyToDb, -} from '../../test/testUtils'; +} from '../../test/testUtils.js'; import { refreshProjectActualMatchingView, refreshProjectEstimatedMatchingView, -} from './projectViewsService'; -import { ProjectActualMatchingView } from '../entities/ProjectActualMatchingView'; -import { NETWORK_IDS } from '../provider'; -import { Sybil } from '../entities/sybil'; -import { ProjectFraud } from '../entities/projectFraud'; -import { DONATION_STATUS } from '../entities/donation'; +} from './projectViewsService.js'; +import { ProjectActualMatchingView } from '../entities/ProjectActualMatchingView.js'; +import { NETWORK_IDS } from '../provider.js'; +import { Sybil } from '../entities/sybil.js'; +import { ProjectFraud } from '../entities/projectFraud.js'; +import { DONATION_STATUS } from '../entities/donation.js'; describe('getActualMatchingFund test cases', getActualMatchingFundTests); diff --git a/src/services/authorizationService.test.ts b/src/services/authorizationService.test.ts index f79329a79..b78f6effd 100644 --- a/src/services/authorizationService.test.ts +++ b/src/services/authorizationService.test.ts @@ -1,21 +1,19 @@ import { assert } from 'chai'; import Axios from 'axios'; import { ethers } from 'ethers'; +import siwe from 'siwe'; import { generateRandomEtheriumAddress, generateTestAccessToken, saveUserDirectlyToDb, -} from '../../test/testUtils'; -import { User } from '../entities/user'; -import { authorizationHandler } from './authorizationServices'; -import config from '../config'; -import { findUserByWalletAddress } from '../repositories/userRepository'; +} from '../../test/testUtils.js'; +import { User } from '../entities/user.js'; +import { authorizationHandler } from './authorizationServices.js'; +import config from '../config.js'; +import { findUserByWalletAddress } from '../repositories/userRepository.js'; describe('authorizationHandler() test cases', authorizationHandlerTestCases); -// eslint-disable-next-line @typescript-eslint/no-var-requires -const siwe = require('siwe'); - const domain = 'localhost'; const origin = 'https://serve.giveth.io'; @@ -42,7 +40,7 @@ function authorizationHandlerTestCases() { statement: 'This is a test statement.', uri: origin, version: '1', - chainId: '1', + chainId: 1, }); const textMessage = siweMessage.prepareMessage(); const signature = await wallet.signMessage(textMessage); @@ -75,7 +73,7 @@ function authorizationHandlerTestCases() { statement: 'This is a test statement.', uri: origin, version: '1', - chainId: '1', + chainId: 1, }); const textMessage = siweMessage.prepareMessage(); const signature = await wallet.signMessage(textMessage); diff --git a/src/services/authorizationServices.ts b/src/services/authorizationServices.ts index bc0221f1c..72cdc2c43 100644 --- a/src/services/authorizationServices.ts +++ b/src/services/authorizationServices.ts @@ -1,15 +1,15 @@ import Axios from 'axios'; import * as jwt from 'jsonwebtoken'; -import { i18n, translationErrorMessagesKeys } from '../utils/errorMessages'; -import { ApolloContext } from '../types/ApolloContext'; -import SentryLogger from '../sentryLogger'; -import { logger } from '../utils/logger'; +import { i18n, translationErrorMessagesKeys } from '../utils/errorMessages.js'; +import { ApolloContext } from '../types/ApolloContext.js'; +import SentryLogger from '../sentryLogger.js'; +import { logger } from '../utils/logger.js'; import { createUserWithPublicAddress, findUserById, findUserByWalletAddress, -} from '../repositories/userRepository'; -import config from '../config'; +} from '../repositories/userRepository.js'; +import config from '../config.js'; // Add any other service that checks auth on a query or mutation export const checkIfUserInRequest = (ctx: ApolloContext) => { diff --git a/src/services/campaignService.ts b/src/services/campaignService.ts index fd22e2947..3657ecacf 100644 --- a/src/services/campaignService.ts +++ b/src/services/campaignService.ts @@ -1,15 +1,16 @@ import { ModuleThread, Pool } from 'threads'; -import { Campaign, CampaignType } from '../entities/campaign'; +import { Campaign, CampaignType } from '../entities/campaign.js'; import { FilterProjectQueryInputParams, filterProjectsQuery, -} from '../repositories/projectRepository'; -import { FilterField, Project, SortingField } from '../entities/project'; -import { findUserReactionsByProjectIds } from '../repositories/reactionRepository'; -import { ProjectResolverWorker } from '../workers/projectsResolverWorker'; -import { findAllActiveCampaigns } from '../repositories/campaignRepository'; -import { logger } from '../utils/logger'; -import { getRedisObject, setObjectInRedis } from '../redis'; +} from '../repositories/projectRepository.js'; +import { FilterField, Project, SortingField } from '../entities/project.js'; +import { findUserReactionsByProjectIds } from '../repositories/reactionRepository.js'; +// @ts-expect-error migrate to ESM +import { ProjectResolverWorker } from '../workers/projectsResolverWorker.js'; +import { findAllActiveCampaigns } from '../repositories/campaignRepository.js'; +import { logger } from '../utils/logger.js'; +import { getRedisObject, setObjectInRedis } from '../redis.js'; const projectFiltersCacheDuration = Number(process.env.PROJECT_FILTERS_THREADS_POOL_DURATION) || 60000; diff --git a/src/services/chains/evm/draftDonationService.test.ts b/src/services/chains/evm/draftDonationService.test.ts index a192a9a12..949acb058 100644 --- a/src/services/chains/evm/draftDonationService.test.ts +++ b/src/services/chains/evm/draftDonationService.test.ts @@ -3,25 +3,25 @@ import { saveProjectDirectlyToDb, createProjectData, saveUserDirectlyToDb, -} from '../../../../test/testUtils'; +} from '../../../../test/testUtils.js'; import { DRAFT_DONATION_STATUS, DraftDonation, -} from '../../../entities/draftDonation'; -import { NETWORK_IDS } from '../../../provider'; -import { ProjectAddress } from '../../../entities/projectAddress'; +} from '../../../entities/draftDonation.js'; +import { NETWORK_IDS } from '../../../provider.js'; +import { ProjectAddress } from '../../../entities/projectAddress.js'; import { isAmountWithinTolerance, matchDraftDonations, -} from './draftDonationService'; -import { findUserByWalletAddress } from '../../../repositories/userRepository'; +} from './draftDonationService.js'; +import { findUserByWalletAddress } from '../../../repositories/userRepository.js'; import { DONATION_ORIGINS, DONATION_STATUS, Donation, -} from '../../../entities/donation'; -import { Project, ProjectUpdate } from '../../../entities/project'; -import { User } from '../../../entities/user'; +} from '../../../entities/donation.js'; +import { Project, ProjectUpdate } from '../../../entities/project.js'; +import { User } from '../../../entities/user.js'; describe.skip('draftDonationMatching', draftDonationMatchingTests); describe('isAmountWithinTolerance', isAmountWithinToleranceTests); diff --git a/src/services/chains/evm/draftDonationService.ts b/src/services/chains/evm/draftDonationService.ts index cf12315fd..36b81125a 100644 --- a/src/services/chains/evm/draftDonationService.ts +++ b/src/services/chains/evm/draftDonationService.ts @@ -4,18 +4,19 @@ import { ModuleThread, Pool, spawn, Worker } from 'threads'; import { DRAFT_DONATION_STATUS, DraftDonation, -} from '../../../entities/draftDonation'; -import { getNetworkNativeToken } from '../../../provider'; -import { getListOfTransactionsByAddress } from './transactionService'; -import { closeTo } from '..'; -import { findTokenByNetworkAndAddress } from '../../../utils/tokenUtils'; -import { ITxInfo } from '../../../types/etherscan'; -import { DONATION_ORIGINS, Donation } from '../../../entities/donation'; -import { DonationResolver } from '../../../resolvers/donationResolver'; -import { ApolloContext } from '../../../types/ApolloContext'; -import { logger } from '../../../utils/logger'; -import { DraftDonationWorker } from '../../../workers/draftDonationMatchWorker'; -import { normalizeAmount } from '../../../utils/utils'; +} from '../../../entities/draftDonation.js'; +import { getNetworkNativeToken } from '../../../provider.js'; +import { getListOfTransactionsByAddress } from './transactionService.js'; +import { closeTo } from '../index.js'; +import { findTokenByNetworkAndAddress } from '../../../utils/tokenUtils.js'; +import { ITxInfo } from '../../../types/etherscan.js'; +import { DONATION_ORIGINS, Donation } from '../../../entities/donation.js'; +import { DonationResolver } from '../../../resolvers/donationResolver.js'; +import { ApolloContext } from '../../../types/ApolloContext.js'; +import { logger } from '../../../utils/logger.js'; +// @ts-expect-error migrate to ESM +import { DraftDonationWorker } from '../../../workers/draftDonationMatchWorker.js'; +import { normalizeAmount } from '../../../utils/utils.js'; export const isAmountWithinTolerance = ( callData1, diff --git a/src/services/chains/evm/draftRecurringDonationService.test.ts b/src/services/chains/evm/draftRecurringDonationService.test.ts index 48ca6e082..5ea00d963 100644 --- a/src/services/chains/evm/draftRecurringDonationService.test.ts +++ b/src/services/chains/evm/draftRecurringDonationService.test.ts @@ -6,21 +6,21 @@ import { generateRandomEtheriumAddress, generateRandomEvmTxHash, saveRecurringDonationDirectlyToDb, -} from '../../../../test/testUtils'; -import { NETWORK_IDS } from '../../../provider'; -import { Project } from '../../../entities/project'; -import { User } from '../../../entities/user'; +} from '../../../../test/testUtils.js'; +import { NETWORK_IDS } from '../../../provider.js'; +import { Project } from '../../../entities/project.js'; +import { User } from '../../../entities/user.js'; import { DraftRecurringDonation, RECURRING_DONATION_ORIGINS, -} from '../../../entities/draftRecurringDonation'; -import { AnchorContractAddress } from '../../../entities/anchorContractAddress'; +} from '../../../entities/draftRecurringDonation.js'; +import { AnchorContractAddress } from '../../../entities/anchorContractAddress.js'; import { RECURRING_DONATION_STATUS, RecurringDonation, -} from '../../../entities/recurringDonation'; -import { addNewAnchorAddress } from '../../../repositories/anchorContractAddressRepository'; -import { matchDraftRecurringDonations } from './draftRecurringDonationService'; +} from '../../../entities/recurringDonation.js'; +import { addNewAnchorAddress } from '../../../repositories/anchorContractAddressRepository.js'; +import { matchDraftRecurringDonations } from './draftRecurringDonationService.js'; describe('matchDraftRecurringDonations', matchDraftRecurringDonationsTests); diff --git a/src/services/chains/evm/draftRecurringDonationService.ts b/src/services/chains/evm/draftRecurringDonationService.ts index cd79dc283..aa5c46e43 100644 --- a/src/services/chains/evm/draftRecurringDonationService.ts +++ b/src/services/chains/evm/draftRecurringDonationService.ts @@ -1,24 +1,25 @@ import { ModuleThread, Pool, spawn, Worker } from 'threads'; +// @ts-expect-error as d import { WorkerModule } from 'threads/dist/types/worker'; -import { DRAFT_DONATION_STATUS } from '../../../entities/draftDonation'; -import { ApolloContext } from '../../../types/ApolloContext'; -import { logger } from '../../../utils/logger'; +import { DRAFT_DONATION_STATUS } from '../../../entities/draftDonation.js'; +import { ApolloContext } from '../../../types/ApolloContext.js'; +import { logger } from '../../../utils/logger.js'; import { DRAFT_RECURRING_DONATION_STATUS, DraftRecurringDonation, RECURRING_DONATION_ORIGINS, -} from '../../../entities/draftRecurringDonation'; +} from '../../../entities/draftRecurringDonation.js'; import { RECURRING_DONATION_STATUS, RecurringDonation, -} from '../../../entities/recurringDonation'; -import { RecurringDonationResolver } from '../../../resolvers/recurringDonationResolver'; -import { findUserById } from '../../../repositories/userRepository'; -import { findActiveAnchorAddress } from '../../../repositories/anchorContractAddressRepository'; -import { findRecurringDonationById } from '../../../repositories/recurringDonationRepository'; -import { getSuperFluidAdapter } from '../../../adapters/adaptersFactory'; -import { FlowUpdatedEvent } from '../../../adapters/superFluid/superFluidAdapterInterface'; -import { convertTimeStampToSeconds } from '../../../utils/utils'; +} from '../../../entities/recurringDonation.js'; +import { RecurringDonationResolver } from '../../../resolvers/recurringDonationResolver.js'; +import { findUserById } from '../../../repositories/userRepository.js'; +import { findActiveAnchorAddress } from '../../../repositories/anchorContractAddressRepository.js'; +import { findRecurringDonationById } from '../../../repositories/recurringDonationRepository.js'; +import { getSuperFluidAdapter } from '../../../adapters/adaptersFactory.js'; +import { FlowUpdatedEvent } from '../../../adapters/superFluid/superFluidAdapterInterface.js'; +import { convertTimeStampToSeconds } from '../../../utils/utils.js'; type DraftRecurringDonationWorkerFunctions = 'matchDraftRecurringDonations'; export type DraftRecurringDonationWorker = diff --git a/src/services/chains/evm/transactionService.test.ts b/src/services/chains/evm/transactionService.test.ts index 90ad60ef8..e5ebbf30a 100644 --- a/src/services/chains/evm/transactionService.test.ts +++ b/src/services/chains/evm/transactionService.test.ts @@ -3,9 +3,9 @@ import 'mocha'; import { getDisperseTransactions, getEvmTransactionTimestamp, -} from './transactionService'; -import { assertThrowsAsync } from '../../../../test/testUtils'; -import { NETWORK_IDS } from '../../../provider'; +} from './transactionService.js'; +import { assertThrowsAsync } from '../../../../test/testUtils.js'; +import { NETWORK_IDS } from '../../../provider.js'; describe( 'getDisperseTransactions test cases', getDisperseTransactionsTestCases, diff --git a/src/services/chains/evm/transactionService.ts b/src/services/chains/evm/transactionService.ts index 135892d7b..7a7d2287b 100644 --- a/src/services/chains/evm/transactionService.ts +++ b/src/services/chains/evm/transactionService.ts @@ -1,31 +1,30 @@ import abiDecoder from 'abi-decoder'; import axios from 'axios'; +import { ethers } from 'ethers'; import { findTokenByNetworkAndAddress, findTokenByNetworkAndSymbol, -} from '../../../utils/tokenUtils'; +} from '../../../utils/tokenUtils.js'; import { errorMessages, i18n, translationErrorMessagesKeys, -} from '../../../utils/errorMessages'; -import { erc20ABI } from '../../../assets/erc20ABI'; -import { disperseABI } from '../../../assets/disperseABI'; +} from '../../../utils/errorMessages.js'; +import { erc20ABI } from '../../../assets/erc20ABI.js'; +import { disperseABI } from '../../../assets/disperseABI.js'; import { getBlockExplorerApiUrl, getNetworkNativeToken, getProvider, NETWORK_IDS, -} from '../../../provider'; -import { logger } from '../../../utils/logger'; -import { gnosisSafeL2ABI } from '../../../assets/gnosisSafeL2ABI'; -import { NetworkTransactionInfo, TransactionDetailInput } from '../index'; -import { normalizeAmount } from '../../../utils/utils'; -import { ONE_HOUR, validateTransactionWithInputData } from '../index'; -import { ITxInfo } from '../../../types/etherscan'; - -// eslint-disable-next-line @typescript-eslint/no-var-requires -const ethers = require('ethers'); +} from '../../../provider.js'; +import { logger } from '../../../utils/logger.js'; +import { gnosisSafeL2ABI } from '../../../assets/gnosisSafeL2ABI.js'; +import { NetworkTransactionInfo, TransactionDetailInput } from '../index.js'; +import { normalizeAmount } from '../../../utils/utils.js'; +import { ONE_HOUR, validateTransactionWithInputData } from '../index.js'; +import { ITxInfo } from '../../../types/etherscan.js'; + abiDecoder.addABI(erc20ABI); abiDecoder.addABI(gnosisSafeL2ABI); @@ -295,7 +294,7 @@ async function getTransactionDetailForNormalTransfer( let transactionTo = transaction.to; let transactionFrom = transaction.from; - let amount = ethers.utils.formatEther(transaction.value); + let amount = Number(ethers.utils.formatEther(transaction.value)); if (input.safeTxHash && receipt) { const decodedLogs = abiDecoder.decodeLogs(receipt.logs); diff --git a/src/services/chains/index.test.ts b/src/services/chains/index.test.ts index e7145b44c..d98093086 100644 --- a/src/services/chains/index.test.ts +++ b/src/services/chains/index.test.ts @@ -1,10 +1,10 @@ import { assert } from 'chai'; import moment from 'moment'; -import { NETWORK_IDS } from '../../provider'; -import { assertThrowsAsync } from '../../../test/testUtils'; -import { errorMessages } from '../../utils/errorMessages'; -import { ChainType } from '../../types/network'; -import { closeTo, getTransactionInfoFromNetwork } from './index'; +import { NETWORK_IDS } from '../../provider.js'; +import { assertThrowsAsync } from '../../../test/testUtils.js'; +import { errorMessages } from '../../utils/errorMessages.js'; +import { ChainType } from '../../types/network.js'; +import { closeTo, getTransactionInfoFromNetwork } from './index.js'; const ONE_DAY = 60 * 60 * 24; diff --git a/src/services/chains/index.ts b/src/services/chains/index.ts index fb11ef0ef..c6328fde0 100644 --- a/src/services/chains/index.ts +++ b/src/services/chains/index.ts @@ -1,9 +1,12 @@ -import { ChainType } from '../../types/network'; -import { getSolanaTransactionInfoFromNetwork } from './solana/transactionService'; -import { getEvmTransactionInfoFromNetwork } from './evm/transactionService'; -import { i18n, translationErrorMessagesKeys } from '../../utils/errorMessages'; -import { logger } from '../../utils/logger'; -import { NETWORK_IDS } from '../../provider'; +import { ChainType } from '../../types/network.js'; +import { getSolanaTransactionInfoFromNetwork } from './solana/transactionService.js'; +import { getEvmTransactionInfoFromNetwork } from './evm/transactionService.js'; +import { + i18n, + translationErrorMessagesKeys, +} from '../../utils/errorMessages.js'; +import { logger } from '../../utils/logger.js'; +import { NETWORK_IDS } from '../../provider.js'; export interface NetworkTransactionInfo { hash: string; diff --git a/src/services/chains/solana/transactionService.ts b/src/services/chains/solana/transactionService.ts index 8c92325c1..0c1a13ccb 100644 --- a/src/services/chains/solana/transactionService.ts +++ b/src/services/chains/solana/transactionService.ts @@ -1,17 +1,17 @@ import SolanaWeb3, { ParsedInstruction } from '@solana/web3.js'; -import { logger } from '../../../utils/logger'; +import { logger } from '../../../utils/logger.js'; import { NetworkTransactionInfo, TransactionDetailInput, validateTransactionWithInputData, -} from '../index'; -import { normalizeAmount } from '../../../utils/utils'; +} from '../index.js'; +import { normalizeAmount } from '../../../utils/utils.js'; import { i18n, translationErrorMessagesKeys, -} from '../../../utils/errorMessages'; -import { findTokenByNetworkAndSymbol } from '../../../utils/tokenUtils'; -import { NETWORK_IDS } from '../../../provider'; +} from '../../../utils/errorMessages.js'; +import { findTokenByNetworkAndSymbol } from '../../../utils/tokenUtils.js'; +import { NETWORK_IDS } from '../../../provider.js'; const solanaProviders = new Map(); diff --git a/src/services/chainvineReferralService.ts b/src/services/chainvineReferralService.ts index 68424961a..ad3a268f3 100644 --- a/src/services/chainvineReferralService.ts +++ b/src/services/chainvineReferralService.ts @@ -1,9 +1,9 @@ import moment from 'moment'; -import { getChainvineAdapter } from '../adapters/adaptersFactory'; -import { getRoundNumberByDate } from '../utils/powerBoostingUtils'; -import { isFirstTimeDonor } from '../repositories/userRepository'; -import { logger } from '../utils/logger'; -import { findReferredEventByUserId } from '../repositories/referredEventRepository'; +import { getChainvineAdapter } from '../adapters/adaptersFactory.js'; +import { getRoundNumberByDate } from '../utils/powerBoostingUtils.js'; +import { isFirstTimeDonor } from '../repositories/userRepository.js'; +import { logger } from '../utils/logger.js'; +import { findReferredEventByUserId } from '../repositories/referredEventRepository.js'; const isDonationEligibleForReferralReward = (params: { firstTimeDonor: boolean; diff --git a/src/services/changeAPI/nonProfits.ts b/src/services/changeAPI/nonProfits.ts index a6b7f77c3..55cefab0e 100644 --- a/src/services/changeAPI/nonProfits.ts +++ b/src/services/changeAPI/nonProfits.ts @@ -1,22 +1,28 @@ import Axios from 'axios'; import slugify from 'slugify'; -import config from '../../config'; -import { Organization, ORGANIZATION_LABELS } from '../../entities/organization'; +import config from '../../config.js'; +import { + Organization, + ORGANIZATION_LABELS, +} from '../../entities/organization.js'; import { Project, ProjectUpdate, ProjStatus, ReviewStatus, -} from '../../entities/project'; -import { ProjectStatus } from '../../entities/projectStatus'; -import { i18n, translationErrorMessagesKeys } from '../../utils/errorMessages'; -import { logger } from '../../utils/logger'; -import { getAppropriateSlug, getQualityScore } from '../projectService'; -import { findUserById } from '../../repositories/userRepository'; -import { Category, CATEGORY_NAMES } from '../../entities/category'; -import { addBulkNewProjectAddress } from '../../repositories/projectAddressRepository'; -import { NETWORK_IDS } from '../../provider'; -import { User } from '../../entities/user'; +} from '../../entities/project.js'; +import { ProjectStatus } from '../../entities/projectStatus.js'; +import { + i18n, + translationErrorMessagesKeys, +} from '../../utils/errorMessages.js'; +import { logger } from '../../utils/logger.js'; +import { getAppropriateSlug, getQualityScore } from '../projectService.js'; +import { findUserById } from '../../repositories/userRepository.js'; +import { Category, CATEGORY_NAMES } from '../../entities/category.js'; +import { addBulkNewProjectAddress } from '../../repositories/projectAddressRepository.js'; +import { NETWORK_IDS } from '../../provider.js'; +import { User } from '../../entities/user.js'; const changeApiNonProfitUrl = config.get( 'CHANGE_API_NON_PROFITS_SEARCH_URL', @@ -98,6 +104,7 @@ export const createProjectFromChangeNonProfit = async ( const adminUser = (await findUserById(Number(adminId))) as User; if (!adminUser) return; + // @ts-expect-error as d const slugBase = slugify(nonProfit.name, { remove: /[*+~.,()'"!:@]/g, }); diff --git a/src/services/cronJobs/backupDonationImport.test.ts b/src/services/cronJobs/backupDonationImport.test.ts index 1fecba3d7..67d881b45 100644 --- a/src/services/cronJobs/backupDonationImport.test.ts +++ b/src/services/cronJobs/backupDonationImport.test.ts @@ -1,16 +1,16 @@ import { assert } from 'chai'; -import { createBackupDonation } from './backupDonationImportJob'; +import { createBackupDonation } from './backupDonationImportJob.js'; import { assertThrowsAsync, createProjectData, generateRandomEtheriumAddress, generateRandomEvmTxHash, saveProjectDirectlyToDb, -} from '../../../test/testUtils'; -import { User } from '../../entities/user'; -import { NETWORK_IDS } from '../../provider'; -import { DONATION_STATUS } from '../../entities/donation'; -import { findTokenByNetworkAndSymbol } from '../../utils/tokenUtils'; +} from '../../../test/testUtils.js'; +import { User } from '../../entities/user.js'; +import { NETWORK_IDS } from '../../provider.js'; +import { DONATION_STATUS } from '../../entities/donation.js'; +import { findTokenByNetworkAndSymbol } from '../../utils/tokenUtils.js'; describe('createBackupDonation test cases', createBackupDonationTestCases); diff --git a/src/services/cronJobs/backupDonationImportJob.ts b/src/services/cronJobs/backupDonationImportJob.ts index 9b2f3e826..02da12733 100644 --- a/src/services/cronJobs/backupDonationImportJob.ts +++ b/src/services/cronJobs/backupDonationImportJob.ts @@ -1,16 +1,19 @@ import { schedule } from 'node-cron'; -import config from '../../config'; +import config from '../../config.js'; -import { logger } from '../../utils/logger'; -import { i18n, translationErrorMessagesKeys } from '../../utils/errorMessages'; -import { findUserByWalletAddress } from '../../repositories/userRepository'; -import { Donation } from '../../entities/donation'; -import { FetchedSavedFailDonationInterface } from '../../adapters/donationSaveBackup/DonationSaveBackupInterface'; -import { getDonationSaveBackupAdapter } from '../../adapters/adaptersFactory'; -import { DonationResolver } from '../../resolvers/donationResolver'; -import { ApolloContext } from '../../types/ApolloContext'; -import { findDonationById } from '../../repositories/donationRepository'; -import { getCreatedAtFromMongoObjectId } from '../../utils/utils'; +import { logger } from '../../utils/logger.js'; +import { + i18n, + translationErrorMessagesKeys, +} from '../../utils/errorMessages.js'; +import { findUserByWalletAddress } from '../../repositories/userRepository.js'; +import { Donation } from '../../entities/donation.js'; +import { FetchedSavedFailDonationInterface } from '../../adapters/donationSaveBackup/DonationSaveBackupInterface.js'; +import { getDonationSaveBackupAdapter } from '../../adapters/adaptersFactory.js'; +import { DonationResolver } from '../../resolvers/donationResolver.js'; +import { ApolloContext } from '../../types/ApolloContext.js'; +import { findDonationById } from '../../repositories/donationRepository.js'; +import { getCreatedAtFromMongoObjectId } from '../../utils/utils.js'; const cronJobTime = (config.get('DONATION_SAVE_BACKUP_CRONJOB_EXPRESSION') as string) || diff --git a/src/services/cronJobs/checkActiveStatusQfRounds.ts b/src/services/cronJobs/checkActiveStatusQfRounds.ts index 74de3d478..63c31cace 100644 --- a/src/services/cronJobs/checkActiveStatusQfRounds.ts +++ b/src/services/cronJobs/checkActiveStatusQfRounds.ts @@ -1,17 +1,17 @@ import { schedule } from 'node-cron'; -import config from '../../config'; -import { logger } from '../../utils/logger'; -import { isTestEnv } from '../../utils/utils'; +import config from '../../config.js'; +import { logger } from '../../utils/logger.js'; +import { isTestEnv } from '../../utils/utils.js'; import { deactivateExpiredQfRounds, getExpiredActiveQfRounds, -} from '../../repositories/qfRoundRepository'; +} from '../../repositories/qfRoundRepository.js'; import { refreshProjectActualMatchingView, refreshProjectEstimatedMatchingView, -} from '../projectViewsService'; -import { fillQfRoundHistory } from '../../repositories/qfRoundHistoryRepository'; -import { fillQfRoundDonationsUserScores } from '../../repositories/donationRepository'; +} from '../projectViewsService.js'; +import { fillQfRoundHistory } from '../../repositories/qfRoundHistoryRepository.js'; +import { fillQfRoundDonationsUserScores } from '../../repositories/donationRepository.js'; // every 10 minutes const cronJobTime = diff --git a/src/services/cronJobs/checkProjectVerificationStatus.test.ts b/src/services/cronJobs/checkProjectVerificationStatus.test.ts index 3b1d2d66e..d6f61c58d 100644 --- a/src/services/cronJobs/checkProjectVerificationStatus.test.ts +++ b/src/services/cronJobs/checkProjectVerificationStatus.test.ts @@ -1,15 +1,13 @@ import { assert } from 'chai'; -import { RevokeSteps } from '../../entities/project'; +import moment from 'moment'; +import { RevokeSteps } from '../../entities/project.js'; -import { checkProjectVerificationStatus } from './checkProjectVerificationStatus'; +import { checkProjectVerificationStatus } from './checkProjectVerificationStatus.js'; import { createProjectData, saveProjectDirectlyToDb, -} from '../../../test/testUtils'; -import { findProjectById } from '../../repositories/projectRepository'; - -// eslint-disable-next-line @typescript-eslint/no-var-requires -const moment = require('moment'); +} from '../../../test/testUtils.js'; +import { findProjectById } from '../../repositories/projectRepository.js'; describe( 'checkProjectVerificationStatus() test cases', @@ -48,7 +46,10 @@ function checkProjectVerificationStatusTestCases() { title: String(new Date().getTime()), slug: String(new Date().getTime()), verified: true, - latestUpdateCreationDate: moment().subtract(91, 'days').endOf('day'), + latestUpdateCreationDate: moment() + .subtract(91, 'days') + .endOf('day') + .toDate(), verificationStatus: RevokeSteps.Warning, }); @@ -68,7 +69,10 @@ function checkProjectVerificationStatusTestCases() { title: String(new Date().getTime()), slug: String(new Date().getTime()), verified: true, - latestUpdateCreationDate: moment().subtract(105, 'days').endOf('day'), + latestUpdateCreationDate: moment() + .subtract(105, 'days') + .endOf('day') + .toDate(), verificationStatus: RevokeSteps.LastChance, }); @@ -90,7 +94,10 @@ function checkProjectVerificationStatusTestCases() { title: String(new Date().getTime()), slug: String(new Date().getTime()), verified: true, - latestUpdateCreationDate: moment().subtract(105, 'days').endOf('day'), + latestUpdateCreationDate: moment() + .subtract(105, 'days') + .endOf('day') + .toDate(), isImported: true, }); diff --git a/src/services/cronJobs/checkProjectVerificationStatus.ts b/src/services/cronJobs/checkProjectVerificationStatus.ts index 10116c199..ef0fe7bac 100644 --- a/src/services/cronJobs/checkProjectVerificationStatus.ts +++ b/src/services/cronJobs/checkProjectVerificationStatus.ts @@ -1,11 +1,14 @@ import { schedule } from 'node-cron'; -import moment = require('moment'); -import { Project, RevokeSteps } from '../../entities/project'; -import config from '../../config'; -import { logger } from '../../utils/logger'; -import { projectsWithoutUpdateAfterTimeFrame } from '../../repositories/projectRepository'; -import { i18n, translationErrorMessagesKeys } from '../../utils/errorMessages'; -import { getNotificationAdapter } from '../../adapters/adaptersFactory'; +import moment from 'moment'; +import { Project, RevokeSteps } from '../../entities/project.js'; +import config from '../../config.js'; +import { logger } from '../../utils/logger.js'; +import { projectsWithoutUpdateAfterTimeFrame } from '../../repositories/projectRepository.js'; +import { + i18n, + translationErrorMessagesKeys, +} from '../../utils/errorMessages.js'; +import { getNotificationAdapter } from '../../adapters/adaptersFactory.js'; const cronJobTime = (config.get( diff --git a/src/services/cronJobs/checkUserSuperTokenBalancesJob.ts b/src/services/cronJobs/checkUserSuperTokenBalancesJob.ts index ae7a3bba2..332cb74b9 100644 --- a/src/services/cronJobs/checkUserSuperTokenBalancesJob.ts +++ b/src/services/cronJobs/checkUserSuperTokenBalancesJob.ts @@ -1,10 +1,10 @@ import { schedule } from 'node-cron'; -import config from '../../config'; -import { logger } from '../../utils/logger'; +import config from '../../config.js'; +import { logger } from '../../utils/logger.js'; import { processRecurringDonationBalancesJobs, runCheckUserSuperTokenBalances, -} from './checkUserSuperTokenBalancesQueue'; +} from './checkUserSuperTokenBalancesQueue.js'; const cronJobTime = (config.get('CHECK_USERS_SUPER_TOKEN_BALANCES_CRONJOB_TIME') as string) || diff --git a/src/services/cronJobs/checkUserSuperTokenBalancesQueue.ts b/src/services/cronJobs/checkUserSuperTokenBalancesQueue.ts index 567ad9671..dc3b0084a 100644 --- a/src/services/cronJobs/checkUserSuperTokenBalancesQueue.ts +++ b/src/services/cronJobs/checkUserSuperTokenBalancesQueue.ts @@ -2,19 +2,19 @@ import Bull from 'bull'; import { getNotificationAdapter, getSuperFluidAdapter, -} from '../../adapters/adaptersFactory'; -import config from '../../config'; -import { RecurringDonation } from '../../entities/recurringDonation'; -import { redisConfig } from '../../redis'; -import { findUserById } from '../../repositories/userRepository'; -import { logger } from '../../utils/logger'; +} from '../../adapters/adaptersFactory.js'; +import config from '../../config.js'; +import { RecurringDonation } from '../../entities/recurringDonation.js'; +import { redisConfig } from '../../redis.js'; +import { findUserById } from '../../repositories/userRepository.js'; +import { logger } from '../../utils/logger.js'; import { findActiveRecurringDonations, findRecurringDonationById, -} from '../../repositories/recurringDonationRepository'; -import { getCurrentDateFormatted } from '../../utils/utils'; -import { getNetworkNameById, superTokens } from '../../provider'; -import { NOTIFICATIONS_EVENT_NAMES } from '../../analytics/analytics'; +} from '../../repositories/recurringDonationRepository.js'; +import { getCurrentDateFormatted } from '../../utils/utils.js'; +import { getNetworkNameById, superTokens } from '../../provider.js'; +import { NOTIFICATIONS_EVENT_NAMES } from '../../analytics/analytics.js'; const runCheckUserSuperTokenBalancesQueue = new Bull( 'user-token-balances-stream-queue', diff --git a/src/services/cronJobs/draftDonationMatchingJob.ts b/src/services/cronJobs/draftDonationMatchingJob.ts index 2be2d607b..26214fa27 100644 --- a/src/services/cronJobs/draftDonationMatchingJob.ts +++ b/src/services/cronJobs/draftDonationMatchingJob.ts @@ -1,11 +1,10 @@ import { schedule } from 'node-cron'; -import config from '../../config'; -import { logger } from '../../utils/logger'; -import { runDraftDonationMatchWorker } from '../chains/evm/draftDonationService'; +import config from '../../config.js'; +import { logger } from '../../utils/logger.js'; import { countPendingDraftDonations, delecteExpiredDraftDonations, -} from '../../repositories/draftDonationRepository'; +} from '../../repositories/draftDonationRepository.js'; const cronJobTime = (config.get('MATCH_DRAFT_DONATION_CRONJOB_EXPRESSION') as string) || @@ -22,12 +21,12 @@ export const runDraftDonationMatchWorkerJob = async () => { const hours = Number(process.env.DRAFT_DONATION_MATCH_EXPIRATION_HOURS || 48); schedule(cronJobTime, async () => { await delecteExpiredDraftDonations(hours); - await runDraftDonationMatchWorker(); + // await runDraftDonationMatchWorker(); }); // Execute first time when running await delecteExpiredDraftDonations(hours); - await runDraftDonationMatchWorker(); + // await runDraftDonationMatchWorker(); setInterval(async () => { try { logger.debug( diff --git a/src/services/cronJobs/draftRecurringDonationMatchingJob.ts b/src/services/cronJobs/draftRecurringDonationMatchingJob.ts index c99e96acc..84b847c81 100644 --- a/src/services/cronJobs/draftRecurringDonationMatchingJob.ts +++ b/src/services/cronJobs/draftRecurringDonationMatchingJob.ts @@ -1,12 +1,12 @@ import { schedule } from 'node-cron'; -import config from '../../config'; -import { logger } from '../../utils/logger'; +import config from '../../config.js'; +import { logger } from '../../utils/logger.js'; import { DRAFT_RECURRING_DONATION_STATUS, DraftRecurringDonation, -} from '../../entities/draftRecurringDonation'; -import { runDraftRecurringDonationMatchWorker } from '../chains/evm/draftRecurringDonationService'; -import { deleteExpiredDraftRecurringDonations } from '../../repositories/draftRecurringDonationRepository'; +} from '../../entities/draftRecurringDonation.js'; +import { runDraftRecurringDonationMatchWorker } from '../chains/evm/draftRecurringDonationService.js'; +import { deleteExpiredDraftRecurringDonations } from '../../repositories/draftRecurringDonationRepository.js'; const cronJobTime = (config.get('MATCH_DRAFT_DONATION_CRONJOB_EXPRESSION') as string) || diff --git a/src/services/cronJobs/fillSnapshotBalances.test.ts b/src/services/cronJobs/fillSnapshotBalances.test.ts index af8ee9915..3c7ae4c40 100644 --- a/src/services/cronJobs/fillSnapshotBalances.test.ts +++ b/src/services/cronJobs/fillSnapshotBalances.test.ts @@ -3,21 +3,21 @@ import sinon from 'sinon'; import { addFillPowerSnapshotBalanceJobsToQueue, processFillPowerSnapshotJobs, -} from './fillSnapshotBalances'; -import { getPowerBoostingSnapshotWithoutBalance } from '../../repositories/powerSnapshotRepository'; +} from './fillSnapshotBalances.js'; +import { getPowerBoostingSnapshotWithoutBalance } from '../../repositories/powerSnapshotRepository.js'; import { createProjectData, generateRandomEtheriumAddress, saveProjectDirectlyToDb, saveUserDirectlyToDb, sleep, -} from '../../../test/testUtils'; -import { PowerSnapshot } from '../../entities/powerSnapshot'; -import { PowerBoostingSnapshot } from '../../entities/powerBoostingSnapshot'; -import { AppDataSource } from '../../orm'; -import { PowerBalanceSnapshot } from '../../entities/powerBalanceSnapshot'; -import { getPowerBalanceAggregatorAdapter } from '../../adapters/adaptersFactory'; -import { convertTimeStampToSeconds } from '../../utils/utils'; +} from '../../../test/testUtils.js'; +import { PowerSnapshot } from '../../entities/powerSnapshot.js'; +import { PowerBoostingSnapshot } from '../../entities/powerBoostingSnapshot.js'; +import { AppDataSource } from '../../orm.js'; +import { PowerBalanceSnapshot } from '../../entities/powerBalanceSnapshot.js'; +import { getPowerBalanceAggregatorAdapter } from '../../adapters/adaptersFactory.js'; +import { convertTimeStampToSeconds } from '../../utils/utils.js'; describe( 'processFillPowerSnapshotJobs test cases', diff --git a/src/services/cronJobs/fillSnapshotBalances.ts b/src/services/cronJobs/fillSnapshotBalances.ts index 97e3ef39c..65adee2e7 100644 --- a/src/services/cronJobs/fillSnapshotBalances.ts +++ b/src/services/cronJobs/fillSnapshotBalances.ts @@ -1,15 +1,15 @@ import Bull from 'bull'; import { schedule } from 'node-cron'; import _ from 'lodash'; -import { redisConfig } from '../../redis'; -import { logger } from '../../utils/logger'; -import config from '../../config'; -import { getPowerBalanceAggregatorAdapter } from '../../adapters/adaptersFactory'; +import { redisConfig } from '../../redis.js'; +import { logger } from '../../utils/logger.js'; +import config from '../../config.js'; +import { getPowerBalanceAggregatorAdapter } from '../../adapters/adaptersFactory.js'; import { getPowerBoostingSnapshotWithoutBalance, GetPowerBoostingSnapshotWithoutBalanceOutput, -} from '../../repositories/powerSnapshotRepository'; -import { addOrUpdatePowerSnapshotBalances } from '../../repositories/powerBalanceSnapshotRepository'; +} from '../../repositories/powerSnapshotRepository.js'; +import { addOrUpdatePowerSnapshotBalances } from '../../repositories/powerBalanceSnapshotRepository.js'; // Constants const FILL_SNAPSHOT_BALANCE_QUEUE_NAME = 'fill-snapshot-balance-aggregator'; diff --git a/src/services/cronJobs/importLostDonationsJob.ts b/src/services/cronJobs/importLostDonationsJob.ts index 5438cc6c5..32a0dde7f 100644 --- a/src/services/cronJobs/importLostDonationsJob.ts +++ b/src/services/cronJobs/importLostDonationsJob.ts @@ -1,32 +1,34 @@ import abiDecoder from 'abi-decoder'; import { schedule } from 'node-cron'; import moment from 'moment'; -import config from '../../config'; -import { Donation } from '../../entities/donation'; -import { logger } from '../../utils/logger'; -import { NetworkTransactionInfo } from '../chains'; -import { getProvider, NETWORKS_IDS_TO_NAME } from '../../provider'; -import { erc20ABI } from '../../assets/erc20ABI'; -import { User } from '../../entities/user'; -import { Token } from '../../entities/token'; -import { Project } from '../../entities/project'; -import { calculateGivbackFactor } from '../givbackService'; +import { ethers } from 'ethers'; +import config from '../../config.js'; +import { Donation } from '../../entities/donation.js'; +import { logger } from '../../utils/logger.js'; +import { NetworkTransactionInfo } from '../chains/index.js'; +import { getProvider, NETWORKS_IDS_TO_NAME } from '../../provider.js'; +import { erc20ABI } from '../../assets/erc20ABI.js'; +import { User } from '../../entities/user.js'; +import { Token } from '../../entities/token.js'; +import { Project } from '../../entities/project.js'; +import { calculateGivbackFactor } from '../givbackService.js'; import { getUserDonationStats, updateUserTotalDonated, updateUserTotalReceived, -} from '../userService'; -import { toFixNumber } from '../donationService'; -import { refreshProjectEstimatedMatchingView } from '../projectViewsService'; -import { CoingeckoPriceAdapter } from '../../adapters/price/CoingeckoPriceAdapter'; -import { QfRound } from '../../entities/qfRound'; -import { i18n, translationErrorMessagesKeys } from '../../utils/errorMessages'; -import { getNotificationAdapter } from '../../adapters/adaptersFactory'; -import { getOrttoPersonAttributes } from '../../adapters/notifications/NotificationCenterAdapter'; -import { updateProjectStatistics } from '../projectService'; - -// eslint-disable-next-line @typescript-eslint/no-var-requires -const ethers = require('ethers'); +} from '../userService.js'; +import { toFixNumber } from '../donationService.js'; +import { refreshProjectEstimatedMatchingView } from '../projectViewsService.js'; +import { CoingeckoPriceAdapter } from '../../adapters/price/CoingeckoPriceAdapter.js'; +import { QfRound } from '../../entities/qfRound.js'; +import { + i18n, + translationErrorMessagesKeys, +} from '../../utils/errorMessages.js'; +import { getNotificationAdapter } from '../../adapters/adaptersFactory.js'; +import { getOrttoPersonAttributes } from '../../adapters/notifications/NotificationCenterAdapter.js'; +import { updateProjectStatistics } from '../projectService.js'; + abiDecoder.addABI(erc20ABI); const QF_ROUND_ID = config.get('LOST_DONATIONS_QF_ROUND'); @@ -293,7 +295,7 @@ async function getDonationDetailForNormalTransfer( ); const transactionTo = transaction.to; - const amount = ethers.utils.formatEther(transaction.value); + const amount = Number(ethers.utils.formatEther(transaction.value)); return { from: transaction.from, diff --git a/src/services/cronJobs/instantBoostingUpdateJob.ts b/src/services/cronJobs/instantBoostingUpdateJob.ts index 660954105..79551e612 100644 --- a/src/services/cronJobs/instantBoostingUpdateJob.ts +++ b/src/services/cronJobs/instantBoostingUpdateJob.ts @@ -1,7 +1,7 @@ import { schedule } from 'node-cron'; -import config from '../../config'; -import { logger } from '../../utils/logger'; -import { updateInstantBoosting } from '../instantBoostingServices'; +import config from '../../config.js'; +import { logger } from '../../utils/logger.js'; +import { updateInstantBoosting } from '../instantBoostingServices.js'; const cronJobTime = (config.get('INSTANT_BOOSTING_UPDATE_CRONJOB_EXPRESSION') as string) || diff --git a/src/services/cronJobs/notifyDonationsWithSegment.test.ts b/src/services/cronJobs/notifyDonationsWithSegment.test.ts index 90afbea45..6d7561cf6 100644 --- a/src/services/cronJobs/notifyDonationsWithSegment.test.ts +++ b/src/services/cronJobs/notifyDonationsWithSegment.test.ts @@ -5,11 +5,11 @@ import { createDonationData, saveDonationDirectlyToDb, SEED_DATA, -} from '../../../test/testUtils'; -import { Donation, DONATION_STATUS } from '../../entities/donation'; -import { notifyMissingDonationsWithSegment } from './notifyDonationsWithSegment'; -import * as utils from '../../utils/utils'; -import { findDonationById } from '../../repositories/donationRepository'; +} from '../../../test/testUtils.js'; +import { Donation, DONATION_STATUS } from '../../entities/donation.js'; +import { notifyMissingDonationsWithSegment } from './notifyDonationsWithSegment.js'; +import * as utils from '../../utils/utils.js'; +import { findDonationById } from '../../repositories/donationRepository.js'; describe( 'notifyMissingDonationsWithSegment() test cases', diff --git a/src/services/cronJobs/notifyDonationsWithSegment.ts b/src/services/cronJobs/notifyDonationsWithSegment.ts index bd05aba5c..522e7d685 100644 --- a/src/services/cronJobs/notifyDonationsWithSegment.ts +++ b/src/services/cronJobs/notifyDonationsWithSegment.ts @@ -1,9 +1,9 @@ import { schedule } from 'node-cron'; -import { Donation, DONATION_STATUS } from '../../entities/donation'; -import { logger } from '../../utils/logger'; -import { sleep } from '../../utils/utils'; -import config from '../../config'; -import { sendNotificationForDonation } from '../donationService'; +import { Donation, DONATION_STATUS } from '../../entities/donation.js'; +import { logger } from '../../utils/logger.js'; +import { sleep } from '../../utils/utils.js'; +import config from '../../config.js'; +import { sendNotificationForDonation } from '../donationService.js'; const cronJobTime = (config.get( diff --git a/src/services/cronJobs/syncDonationsWithNetwork.ts b/src/services/cronJobs/syncDonationsWithNetwork.ts index 02c1af491..8a79d70fe 100644 --- a/src/services/cronJobs/syncDonationsWithNetwork.ts +++ b/src/services/cronJobs/syncDonationsWithNetwork.ts @@ -1,10 +1,10 @@ import { schedule } from 'node-cron'; import Bull from 'bull'; -import config from '../../config'; -import { redisConfig } from '../../redis'; -import { logger } from '../../utils/logger'; -import { syncDonationStatusWithBlockchainNetwork } from '../donationService'; -import { getPendingDonationsIds } from '../../repositories/donationRepository'; +import config from '../../config.js'; +import { redisConfig } from '../../redis.js'; +import { logger } from '../../utils/logger.js'; +import { syncDonationStatusWithBlockchainNetwork } from '../donationService.js'; +import { getPendingDonationsIds } from '../../repositories/donationRepository.js'; const verifyDonationsQueue = new Bull('verify-donations-queue', { redis: redisConfig, diff --git a/src/services/cronJobs/syncIdrissTwitterDonations.ts b/src/services/cronJobs/syncIdrissTwitterDonations.ts index a7dcc5b68..4fe015023 100644 --- a/src/services/cronJobs/syncIdrissTwitterDonations.ts +++ b/src/services/cronJobs/syncIdrissTwitterDonations.ts @@ -1,7 +1,7 @@ import { schedule } from 'node-cron'; -import config from '../../config'; -import { logger } from '../../utils/logger'; -import { getTwitterDonations } from '../Idriss/contractDonations'; +import config from '../../config.js'; +import { logger } from '../../utils/logger.js'; +import { getTwitterDonations } from '../Idriss/contractDonations.js'; const cronJobTime = (config.get('SYNC_IDRISS_TWITTER_DONATIONS_CRONJOB_EXPRESSION') as string) || diff --git a/src/services/cronJobs/syncProjectsRequiredForListing.test.ts b/src/services/cronJobs/syncProjectsRequiredForListing.test.ts index b36c864b0..1cbacb7fd 100644 --- a/src/services/cronJobs/syncProjectsRequiredForListing.test.ts +++ b/src/services/cronJobs/syncProjectsRequiredForListing.test.ts @@ -1,13 +1,11 @@ import { assert } from 'chai'; +import moment from 'moment'; import { createProjectData, saveProjectDirectlyToDb, -} from '../../../test/testUtils'; -import { Project, ProjStatus, ReviewStatus } from '../../entities/project'; -import { updateProjectListing } from './syncProjectsRequiredForListing'; - -// eslint-disable-next-line @typescript-eslint/no-var-requires -const moment = require('moment'); +} from '../../../test/testUtils.js'; +import { Project, ProjStatus, ReviewStatus } from '../../entities/project.js'; +import { updateProjectListing } from './syncProjectsRequiredForListing.js'; describe('updateProjectListing() test cases', updateProjectListingTestCases); @@ -16,8 +14,8 @@ function updateProjectListingTestCases() { const projectData = createProjectData(); projectData.listed = undefined; projectData.reviewStatus = ReviewStatus.NotReviewed; - projectData.creationDate = moment().subtract(23, 'days'); - projectData.updatedAt = moment().subtract(23, 'days'); + projectData.creationDate = moment().subtract(23, 'days').toDate(); + projectData.updatedAt = moment().subtract(23, 'days').toDate(); const project = await saveProjectDirectlyToDb(projectData); await updateProjectListing(); @@ -30,7 +28,7 @@ function updateProjectListingTestCases() { const projectData = createProjectData(); projectData.listed = undefined; projectData.reviewStatus = ReviewStatus.NotReviewed; - projectData.creationDate = moment().subtract(12, 'days'); + projectData.creationDate = moment().subtract(12, 'days').toDate(); const project = await saveProjectDirectlyToDb(projectData); await updateProjectListing(); @@ -43,7 +41,7 @@ function updateProjectListingTestCases() { const projectData = createProjectData(); projectData.listed = undefined; projectData.reviewStatus = ReviewStatus.NotReviewed; - projectData.creationDate = moment().subtract(12, 'days'); + projectData.creationDate = moment().subtract(12, 'days').toDate(); projectData.statusId = ProjStatus.drafted; const project = await saveProjectDirectlyToDb(projectData); diff --git a/src/services/cronJobs/syncProjectsRequiredForListing.ts b/src/services/cronJobs/syncProjectsRequiredForListing.ts index b72127144..449c4034b 100644 --- a/src/services/cronJobs/syncProjectsRequiredForListing.ts +++ b/src/services/cronJobs/syncProjectsRequiredForListing.ts @@ -1,10 +1,10 @@ import { schedule } from 'node-cron'; -import { Project } from '../../entities/project'; +import { Project } from '../../entities/project.js'; -import config from '../../config'; -import { logger } from '../../utils/logger'; -import { getNotificationAdapter } from '../../adapters/adaptersFactory'; -import { makeProjectListed } from '../../repositories/projectRepository'; +import config from '../../config.js'; +import { logger } from '../../utils/logger.js'; +import { getNotificationAdapter } from '../../adapters/adaptersFactory.js'; +import { makeProjectListed } from '../../repositories/projectRepository.js'; const cronJobTime = (config.get('MAKE_UNREVIEWED_PROJECT_LISTED_CRONJOB_EXPRESSION') as string) || diff --git a/src/services/cronJobs/syncRecurringDonationsWithNetwork.ts b/src/services/cronJobs/syncRecurringDonationsWithNetwork.ts index 44d0d6cac..f92a8b0e8 100644 --- a/src/services/cronJobs/syncRecurringDonationsWithNetwork.ts +++ b/src/services/cronJobs/syncRecurringDonationsWithNetwork.ts @@ -1,10 +1,10 @@ import { schedule } from 'node-cron'; import Bull from 'bull'; -import config from '../../config'; -import { redisConfig } from '../../redis'; -import { logger } from '../../utils/logger'; -import { getPendingRecurringDonationsIds } from '../../repositories/recurringDonationRepository'; -import { updateRecurringDonationStatusWithNetwork } from '../recurringDonationService'; +import config from '../../config.js'; +import { redisConfig } from '../../redis.js'; +import { logger } from '../../utils/logger.js'; +import { getPendingRecurringDonationsIds } from '../../repositories/recurringDonationRepository.js'; +import { updateRecurringDonationStatusWithNetwork } from '../recurringDonationService.js'; const verifyRecurringDonationsQueue = new Bull( 'verify-recurring-donations-queue', diff --git a/src/services/cronJobs/updatePowerRoundJob.ts b/src/services/cronJobs/updatePowerRoundJob.ts index d36f94c5d..b7572b31e 100644 --- a/src/services/cronJobs/updatePowerRoundJob.ts +++ b/src/services/cronJobs/updatePowerRoundJob.ts @@ -1,24 +1,24 @@ import { schedule } from 'node-cron'; -import config from '../../config'; -import { logger } from '../../utils/logger'; +import config from '../../config.js'; +import { logger } from '../../utils/logger.js'; import { getPowerRound, setPowerRound, -} from '../../repositories/powerRoundRepository'; -import { getRoundNumberByDate } from '../../utils/powerBoostingUtils'; +} from '../../repositories/powerRoundRepository.js'; +import { getRoundNumberByDate } from '../../utils/powerBoostingUtils.js'; import { refreshProjectPowerView, refreshProjectFuturePowerView, getBottomRank, -} from '../../repositories/projectPowerViewRepository'; -import { refreshUserProjectPowerView } from '../../repositories/userProjectPowerViewRepository'; +} from '../../repositories/projectPowerViewRepository.js'; +import { refreshUserProjectPowerView } from '../../repositories/userProjectPowerViewRepository.js'; import { copyProjectRanksToPreviousRoundRankTable, projectsThatTheirRanksHaveChanged, -} from '../../repositories/previousRoundRankRepository'; -import { getNotificationAdapter } from '../../adapters/adaptersFactory'; -import { sleep } from '../../utils/utils'; -import { fillIncompletePowerSnapshots } from '../powerSnapshotServices'; +} from '../../repositories/previousRoundRankRepository.js'; +import { getNotificationAdapter } from '../../adapters/adaptersFactory.js'; +import { sleep } from '../../utils/utils.js'; +import { fillIncompletePowerSnapshots } from '../powerSnapshotServices.js'; const cronJobTime = (config.get('UPDATE_POWER_ROUND_CRONJOB_EXPRESSION') as string) || diff --git a/src/services/cronJobs/updateProjectCampaignsCacheJob.ts b/src/services/cronJobs/updateProjectCampaignsCacheJob.ts index a69e4bfe8..eb79baf49 100644 --- a/src/services/cronJobs/updateProjectCampaignsCacheJob.ts +++ b/src/services/cronJobs/updateProjectCampaignsCacheJob.ts @@ -1,7 +1,7 @@ import { schedule } from 'node-cron'; -import config from '../../config'; -import { logger } from '../../utils/logger'; -import { cacheProjectCampaigns } from '../campaignService'; +import config from '../../config.js'; +import { logger } from '../../utils/logger.js'; +import { cacheProjectCampaigns } from '../campaignService.js'; // every 10 minutes const cronJobTime = diff --git a/src/services/cronJobs/updateStreamOldRecurringDonationsJob.ts b/src/services/cronJobs/updateStreamOldRecurringDonationsJob.ts index 38b7ce628..4c9348294 100644 --- a/src/services/cronJobs/updateStreamOldRecurringDonationsJob.ts +++ b/src/services/cronJobs/updateStreamOldRecurringDonationsJob.ts @@ -1,10 +1,10 @@ import { schedule } from 'node-cron'; -import config from '../../config'; -import { logger } from '../../utils/logger'; +import config from '../../config.js'; +import { logger } from '../../utils/logger.js'; import { processRecurringDonationStreamJobs, updateRecurringDonationsStream, -} from '../recurringDonationStreamQueue'; +} from '../recurringDonationStreamQueue.js'; const cronJobTime = (config.get('UPDATE_RECURRING_DONATIONS_STREAM_CRONJOB') as string) || diff --git a/src/services/donationService.test.ts b/src/services/donationService.tes.ts similarity index 98% rename from src/services/donationService.test.ts rename to src/services/donationService.tes.ts index 792063aa3..c3e63e275 100644 --- a/src/services/donationService.test.ts +++ b/src/services/donationService.tes.ts @@ -1,4 +1,5 @@ import { assert, expect } from 'chai'; +// @ts-expect-error as d import { CHAIN_ID } from '@giveth/monoswap/dist/src/sdk/sdkFactory'; import moment from 'moment'; import { @@ -7,8 +8,8 @@ import { syncDonationStatusWithBlockchainNetwork, updateDonationPricesAndValues, insertDonationsFromQfRoundHistory, -} from './donationService'; -import { NETWORK_IDS } from '../provider'; +} from './donationService.js'; +import { NETWORK_IDS } from '../provider.js'; import { createDonationData, createProjectData, @@ -18,24 +19,24 @@ import { saveProjectDirectlyToDb, saveUserDirectlyToDb, SEED_DATA, -} from '../../test/testUtils'; -import { Token } from '../entities/token'; -import { ORGANIZATION_LABELS } from '../entities/organization'; -import { Project } from '../entities/project'; -import { Donation, DONATION_STATUS } from '../entities/donation'; -import { errorMessages } from '../utils/errorMessages'; -import { findDonationById } from '../repositories/donationRepository'; -import { findProjectById } from '../repositories/projectRepository'; -import { findUserByWalletAddress } from '../repositories/userRepository'; -import { QfRound } from '../entities/qfRound'; +} from '../../test/testUtils.js'; +import { Token } from '../entities/token.js'; +import { ORGANIZATION_LABELS } from '../entities/organization.js'; +import { Project } from '../entities/project.js'; +import { Donation, DONATION_STATUS } from '../entities/donation.js'; +import { errorMessages } from '../utils/errorMessages.js'; +import { findDonationById } from '../repositories/donationRepository.js'; +import { findProjectById } from '../repositories/projectRepository.js'; +import { findUserByWalletAddress } from '../repositories/userRepository.js'; +import { QfRound } from '../entities/qfRound.js'; import { fillQfRoundHistory, getQfRoundHistoriesThatDontHaveRelatedDonations, getQfRoundHistory, -} from '../repositories/qfRoundHistoryRepository'; -import { User } from '../entities/user'; -import { QfRoundHistory } from '../entities/qfRoundHistory'; -import { updateProjectStatistics } from './projectService'; +} from '../repositories/qfRoundHistoryRepository.js'; +import { User } from '../entities/user.js'; +import { QfRoundHistory } from '../entities/qfRoundHistory.js'; +import { updateProjectStatistics } from './projectService.js'; describe('isProjectAcceptToken test cases', isProjectAcceptTokenTestCases); describe( diff --git a/src/services/donationService.ts b/src/services/donationService.ts index 29c66c20b..f3186c56a 100644 --- a/src/services/donationService.ts +++ b/src/services/donationService.ts @@ -1,46 +1,46 @@ import { getTokenPrices } from '@giveth/monoswap'; -import { Project } from '../entities/project'; -import { Token } from '../entities/token'; -import { Donation, DONATION_STATUS } from '../entities/donation'; -import { TransakOrder } from './transak/order'; -import { logger } from '../utils/logger'; +import { Project } from '../entities/project.js'; +import { Token } from '../entities/token.js'; +import { Donation, DONATION_STATUS } from '../entities/donation.js'; +import { TransakOrder } from './transak/order.js'; +import { logger } from '../utils/logger.js'; import { findUserById, findUserByWalletAddress, -} from '../repositories/userRepository'; +} from '../repositories/userRepository.js'; import { errorMessages, i18n, translationErrorMessagesKeys, -} from '../utils/errorMessages'; -import { findProjectById } from '../repositories/projectRepository'; -import { convertExponentialNumber } from '../utils/utils'; +} from '../utils/errorMessages.js'; +import { findProjectById } from '../repositories/projectRepository.js'; +import { convertExponentialNumber } from '../utils/utils.js'; import { findDonationById, findDonationsByProjectIdWhichUseDonationBox, -} from '../repositories/donationRepository'; +} from '../repositories/donationRepository.js'; import { getChainvineAdapter, getNotificationAdapter, -} from '../adapters/adaptersFactory'; -import { calculateGivbackFactor } from './givbackService'; -import SentryLogger from '../sentryLogger'; +} from '../adapters/adaptersFactory.js'; +import { calculateGivbackFactor } from './givbackService.js'; +import SentryLogger from '../sentryLogger.js'; import { getUserDonationStats, updateUserTotalDonated, updateUserTotalReceived, -} from './userService'; -import { refreshProjectEstimatedMatchingView } from './projectViewsService'; -import { AppDataSource } from '../orm'; -import { getQfRoundHistoriesThatDontHaveRelatedDonations } from '../repositories/qfRoundHistoryRepository'; -import { getPowerRound } from '../repositories/powerRoundRepository'; -import { fetchSafeTransactionHash } from './safeServices'; -import { NETWORKS_IDS_TO_NAME } from '../provider'; -import { getTransactionInfoFromNetwork } from './chains'; -import { getEvmTransactionTimestamp } from './chains/evm/transactionService'; -import { getOrttoPersonAttributes } from '../adapters/notifications/NotificationCenterAdapter'; -import { CustomToken, getTokenPrice } from './priceService'; -import { updateProjectStatistics } from './projectService'; +} from './userService.js'; +import { refreshProjectEstimatedMatchingView } from './projectViewsService.js'; +import { AppDataSource } from '../orm.js'; +import { getQfRoundHistoriesThatDontHaveRelatedDonations } from '../repositories/qfRoundHistoryRepository.js'; +import { getPowerRound } from '../repositories/powerRoundRepository.js'; +import { fetchSafeTransactionHash } from './safeServices.js'; +import { NETWORKS_IDS_TO_NAME } from '../provider.js'; +import { getTransactionInfoFromNetwork } from './chains/index.js'; +import { getEvmTransactionTimestamp } from './chains/evm/transactionService.js'; +import { getOrttoPersonAttributes } from '../adapters/notifications/NotificationCenterAdapter.js'; +import { CustomToken, getTokenPrice } from './priceService.js'; +import { updateProjectStatistics } from './projectService.js'; export const TRANSAK_COMPLETED_STATUS = 'COMPLETED'; @@ -313,6 +313,7 @@ export const syncDonationStatusWithBlockchainNetwork = async (params: { donationId: donation.id, }), ); + // @ts-expect-error migrate to esm await getChainvineAdapter().notifyChainVine({ fromWalletAddress: donation.fromWalletAddress, amount: donation.amount, diff --git a/src/services/givbackService.ts b/src/services/givbackService.ts index f94db6f1a..95e55d926 100644 --- a/src/services/givbackService.ts +++ b/src/services/givbackService.ts @@ -1,8 +1,8 @@ import { findProjectPowerViewByProjectId, getBottomRank, -} from '../repositories/projectPowerViewRepository'; -import { getPowerRound } from '../repositories/powerRoundRepository'; +} from '../repositories/projectPowerViewRepository.js'; +import { getPowerRound } from '../repositories/powerRoundRepository.js'; export const calculateGivbackFactor = async ( projectId: number, diff --git a/src/services/googleSheets.ts b/src/services/googleSheets.ts index a888a32b6..00e065225 100644 --- a/src/services/googleSheets.ts +++ b/src/services/googleSheets.ts @@ -1,34 +1,33 @@ -import { GoogleSpreadsheet } from 'google-spreadsheet'; -import config from '../config'; -import { logger } from '../utils/logger'; -import { ReviewStatus } from '../entities/project'; +// import { GoogleSpreadsheet } from 'google-spreadsheet'; +// import moment from 'moment'; +// import config from '../config.js'; +// import { logger } from '../utils/logger.js'; +// import { ReviewStatus } from '../entities/project.js'; + +// interface ProjectExport { +// id: number; +// title: string; +// slug?: string | null; +// adminUserId?: number | null; +// creationDate: Date; +// updatedAt: Date; +// impactLocation?: string | null; +// walletAddress?: string | null; +// statusId: number; +// qualityScore: number; +// verified: boolean; +// listed: boolean; +// reviewStatus: ReviewStatus; +// totalDonations: number; +// totalProjectUpdates: number; +// website: string; +// email: string; +// firstWalletAddress: string; +// firstWalletAddressNetwork: string; +// secondWalletAddress: string; +// secondWalletAddressNetwork: string; +// } -// eslint-disable-next-line @typescript-eslint/no-var-requires -const moment = require('moment'); - -interface ProjectExport { - id: number; - title: string; - slug?: string | null; - adminUserId?: number | null; - creationDate: Date; - updatedAt: Date; - impactLocation?: string | null; - walletAddress?: string | null; - statusId: number; - qualityScore: number; - verified: boolean; - listed: boolean; - reviewStatus: ReviewStatus; - totalDonations: number; - totalProjectUpdates: number; - website: string; - email: string; - firstWalletAddress: string; - firstWalletAddressNetwork: string; - secondWalletAddress: string; - secondWalletAddressNetwork: string; -} export interface QfRoundDonationRow { projectName: string; // Pattern is networkId-projectAddress,... Example: 1-0x123...456,10,ETH,0x123...456 @@ -51,157 +50,157 @@ export interface QfRoundDonationRow { projectOwnerEmail?: string; } -interface DonationExport { - id: number; - transactionId: string; - transactionNetworkId: number; - isProjectVerified: boolean; - status: string; - toWalletAddress: string; - fromWalletAddress: string; - tokenAddress: string; - currency: string; - anonymous: boolean; - amount: number; - isFiat: boolean; - isCustomToken: boolean; - valueEth: number; - valueUsd: number; - priceEth: number; - priceUsd: number; - projectId: string | number; - userId: string | number; - contactEmail: string; - createdAt: string; - referrerWallet: string | null; - isTokenEligibleForGivback: boolean; -} - -export const initExportSpreadsheet = async (): Promise< - typeof GoogleSpreadsheet -> => { - // Initialize the sheet - document ID is the long id in the sheets URL - const spreadSheet = new GoogleSpreadsheet( - config.get('GOOGLE_PROJECT_EXPORTS_SPREADSHEET_ID'), - ); - - // Initialize Auth - see https://theoephraim.github.io/node-google-spreadsheet/#/getting-started/authentication - await spreadSheet.useServiceAccountAuth({ - // env var values are copied from service account credentials generated by google - // see "Authentication" section in docs for more info - client_email: config.get('GOOGLE_SPREADSHEETS_CLIENT_EMAIL'), - private_key: config.get('GOOGLE_SPREADSHEETS_PRIVATE_KEY'), - }); - - return spreadSheet; -}; - -const initQfRoundDonationsSpreadsheet = async (): Promise< - typeof GoogleSpreadsheet -> => { - // Initialize the sheet - document ID is the long id in the sheets URL - const spreadSheet = new GoogleSpreadsheet( - config.get('QF_ROUND_DONATIONS_GOOGLE_SPREADSHEET_ID'), - ); - - // Initialize Auth - see https://theoephraim.github.io/node-google-spreadsheet/#/getting-started/authentication - await spreadSheet.useServiceAccountAuth({ - // env var values are copied from service account credentials generated by google - // see "Authentication" section in docs for more info - client_email: config.get('QF_ROUND_GOOGLE_SPREADSHEETS_CLIENT_EMAIL'), - private_key: config.get('QF_ROUND_GOOGLE_SPREADSHEETS_PRIVATE_KEY'), - }); - - return spreadSheet; -}; - -export const addDonationsSheetToSpreadsheet = async ( - spreadSheet: GoogleSpreadsheet, - headers: string[], - rows: DonationExport[], -): Promise => { - try { - const currentDate = moment().toDate(); - - const sheet = await spreadSheet.addSheet({ - headerValues: headers, - title: `Donations ${currentDate.toDateString()} ${currentDate.getTime()}`, - }); - await sheet.addRows(rows); - } catch (e) { - logger.error('addDonationsSheetToSpreadsheet error', e); - throw e; - } -}; - -export const addProjectsSheetToSpreadsheet = async ( - spreadSheet: GoogleSpreadsheet, - headers: string[], - rows: ProjectExport[], -): Promise => { - try { - const currentDate = moment().toDate(); - - const sheet = await spreadSheet.addSheet({ - headerValues: headers, - title: `Projects ${currentDate.toDateString()} ${currentDate.getTime()}`, - }); - await sheet.addRows(rows); - } catch (e) { - logger.error('addProjectsSheetToSpreadsheet error', e); - throw e; - } -}; - -export const addQfRoundDonationsSheetToSpreadsheet = async (params: { - rows: QfRoundDonationRow[]; - qfRoundId: number; -}): Promise => { - try { - const spreadSheet = await initQfRoundDonationsSpreadsheet(); - const currentDate = moment().toDate(); - const headers = [ - 'projectName', - 'addresses', - 'link', - 'allUsdReceived', - 'allUsdReceivedAfterSybilsAnalysis', - 'totalDonors', - 'uniqueDonors', - 'realMatchingFund', - 'projectWeight', - 'donationIdsBeforeAnalysis', - 'donationIdsAfterAnalysis', - 'totalValuesOfUserDonationsAfterAnalysis', - 'uniqueUserIdsAfterAnalysis', - 'projectOwnerEmail', - ]; - - const { rows, qfRoundId } = params; - - const sheet = await spreadSheet.addSheet({ - headerValues: headers, - title: `QfRound -${qfRoundId} - ${currentDate.toDateString()} ${currentDate.getTime()}`, - }); - - // Modify rows to truncate cells with more than 50000 characters and add "..." - const modifiedRows = rows.map(row => { - const modifiedRow = {}; - Object.keys(row).forEach(key => { - if (typeof row[key] === 'string' && row[key].length > 50000) { - // Truncate the string to the maximum allowed length and append "..." - modifiedRow[key] = row[key].substring(0, 49990) + '...'; - } else { - modifiedRow[key] = row[key]; - } - }); - return modifiedRow; - }); - - logger.debug('addQfRoundDonationsSheetToSpreadsheet', params); - await sheet.addRows(modifiedRows); - } catch (e) { - logger.error('addQfRoundDonationsSheetToSpreadsheet error', e); - throw e; - } -}; +// interface DonationExport { +// id: number; +// transactionId: string; +// transactionNetworkId: number; +// isProjectVerified: boolean; +// status: string; +// toWalletAddress: string; +// fromWalletAddress: string; +// tokenAddress: string; +// currency: string; +// anonymous: boolean; +// amount: number; +// isFiat: boolean; +// isCustomToken: boolean; +// valueEth: number; +// valueUsd: number; +// priceEth: number; +// priceUsd: number; +// projectId: string | number; +// userId: string | number; +// contactEmail: string; +// createdAt: string; +// referrerWallet: string | null; +// isTokenEligibleForGivback: boolean; +// } + +// export const initExportSpreadsheet = async (): Promise< +// typeof GoogleSpreadsheet +// > => { +// // Initialize the sheet - document ID is the long id in the sheets URL +// const spreadSheet = new GoogleSpreadsheet( +// config.get('GOOGLE_PROJECT_EXPORTS_SPREADSHEET_ID'), +// ); +// +// // Initialize Auth - see https://theoephraim.github.io/node-google-spreadsheet/#/getting-started/authentication +// await spreadSheet.useServiceAccountAuth({ +// // env var values are copied from service account credentials generated by google +// // see "Authentication" section in docs for more info +// client_email: config.get('GOOGLE_SPREADSHEETS_CLIENT_EMAIL'), +// private_key: config.get('GOOGLE_SPREADSHEETS_PRIVATE_KEY'), +// }); +// +// return spreadSheet; +// }; + +// const initQfRoundDonationsSpreadsheet = async (): Promise< +// typeof GoogleSpreadsheet +// > => { +// // Initialize the sheet - document ID is the long id in the sheets URL +// const spreadSheet = new GoogleSpreadsheet( +// config.get('QF_ROUND_DONATIONS_GOOGLE_SPREADSHEET_ID'), +// ); +// +// // Initialize Auth - see https://theoephraim.github.io/node-google-spreadsheet/#/getting-started/authentication +// await spreadSheet.useServiceAccountAuth({ +// // env var values are copied from service account credentials generated by google +// // see "Authentication" section in docs for more info +// client_email: config.get('QF_ROUND_GOOGLE_SPREADSHEETS_CLIENT_EMAIL'), +// private_key: config.get('QF_ROUND_GOOGLE_SPREADSHEETS_PRIVATE_KEY'), +// }); +// +// return spreadSheet; +// }; + +// export const addDonationsSheetToSpreadsheet = async ( +// spreadSheet: GoogleSpreadsheet, +// headers: string[], +// rows: DonationExport[], +// ): Promise => { +// try { +// const currentDate = moment().toDate(); +// +// const sheet = await spreadSheet.addSheet({ +// headerValues: headers, +// title: `Donations ${currentDate.toDateString()} ${currentDate.getTime()}`, +// }); +// await sheet.addRows(rows); +// } catch (e) { +// logger.error('addDonationsSheetToSpreadsheet error', e); +// throw e; +// } +// }; + +// export const addProjectsSheetToSpreadsheet = async ( +// spreadSheet: GoogleSpreadsheet, +// headers: string[], +// rows: ProjectExport[], +// ): Promise => { +// try { +// const currentDate = moment().toDate(); +// +// const sheet = await spreadSheet.addSheet({ +// headerValues: headers, +// title: `Projects ${currentDate.toDateString()} ${currentDate.getTime()}`, +// }); +// await sheet.addRows(rows); +// } catch (e) { +// logger.error('addProjectsSheetToSpreadsheet error', e); +// throw e; +// } +// }; + +// export const addQfRoundDonationsSheetToSpreadsheet = async (params: { +// rows: QfRoundDonationRow[]; +// qfRoundId: number; +// }): Promise => { +// try { +// const spreadSheet = await initQfRoundDonationsSpreadsheet(); +// const currentDate = moment().toDate(); +// const headers = [ +// 'projectName', +// 'addresses', +// 'link', +// 'allUsdReceived', +// 'allUsdReceivedAfterSybilsAnalysis', +// 'totalDonors', +// 'uniqueDonors', +// 'realMatchingFund', +// 'projectWeight', +// 'donationIdsBeforeAnalysis', +// 'donationIdsAfterAnalysis', +// 'totalValuesOfUserDonationsAfterAnalysis', +// 'uniqueUserIdsAfterAnalysis', +// 'projectOwnerEmail', +// ]; +// +// const { rows, qfRoundId } = params; +// +// const sheet = await spreadSheet.addSheet({ +// headerValues: headers, +// title: `QfRound -${qfRoundId} - ${currentDate.toDateString()} ${currentDate.getTime()}`, +// }); +// +// // Modify rows to truncate cells with more than 50000 characters and add "..." +// const modifiedRows = rows.map(row => { +// const modifiedRow = {}; +// Object.keys(row).forEach(key => { +// if (typeof row[key] === 'string' && row[key].length > 50000) { +// // Truncate the string to the maximum allowed length and append "..." +// modifiedRow[key] = row[key].substring(0, 49990) + '...'; +// } else { +// modifiedRow[key] = row[key]; +// } +// }); +// return modifiedRow; +// }); +// +// logger.debug('addQfRoundDonationsSheetToSpreadsheet', params); +// await sheet.addRows(modifiedRows); +// } catch (e) { +// logger.error('addQfRoundDonationsSheetToSpreadsheet error', e); +// throw e; +// } +// }; diff --git a/src/services/instantBoostingServices.test.ts b/src/services/instantBoostingServices.test.ts index fc2d093c3..c91171ff0 100644 --- a/src/services/instantBoostingServices.test.ts +++ b/src/services/instantBoostingServices.test.ts @@ -1,15 +1,15 @@ import { expect } from 'chai'; -import { PowerBoosting } from '../entities/powerBoosting'; -import { InstantPowerBalance } from '../entities/instantPowerBalance'; -import { updateInstantPowerBalances } from './instantBoostingServices'; -import { InstantPowerFetchState } from '../entities/instantPowerFetchState'; -import { getMaxFetchedUpdatedAtTimestamp } from '../repositories/instantBoostingRepository'; -import { insertSinglePowerBoosting } from '../repositories/powerBoostingRepository'; +import { PowerBoosting } from '../entities/powerBoosting.js'; +import { InstantPowerBalance } from '../entities/instantPowerBalance.js'; +import { updateInstantPowerBalances } from './instantBoostingServices.js'; +import { InstantPowerFetchState } from '../entities/instantPowerFetchState.js'; +import { getMaxFetchedUpdatedAtTimestamp } from '../repositories/instantBoostingRepository.js'; +import { insertSinglePowerBoosting } from '../repositories/powerBoostingRepository.js'; import { createProjectData, saveProjectDirectlyToDb, saveUserDirectlyToDb, -} from '../../test/testUtils'; +} from '../../test/testUtils.js'; describe( 'updateInstancePowerBalances test cases', diff --git a/src/services/instantBoostingServices.ts b/src/services/instantBoostingServices.ts index 87463d001..23fe01755 100644 --- a/src/services/instantBoostingServices.ts +++ b/src/services/instantBoostingServices.ts @@ -1,19 +1,19 @@ -import { getPowerBalanceAggregatorAdapter } from '../adapters/adaptersFactory'; +import { getPowerBalanceAggregatorAdapter } from '../adapters/adaptersFactory.js'; import { getMaxFetchedUpdatedAtTimestamp, getUsersBoostedWithoutInstanceBalance, refreshProjectInstantPowerView, saveOrUpdateInstantPowerBalances, setMaxFetchedUpdatedAtTimestamp, -} from '../repositories/instantBoostingRepository'; -import { logger } from '../utils/logger'; -import { getBoosterUsersByWalletAddresses } from '../repositories/powerBoostingRepository'; -import { dateToTimestampMs } from '../utils/utils'; -import { InstantPowerBalance } from '../entities/instantPowerBalance'; +} from '../repositories/instantBoostingRepository.js'; +import { logger } from '../utils/logger.js'; +import { getBoosterUsersByWalletAddresses } from '../repositories/powerBoostingRepository.js'; +import { dateToTimestampMs } from '../utils/utils.js'; +import { InstantPowerBalance } from '../entities/instantPowerBalance.js'; import { BalanceResponse, IGivPowerBalanceAggregator, -} from '../types/GivPowerBalanceAggregator'; +} from '../types/GivPowerBalanceAggregator.js'; export const updateInstantBoosting = async (): Promise => { logger.debug('updateInstantBoosting() has been called'); diff --git a/src/services/mpEthPriceService.test.ts b/src/services/mpEthPriceService.test.ts index 1521f5088..9ff738bfc 100644 --- a/src/services/mpEthPriceService.test.ts +++ b/src/services/mpEthPriceService.test.ts @@ -1,5 +1,5 @@ import { assert, expect } from 'chai'; -import { fetchMpEthPrice } from './mpEthPriceService'; +import { fetchMpEthPrice } from './mpEthPriceService.js'; describe('fetchMpEthPrice test cases', fetchMpEthPriceTestCases); diff --git a/src/services/mpEthPriceService.ts b/src/services/mpEthPriceService.ts index 5c3524aa2..fb8a873de 100644 --- a/src/services/mpEthPriceService.ts +++ b/src/services/mpEthPriceService.ts @@ -1,5 +1,5 @@ import Axios from 'axios'; -import { logger } from '../utils/logger'; +import { logger } from '../utils/logger.js'; const mpEthSubgraphUrl = process.env.MPETH_GRAPHQL_PRICES_URL as string; diff --git a/src/services/onramper/donationService.ts b/src/services/onramper/donationService.ts index bc51cd8d8..e5db9b901 100644 --- a/src/services/onramper/donationService.ts +++ b/src/services/onramper/donationService.ts @@ -1,20 +1,26 @@ -import { Donation, DONATION_STATUS } from '../../entities/donation'; -import { ProjStatus } from '../../entities/project'; -import { Token } from '../../entities/token'; -import { NETWORK_IDS } from '../../provider'; -import { findProjectRecipientAddressByNetworkId } from '../../repositories/projectAddressRepository'; -import { findProjectById } from '../../repositories/projectRepository'; -import { findUserById } from '../../repositories/userRepository'; -import { i18n, translationErrorMessagesKeys } from '../../utils/errorMessages'; -import { logger } from '../../utils/logger'; -import { isTokenAcceptableForProject } from '../donationService'; -import { OnRamperFiatTransaction, OnRamperMetadata } from './fiatTransaction'; -import SentryLogger from '../../sentryLogger'; +import { Donation, DONATION_STATUS } from '../../entities/donation.js'; +import { ProjStatus } from '../../entities/project.js'; +import { Token } from '../../entities/token.js'; +import { NETWORK_IDS } from '../../provider.js'; +import { findProjectRecipientAddressByNetworkId } from '../../repositories/projectAddressRepository.js'; +import { findProjectById } from '../../repositories/projectRepository.js'; +import { findUserById } from '../../repositories/userRepository.js'; +import { + i18n, + translationErrorMessagesKeys, +} from '../../utils/errorMessages.js'; +import { logger } from '../../utils/logger.js'; +import { isTokenAcceptableForProject } from '../donationService.js'; +import { + OnRamperFiatTransaction, + OnRamperMetadata, +} from './fiatTransaction.js'; +import SentryLogger from '../../sentryLogger.js'; import { updateUserTotalDonated, updateUserTotalReceived, -} from '../userService'; -import { updateProjectStatistics } from '../projectService'; +} from '../userService.js'; +import { updateProjectStatistics } from '../projectService.js'; export const createFiatDonationFromOnramper = async ( fiatTransaction: OnRamperFiatTransaction, diff --git a/src/services/onramper/webhookHandler.test.ts b/src/services/onramper/webhookHandler.test.ts index fa59f144d..45278cd7d 100644 --- a/src/services/onramper/webhookHandler.test.ts +++ b/src/services/onramper/webhookHandler.test.ts @@ -1,7 +1,7 @@ import axios from 'axios'; import { assert } from 'chai'; -import { serverBaseAddress } from '../../../test/testUtils'; -import { Donation } from '../../entities/donation'; +import { serverBaseAddress } from '../../../test/testUtils.js'; +import { Donation } from '../../entities/donation.js'; describe('onramperWebhookHandlerTestCases', onramperWebhookHandlerTestCases); diff --git a/src/services/onramper/webhookHandler.ts b/src/services/onramper/webhookHandler.ts index b7b85a197..60c4d7666 100644 --- a/src/services/onramper/webhookHandler.ts +++ b/src/services/onramper/webhookHandler.ts @@ -1,11 +1,10 @@ -import { createFiatDonationFromOnramper } from './donationService'; +import { sha256 } from 'js-sha256'; +import { createFiatDonationFromOnramper } from './donationService.js'; // import { TransakOrder } from './order'; -import { logger } from '../../utils/logger'; -import { OnRamperFiatTransaction } from './fiatTransaction'; -import { i18n } from '../../utils/errorMessages'; +import { logger } from '../../utils/logger.js'; +import { OnRamperFiatTransaction } from './fiatTransaction.js'; +import { i18n } from '../../utils/errorMessages.js'; -// eslint-disable-next-line @typescript-eslint/no-var-requires -const sha256 = require('js-sha256'); const onramperSecret = process.env.ONRAMPER_SECRET as string; /** diff --git a/src/services/powerBoostingService.test.ts b/src/services/powerBoostingService.test.ts index d0f3bac1b..219840e75 100644 --- a/src/services/powerBoostingService.test.ts +++ b/src/services/powerBoostingService.test.ts @@ -5,12 +5,12 @@ import { saveProjectDirectlyToDb, saveUserDirectlyToDb, sleep, -} from '../../test/testUtils'; +} from '../../test/testUtils.js'; import { findUserPowerBoosting, setMultipleBoosting, -} from '../repositories/powerBoostingRepository'; -import { changeUserBoostingsAfterProjectCancelled } from './powerBoostingService'; +} from '../repositories/powerBoostingRepository.js'; +import { changeUserBoostingsAfterProjectCancelled } from './powerBoostingService.js'; describe( 'changeUserBoostingsAfterProjectCancelled', diff --git a/src/services/powerBoostingService.ts b/src/services/powerBoostingService.ts index 3b10a4145..aeea076a4 100644 --- a/src/services/powerBoostingService.ts +++ b/src/services/powerBoostingService.ts @@ -1,7 +1,7 @@ import { cancelProjectBoosting, findPowerBoostings, -} from '../repositories/powerBoostingRepository'; +} from '../repositories/powerBoostingRepository.js'; export const changeUserBoostingsAfterProjectCancelled = async (params: { projectId: number; diff --git a/src/services/powerSnapshotServices.ts b/src/services/powerSnapshotServices.ts index 800a9b0ff..5ff251e07 100644 --- a/src/services/powerSnapshotServices.ts +++ b/src/services/powerSnapshotServices.ts @@ -1,9 +1,9 @@ import { findInCompletePowerSnapShots, updatePowerSnapShots, -} from '../repositories/powerSnapshotRepository'; -import { getRoundNumberByDate } from '../utils/powerBoostingUtils'; -import { logger } from '../utils/logger'; +} from '../repositories/powerSnapshotRepository.js'; +import { getRoundNumberByDate } from '../utils/powerBoostingUtils.js'; +import { logger } from '../utils/logger.js'; export const fillIncompletePowerSnapshots = async (): Promise => { const incompletePowerSnapshots = await findInCompletePowerSnapShots(); diff --git a/src/services/priceService.ts b/src/services/priceService.ts index 81214f388..9c9637f90 100644 --- a/src/services/priceService.ts +++ b/src/services/priceService.ts @@ -1,7 +1,6 @@ -import { logger } from '../utils/logger'; -import { CryptoComparePriceAdapter } from '../adapters/price/CryptoComparePriceAdapter'; -import { CoingeckoPriceAdapter } from '../adapters/price/CoingeckoPriceAdapter'; -import { MonoswapPriceAdapter } from '../adapters/price/MonoswapPriceAdapter'; +import { logger } from '../utils/logger.js'; +import { CryptoComparePriceAdapter } from '../adapters/price/CryptoComparePriceAdapter.js'; +import { CoingeckoPriceAdapter } from '../adapters/price/CoingeckoPriceAdapter.js'; export interface CustomToken { symbol: string; @@ -18,7 +17,7 @@ export const getTokenPrice = async ( return 0; } try { - const { symbol, cryptoCompareId, isStableCoin, coingeckoId } = token; + const { cryptoCompareId, isStableCoin, coingeckoId } = token; logger.debug('getTokenPrice token', token); let priceUsd: number; if (isStableCoin) { @@ -38,10 +37,11 @@ export const getTokenPrice = async ( networkId: chainId, }); } else { - priceUsd = await new MonoswapPriceAdapter().getTokenPrice({ - symbol, - networkId: chainId, - }); + priceUsd = 0; + // priceUsd = await new MonoswapPriceAdapter().getTokenPrice({ + // symbol, + // networkId: chainId, + // }); } return Number(priceUsd || 0); } catch (error) { diff --git a/src/services/projectService.ts b/src/services/projectService.ts index 476167549..a99481aa8 100644 --- a/src/services/projectService.ts +++ b/src/services/projectService.ts @@ -1,9 +1,9 @@ -import { Project } from '../entities/project'; +import { Project } from '../entities/project.js'; import { countUniqueDonorsAndSumDonationValueUsd, getProjectQfRoundStats, -} from '../repositories/donationRepository'; -import { findActiveQfRound } from '../repositories/qfRoundRepository'; +} from '../repositories/donationRepository.js'; +import { findActiveQfRound } from '../repositories/qfRoundRepository.js'; export const getAppropriateSlug = async ( slugBase: string, diff --git a/src/services/projectUpdatesService.test.ts b/src/services/projectUpdatesService.test.ts index f83f525c6..9f0f758e6 100644 --- a/src/services/projectUpdatesService.test.ts +++ b/src/services/projectUpdatesService.test.ts @@ -3,9 +3,9 @@ import moment from 'moment'; import { createProjectData, saveProjectDirectlyToDb, -} from '../../test/testUtils'; -import { Project, ProjectUpdate } from '../entities/project'; -import { updateProjectUpdatesStatistics } from './projectUpdatesService'; +} from '../../test/testUtils.js'; +import { Project, ProjectUpdate } from '../entities/project.js'; +import { updateProjectUpdatesStatistics } from './projectUpdatesService.js'; describe( 'updateTotalProjectUpdatesOfAProject test cases', diff --git a/src/services/projectUpdatesService.ts b/src/services/projectUpdatesService.ts index 4b06ed252..93b5afbe5 100644 --- a/src/services/projectUpdatesService.ts +++ b/src/services/projectUpdatesService.ts @@ -1,6 +1,6 @@ -import { Project } from '../entities/project'; -import { ProjectUpdate } from '../entities/project'; -import { logger } from '../utils/logger'; +import { Project } from '../entities/project.js'; +import { ProjectUpdate } from '../entities/project.js'; +import { logger } from '../utils/logger.js'; export const updateProjectUpdatesStatistics = async (projectId: number) => { try { diff --git a/src/services/projectVerificationFormService.ts b/src/services/projectVerificationFormService.ts index db6c8f07a..75f3e642a 100644 --- a/src/services/projectVerificationFormService.ts +++ b/src/services/projectVerificationFormService.ts @@ -7,7 +7,7 @@ import { ProjectRegistry, ProjectVerificationForm, PersonalInfo, -} from '../entities/projectVerificationForm'; +} from '../entities/projectVerificationForm.js'; import { submitProjectVerificationStepValidator, updateProjectVerificationManagingFundsStepValidator, @@ -17,7 +17,7 @@ import { updateProjectVerificationProjectRegistryStepValidator, updateProjectVerificationTermsAndConditionsStepValidator, validateWithJoiSchema, -} from '../utils/validators/graphqlQueryValidators'; +} from '../utils/validators/graphqlQueryValidators.js'; import { findProjectVerificationFormById, updateManagingFundsOfProjectVerification, @@ -28,10 +28,10 @@ import { updateProjectVerificationLastStep, updateProjectVerificationStatus, updateTermsAndConditionsOfProjectVerification, -} from '../repositories/projectVerificationRepository'; -import { i18n, translationErrorMessagesKeys } from '../utils/errorMessages'; -import { ProjectVerificationUpdateInput } from '../resolvers/types/ProjectVerificationUpdateInput'; -import { removeUndefinedFieldsFromObject } from '../utils/utils'; +} from '../repositories/projectVerificationRepository.js'; +import { i18n, translationErrorMessagesKeys } from '../utils/errorMessages.js'; +import { ProjectVerificationUpdateInput } from '../resolvers/types/ProjectVerificationUpdateInput.js'; +import { removeUndefinedFieldsFromObject } from '../utils/utils.js'; const updateLastStep = async (params: { projectVerificationForm: ProjectVerificationForm; diff --git a/src/services/projectViewService.test.ts b/src/services/projectViewService.test.ts index 675e10668..d87867da3 100644 --- a/src/services/projectViewService.test.ts +++ b/src/services/projectViewService.test.ts @@ -3,10 +3,10 @@ import { assert } from 'chai'; import { getQfRoundActualDonationDetails, refreshProjectActualMatchingView, -} from './projectViewsService'; -import { QfRound } from '../entities/qfRound'; -import { Project } from '../entities/project'; -import { NETWORK_IDS } from '../provider'; +} from './projectViewsService.js'; +import { QfRound } from '../entities/qfRound.js'; +import { Project } from '../entities/project.js'; +import { NETWORK_IDS } from '../provider.js'; import { createDonationData, createProjectData, @@ -14,7 +14,7 @@ import { saveDonationDirectlyToDb, saveProjectDirectlyToDb, saveUserDirectlyToDb, -} from '../../test/testUtils'; +} from '../../test/testUtils.js'; describe( 'getQfRoundActualDonationDetails test cases', diff --git a/src/services/projectViewsService.ts b/src/services/projectViewsService.ts index b317e8d8c..f14829f04 100644 --- a/src/services/projectViewsService.ts +++ b/src/services/projectViewsService.ts @@ -1,8 +1,8 @@ -import { QfRound } from '../entities/qfRound'; -import { AppDataSource } from '../orm'; -import { logger } from '../utils/logger'; -import { QfRoundDonationRow } from './googleSheets'; -import { ProjectActualMatchingView } from '../entities/ProjectActualMatchingView'; +import { QfRound } from '../entities/qfRound.js'; +import { AppDataSource } from '../orm.js'; +import { logger } from '../utils/logger.js'; +import { QfRoundDonationRow } from './googleSheets.js'; +import { ProjectActualMatchingView } from '../entities/ProjectActualMatchingView.js'; let lastRefreshTimestamp: number | null = null; const refreshEstimatedMatchingCacheDuration = Number( diff --git a/src/services/qfRoundHistoryService.ts b/src/services/qfRoundHistoryService.ts index d8b7b3071..ff650ef48 100644 --- a/src/services/qfRoundHistoryService.ts +++ b/src/services/qfRoundHistoryService.ts @@ -1,4 +1,4 @@ -import { AppDataSource } from '../orm'; +import { AppDataSource } from '../orm.js'; export const getQfRoundHistoriesThatDontHaveRelatedDonations = async () => { return AppDataSource.getDataSource().query( diff --git a/src/services/qfRoundService.test.ts b/src/services/qfRoundService.test.ts index 470fd536f..bee6a078f 100644 --- a/src/services/qfRoundService.test.ts +++ b/src/services/qfRoundService.test.ts @@ -3,9 +3,9 @@ import moment from 'moment'; import { createProjectData, saveProjectDirectlyToDb, -} from '../../test/testUtils'; -import { QfRound } from '../entities/qfRound'; -import { relatedActiveQfRoundForProject } from './qfRoundService'; +} from '../../test/testUtils.js'; +import { QfRound } from '../entities/qfRound.js'; +import { relatedActiveQfRoundForProject } from './qfRoundService.js'; describe( 'relatedActiveQfRoundForProject', diff --git a/src/services/qfRoundService.ts b/src/services/qfRoundService.ts index 65e495b69..ab43178f6 100644 --- a/src/services/qfRoundService.ts +++ b/src/services/qfRoundService.ts @@ -1,5 +1,5 @@ -import { findProjectById } from '../repositories/projectRepository'; -import { QfRound } from '../entities/qfRound'; +import { findProjectById } from '../repositories/projectRepository.js'; +import { QfRound } from '../entities/qfRound.js'; export const relatedActiveQfRoundForProject = async ( projectId: number, diff --git a/src/services/reactionsService.test.ts b/src/services/reactionsService.test.ts index bc271e825..d97577daf 100644 --- a/src/services/reactionsService.test.ts +++ b/src/services/reactionsService.test.ts @@ -4,11 +4,11 @@ import { createProjectData, saveProjectDirectlyToDb, SEED_DATA, -} from '../../test/testUtils'; -import { Project } from '../entities/project'; -import { updateTotalReactionsOfAProject } from './reactionsService'; -import { Reaction } from '../entities/reaction'; -import { findProjectById } from '../repositories/projectRepository'; +} from '../../test/testUtils.js'; +import { Project } from '../entities/project.js'; +import { updateTotalReactionsOfAProject } from './reactionsService.js'; +import { Reaction } from '../entities/reaction.js'; +import { findProjectById } from '../repositories/projectRepository.js'; describe( 'updateTotalReactionsOfAProject test cases', diff --git a/src/services/reactionsService.ts b/src/services/reactionsService.ts index 64f3c71b5..ada303192 100644 --- a/src/services/reactionsService.ts +++ b/src/services/reactionsService.ts @@ -1,6 +1,6 @@ -import { Project } from '../entities/project'; -import { Reaction } from '../entities/reaction'; -import { logger } from '../utils/logger'; +import { Project } from '../entities/project.js'; +import { Reaction } from '../entities/reaction.js'; +import { logger } from '../utils/logger.js'; export const updateTotalReactionsOfAProject = async (projectId: number) => { try { diff --git a/src/services/recurringDonationService.test.ts b/src/services/recurringDonationService.test.ts index c6bd6e943..aa890f280 100644 --- a/src/services/recurringDonationService.test.ts +++ b/src/services/recurringDonationService.test.ts @@ -6,20 +6,20 @@ import { saveProjectDirectlyToDb, saveRecurringDonationDirectlyToDb, saveUserDirectlyToDb, -} from '../../test/testUtils'; +} from '../../test/testUtils.js'; import { createRelatedDonationsToStream, updateRecurringDonationStatusWithNetwork, -} from './recurringDonationService'; -import { Donation } from '../entities/donation'; -import { addNewAnchorAddress } from '../repositories/anchorContractAddressRepository'; -import { NETWORK_IDS } from '../provider'; +} from './recurringDonationService.js'; +import { Donation } from '../entities/donation.js'; +import { addNewAnchorAddress } from '../repositories/anchorContractAddressRepository.js'; +import { NETWORK_IDS } from '../provider.js'; import { RECURRING_DONATION_STATUS, RecurringDonation, -} from '../entities/recurringDonation'; -import { AnchorContractAddress } from '../entities/anchorContractAddress'; -import { findRecurringDonationById } from '../repositories/recurringDonationRepository'; +} from '../entities/recurringDonation.js'; +import { AnchorContractAddress } from '../entities/anchorContractAddress.js'; +import { findRecurringDonationById } from '../repositories/recurringDonationRepository.js'; describe( 'createRelatedDonationsToStream test cases', diff --git a/src/services/recurringDonationService.ts b/src/services/recurringDonationService.ts index 3e2d52d41..5f9c3870f 100644 --- a/src/services/recurringDonationService.ts +++ b/src/services/recurringDonationService.ts @@ -4,41 +4,44 @@ import { ethers } from 'ethers'; import { getNotificationAdapter, getSuperFluidAdapter, -} from '../adapters/adaptersFactory'; -import { Donation, DONATION_STATUS } from '../entities/donation'; +} from '../adapters/adaptersFactory.js'; +import { Donation, DONATION_STATUS } from '../entities/donation.js'; import { RECURRING_DONATION_STATUS, RecurringDonation, -} from '../entities/recurringDonation'; -import { Token } from '../entities/token'; +} from '../entities/recurringDonation.js'; +import { Token } from '../entities/token.js'; import { getNetworkNameById, getProvider, NETWORK_IDS, superTokensToToken, -} from '../provider'; -import { findProjectRecipientAddressByNetworkId } from '../repositories/projectAddressRepository'; -import { findProjectById } from '../repositories/projectRepository'; +} from '../provider.js'; +import { findProjectRecipientAddressByNetworkId } from '../repositories/projectAddressRepository.js'; +import { findProjectById } from '../repositories/projectRepository.js'; import { findRecurringDonationById, updateRecurringDonationFromTheStreamDonations, -} from '../repositories/recurringDonationRepository'; -import { findUserById } from '../repositories/userRepository'; -import { ChainType } from '../types/network'; -import { i18n, translationErrorMessagesKeys } from '../utils/errorMessages'; -import { logger } from '../utils/logger'; +} from '../repositories/recurringDonationRepository.js'; +import { findUserById } from '../repositories/userRepository.js'; +import { ChainType } from '../types/network.js'; +import { i18n, translationErrorMessagesKeys } from '../utils/errorMessages.js'; +import { logger } from '../utils/logger.js'; import { isTokenAcceptableForProject, updateDonationPricesAndValues, -} from './donationService'; -import { calculateGivbackFactor } from './givbackService'; -import { updateUserTotalDonated, updateUserTotalReceived } from './userService'; -import config from '../config'; -import { User } from '../entities/user'; -import { NOTIFICATIONS_EVENT_NAMES } from '../analytics/analytics'; -import { relatedActiveQfRoundForProject } from './qfRoundService'; -import { updateProjectStatistics } from './projectService'; -import { ResourcesTotalPerMonthAndYear } from '../resolvers/donationResolver'; +} from './donationService.js'; +import { calculateGivbackFactor } from './givbackService.js'; +import { + updateUserTotalDonated, + updateUserTotalReceived, +} from './userService.js'; +import config from '../config.js'; +import { User } from '../entities/user.js'; +import { NOTIFICATIONS_EVENT_NAMES } from '../analytics/analytics.js'; +import { relatedActiveQfRoundForProject } from './qfRoundService.js'; +import { updateProjectStatistics } from './projectService.js'; +import { ResourcesTotalPerMonthAndYear } from '../resolvers/donationResolver.js'; // Initially it will only be monthly data export const priceDisplay = 'month'; diff --git a/src/services/recurringDonationStreamQueue.ts b/src/services/recurringDonationStreamQueue.ts index 4df0e13f9..beca8a4a9 100644 --- a/src/services/recurringDonationStreamQueue.ts +++ b/src/services/recurringDonationStreamQueue.ts @@ -1,13 +1,13 @@ import Bull from 'bull'; -import { logger } from '../utils/logger'; +import { logger } from '../utils/logger.js'; import { findActiveRecurringDonations, findRecurringDonationById, -} from '../repositories/recurringDonationRepository'; -import { redisConfig } from '../redis'; -import config from '../config'; -import { getCurrentDateFormatted } from '../utils/utils'; -import { createRelatedDonationsToStream } from './recurringDonationService'; +} from '../repositories/recurringDonationRepository.js'; +import { redisConfig } from '../redis.js'; +import config from '../config.js'; +import { getCurrentDateFormatted } from '../utils/utils.js'; +import { createRelatedDonationsToStream } from './recurringDonationService.js'; const updateRecurringDonationsStreamQueue = new Bull( 'update-recurring-donations-stream-queue', diff --git a/src/services/safeServices.ts b/src/services/safeServices.ts index 16b60bfb0..42fe36656 100644 --- a/src/services/safeServices.ts +++ b/src/services/safeServices.ts @@ -1,5 +1,5 @@ import SafeApiKit from '@safe-global/api-kit'; -import { logger } from '../utils/logger'; +import { logger } from '../utils/logger.js'; export const fetchSafeTransactionHash = async ( safeMessageHash: string, @@ -7,6 +7,7 @@ export const fetchSafeTransactionHash = async ( ) => { let safeTransactionHash; try { + // @ts-expect-error as d const safeService = new SafeApiKit({ chainId: BigInt(networkId), }); diff --git a/src/services/socialProfileService.ts b/src/services/socialProfileService.ts index 3c781b71a..3f2e0fe21 100644 --- a/src/services/socialProfileService.ts +++ b/src/services/socialProfileService.ts @@ -1,17 +1,17 @@ -import { getSocialNetworkAdapter } from '../adapters/adaptersFactory'; +import { getSocialNetworkAdapter } from '../adapters/adaptersFactory.js'; import { createSocialProfile, isSocialNetworkAddedToVerificationForm, -} from '../repositories/socialProfileRepository'; -import { i18n, translationErrorMessagesKeys } from '../utils/errorMessages'; -import { SocialProfile } from '../entities/socialProfile'; -import { generateRandomString } from '../utils/utils'; -import { getRedisObject, setObjectInRedis } from '../redis'; -import { findProjectVerificationFormById } from '../repositories/projectVerificationRepository'; +} from '../repositories/socialProfileRepository.js'; +import { i18n, translationErrorMessagesKeys } from '../utils/errorMessages.js'; +import { SocialProfile } from '../entities/socialProfile.js'; +import { generateRandomString } from '../utils/utils.js'; +import { getRedisObject, setObjectInRedis } from '../redis.js'; +import { findProjectVerificationFormById } from '../repositories/projectVerificationRepository.js'; import { PROJECT_VERIFICATION_STATUSES, ProjectVerificationForm, -} from '../entities/projectVerificationForm'; +} from '../entities/projectVerificationForm.js'; export const getProjectVerificationFormByState = async (params: { state: string; diff --git a/src/services/the-giving-blocks/api.ts b/src/services/the-giving-blocks/api.ts new file mode 100644 index 000000000..e69de29bb diff --git a/src/services/the-giving-blocks/syncProjectsCronJob.ts b/src/services/the-giving-blocks/syncProjectsCronJob.ts new file mode 100644 index 000000000..e69de29bb diff --git a/src/services/transak/webhookHandler.ts b/src/services/transak/webhookHandler.ts index 9a7efc1a2..6f389b8e2 100644 --- a/src/services/transak/webhookHandler.ts +++ b/src/services/transak/webhookHandler.ts @@ -1,7 +1,7 @@ import { verify } from 'jsonwebtoken'; -import { updateDonationByTransakData } from '../donationService'; -import { TransakOrder } from './order'; -import { logger } from '../../utils/logger'; +import { updateDonationByTransakData } from '../donationService.js'; +import { TransakOrder } from './order.js'; +import { logger } from '../../utils/logger.js'; /** * Returns status 200 always, most providers require this or they will keep sending requests indefinitely diff --git a/src/services/userService.test.ts b/src/services/userService.test.ts index 8780f7ad5..ef3c11162 100644 --- a/src/services/userService.test.ts +++ b/src/services/userService.test.ts @@ -1,7 +1,8 @@ import { assert } from 'chai'; import 'mocha'; -import { User, UserRole } from '../entities/user'; -import { DONATION_STATUS } from '../entities/donation'; +import bcrypt from 'bcrypt'; +import { User, UserRole } from '../entities/user.js'; +import { DONATION_STATUS } from '../entities/donation.js'; import { createDonationData, createProjectData, @@ -9,17 +10,15 @@ import { saveDonationDirectlyToDb, saveProjectDirectlyToDb, saveUserDirectlyToDb, -} from '../../test/testUtils'; +} from '../../test/testUtils.js'; import { fetchAdminAndValidatePassword, updateUserTotalDonated, updateUserTotalReceived, -} from './userService'; -import { ORGANIZATION_LABELS } from '../entities/organization'; -import { generateRandomString } from '../utils/utils'; -import { findUserById } from '../repositories/userRepository'; -// eslint-disable-next-line @typescript-eslint/no-var-requires -const bcrypt = require('bcrypt'); +} from './userService.js'; +import { ORGANIZATION_LABELS } from '../entities/organization.js'; +import { generateRandomString } from '../utils/utils.js'; +import { findUserById } from '../repositories/userRepository.js'; describe( 'updateUserTotalDonated() test cases', diff --git a/src/services/userService.ts b/src/services/userService.ts index b8915aef1..719d3a0fe 100644 --- a/src/services/userService.ts +++ b/src/services/userService.ts @@ -1,9 +1,8 @@ -import { User } from '../entities/user'; -import { Donation } from '../entities/donation'; -import { logger } from '../utils/logger'; -import { findAdminUserByEmail } from '../repositories/userRepository'; -// eslint-disable-next-line @typescript-eslint/no-var-requires -const bcrypt = require('bcrypt'); +import bcrypt from 'bcrypt'; +import { User } from '../entities/user.js'; +import { Donation } from '../entities/donation.js'; +import { logger } from '../utils/logger.js'; +import { findAdminUserByEmail } from '../repositories/userRepository.js'; export const updateUserTotalDonated = async (userId: number) => { try { diff --git a/src/test.ts b/src/test.ts new file mode 100644 index 000000000..6356bc5c7 --- /dev/null +++ b/src/test.ts @@ -0,0 +1,28 @@ +import { fileURLToPath } from 'url'; +import path from 'path'; +import dotenv from 'dotenv'; +import config from './config.js'; +import { Project } from './entities/project.js'; +import { AppDataSource } from './orm.js'; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); + +const configPath = path.resolve( + __dirname, + `../config/${process.env.NODE_ENV || ''}.env`, +); +dotenv.config({ + path: configPath, +}); + +const fun = async () => { + await AppDataSource.initialize(); + const pa = await Project.findOneBy({ id: 1 }); + const p = process.env.TYPEORM_DATABASE_NAME; + const a = config.get('TYPEORM_DATABASE_NAME'); + // eslint-disable-next-line no-console + console.log(p, a, pa); +}; + +await fun(); diff --git a/src/types/ApolloContext.ts b/src/types/ApolloContext.ts index ac886ea22..b08a66364 100644 --- a/src/types/ApolloContext.ts +++ b/src/types/ApolloContext.ts @@ -1,6 +1,7 @@ import { Pool, ModuleThread } from 'threads'; -import { ProjectResolverWorker } from '../workers/projectsResolverWorker'; -import { JwtVerifiedUser } from '../services/authorizationServices'; +// @ts-expect-error migrate to ESM +import { ProjectResolverWorker } from '../workers/projectsResolverWorker.js'; +import { JwtVerifiedUser } from '../services/authorizationServices.js'; export interface AuthContextRequest { token?: string; @@ -14,5 +15,5 @@ export interface ContextRequest { export interface ApolloContext { req: ContextRequest; - projectsFiltersThreadPool: Pool>; + projectsFiltersThreadPool?: Pool>; } diff --git a/src/user/LoginResolver.ts b/src/user/LoginResolver.ts new file mode 100644 index 000000000..e69de29bb diff --git a/src/user/MeResolver.ts b/src/user/MeResolver.ts index c31d2c16f..e23392724 100644 --- a/src/user/MeResolver.ts +++ b/src/user/MeResolver.ts @@ -1,11 +1,11 @@ import { Resolver, Query, Ctx, Authorized } from 'type-graphql'; import { Repository } from 'typeorm'; -import { User } from '../entities/user'; -import { Project } from '../entities/project'; -import { ApolloContext } from '../types/ApolloContext'; -import { getLoggedInUser } from '../services/authorizationServices'; -import { AppDataSource } from '../orm'; +import { User } from '../entities/user.js'; +import { Project } from '../entities/project.js'; +import { ApolloContext } from '../types/ApolloContext.js'; +import { getLoggedInUser } from '../services/authorizationServices.js'; +import { AppDataSource } from '../orm.js'; @Resolver() export class MeResolver { diff --git a/src/user/register/RegisterResolver.ts b/src/user/register/RegisterResolver.ts new file mode 100644 index 000000000..e69de29bb diff --git a/src/utils/documents.ts b/src/utils/documents.ts index 9e3db531d..60b9a2890 100644 --- a/src/utils/documents.ts +++ b/src/utils/documents.ts @@ -1,37 +1,4 @@ -import HTMLToPDF from 'html-pdf-node'; -import { pinFileDataBase64 } from '../middleware/pinataUtils'; - -// eslint-disable-next-line @typescript-eslint/no-var-requires -const path = require('path'); -// eslint-disable-next-line @typescript-eslint/no-var-requires -const fs = require('fs'); -// eslint-disable-next-line @typescript-eslint/no-var-requires -const util = require('util'); -// eslint-disable-next-line @typescript-eslint/no-var-requires -const Handlebars = require('handlebars'); - -const readFile = util.promisify(fs.readFile); - -export async function generateHTMLDocument(name: string, data: any) { - const raw = await readFile( - path.join(__dirname, '../docs/html/' + name + '.html'), - 'utf-8', - ); - - return Handlebars.compile(raw)(data); -} - -export async function generatePDFDocument( - name: string, - data: any, -): Promise { - const html = await generateHTMLDocument(name, data); - const buf = await HTMLToPDF.generatePdf({ content: html }, { format: 'A4' }); - - // fs.writeFileSync("test.pdf", buf) - - return buf.toString('base64'); -} +import { pinFileDataBase64 } from '../middleware/pinataUtils.js'; export async function changeBase64ToIpfsImageInHTML( html: string, diff --git a/src/utils/errorMessages.ts b/src/utils/errorMessages.ts index 31e835498..55623c723 100644 --- a/src/utils/errorMessages.ts +++ b/src/utils/errorMessages.ts @@ -1,8 +1,11 @@ import path from 'path'; +import { fileURLToPath } from 'url'; +import _i18n from 'i18n'; -// eslint-disable-next-line @typescript-eslint/no-var-requires -export const i18n = require('i18n'); +export const i18n = _i18n; +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); // global config, where ever its exported i18n.configure({ locales: ['en', 'es'], diff --git a/src/utils/logger.ts b/src/utils/logger.ts index ed3e6fa79..d7dea8d6b 100644 --- a/src/utils/logger.ts +++ b/src/utils/logger.ts @@ -1,6 +1,5 @@ +import RotatingFileStream from 'bunyan-rotating-file-stream'; import { createLogger, levelFromName, DEBUG } from 'bunyan'; -// eslint-disable-next-line @typescript-eslint/no-var-requires -const RotatingFileStream = require('bunyan-rotating-file-stream'); function createBunyanLogger() { const logDir = process.env.LOG_PATH || './logs/impact-graph.log'; diff --git a/src/utils/networks.test.ts b/src/utils/networks.test.ts index 17693c18b..5960daf28 100644 --- a/src/utils/networks.test.ts +++ b/src/utils/networks.test.ts @@ -1,6 +1,6 @@ import { assert } from 'chai'; -import { detectAddressChainType } from './networks'; -import { ChainType } from '../types/network'; +import { detectAddressChainType } from './networks.js'; +import { ChainType } from '../types/network.js'; describe('networks - ' + detectAddressChainType.name, () => { it('detect solana address - 1', () => { diff --git a/src/utils/networks.ts b/src/utils/networks.ts index 53f26a561..4f86692ee 100644 --- a/src/utils/networks.ts +++ b/src/utils/networks.ts @@ -1,7 +1,7 @@ import { ethers } from 'ethers'; import { PublicKey } from '@solana/web3.js'; -import { ChainType } from '../types/network'; -import networksConfig from './networksConfig'; +import { ChainType } from '../types/network.js'; +import networksConfig from './networksConfig.js'; export const SOLANA_SYSTEM_PROGRAM = '11111111111111111111111111111111'; diff --git a/src/utils/powerBoostingUtils.ts b/src/utils/powerBoostingUtils.ts index 79a605676..a77ec2862 100644 --- a/src/utils/powerBoostingUtils.ts +++ b/src/utils/powerBoostingUtils.ts @@ -1,4 +1,4 @@ -import { getTimestampInSeconds } from './utils'; +import { getTimestampInSeconds } from './utils.js'; const firstGivbackRoundTimeStamp = Number( process.env.FIRST_GIVBACK_ROUND_TIME_STAMP, diff --git a/src/utils/qfUtils.ts b/src/utils/qfUtils.ts index a1024f0fb..b79aebe2d 100644 --- a/src/utils/qfUtils.ts +++ b/src/utils/qfUtils.ts @@ -2,7 +2,7 @@ import { findActiveQfRound, getQfRoundTotalSqrtRootSumSquared, getProjectDonationsSqrtRootSum, -} from '../repositories/qfRoundRepository'; +} from '../repositories/qfRoundRepository.js'; export const calculateEstimatedMatchingWithParams = async (params: { matchingPool: number; diff --git a/src/utils/sendEmail.ts b/src/utils/sendEmail.ts new file mode 100644 index 000000000..e69de29bb diff --git a/src/utils/stripe.ts b/src/utils/stripe.ts index 8a6ed9e4c..c61b8a711 100644 --- a/src/utils/stripe.ts +++ b/src/utils/stripe.ts @@ -1,9 +1,9 @@ import Stripe from 'stripe'; -import config from '../config'; -import { StripeTransaction } from '../entities/bankAccount'; -import { Project } from '../entities/project'; -import { logger } from './logger'; +import config from '../config.js'; +import { StripeTransaction } from '../entities/bankAccount.js'; +import { Project } from '../entities/project.js'; +import { logger } from './logger.js'; const stripe = new Stripe(config.get('STRIPE_SECRET').toString(), { apiVersion: '2020-08-27', diff --git a/src/utils/tokenUtils.ts b/src/utils/tokenUtils.ts index 35e603290..c6b7f89a4 100644 --- a/src/utils/tokenUtils.ts +++ b/src/utils/tokenUtils.ts @@ -1,5 +1,5 @@ -import { i18n, translationErrorMessagesKeys } from './errorMessages'; -import { Token } from '../entities/token'; +import { i18n, translationErrorMessagesKeys } from './errorMessages.js'; +import { Token } from '../entities/token.js'; export const findTokenByNetworkAndSymbol = async ( networkId: number, diff --git a/src/utils/utils.test.ts b/src/utils/utils.test.ts index 180e767a0..ab6596f8e 100644 --- a/src/utils/utils.test.ts +++ b/src/utils/utils.test.ts @@ -1,7 +1,7 @@ /* eslint-disable no-irregular-whitespace */ import { assert } from 'chai'; -import { getCreatedAtFromMongoObjectId, getHtmlTextSummary } from './utils'; -import { SUMMARY_LENGTH } from '../constants/summary'; +import { getCreatedAtFromMongoObjectId, getHtmlTextSummary } from './utils.js'; +import { SUMMARY_LENGTH } from '../constants/summary.js'; describe('getHtmlTextSummary test cases', getHtmlTextSummaryTestCases); describe( diff --git a/src/utils/utils.ts b/src/utils/utils.ts index 8cdc4a78e..ba6d001df 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -1,16 +1,15 @@ +import { createHash } from 'node:crypto'; import { convert } from 'html-to-text'; import slugify from 'slugify'; import stringify from 'json-stable-stringify'; -import { isEqual } from 'lodash'; -import { Country } from '../entities/Country'; -import { FilterField, SortingField } from '../entities/project'; +import { isEqual } from 'lodash-es'; +import { Country } from '../entities/Country.js'; +import { FilterField, SortingField } from '../entities/project.js'; -import { SUMMARY_LENGTH } from '../constants/summary'; -import config from '../config'; -import { ProjectSocialMedia } from '../entities/projectSocialMedia'; -import { ProjectSocialMediaInput } from '../resolvers/types/ProjectVerificationUpdateInput'; -// eslint-disable-next-line @typescript-eslint/no-var-requires -const { createHash } = require('node:crypto'); +import { SUMMARY_LENGTH } from '../constants/summary.js'; +import config from '../config.js'; +import { ProjectSocialMedia } from '../entities/projectSocialMedia.js'; +import { ProjectSocialMediaInput } from '../resolvers/types/ProjectVerificationUpdateInput.js'; export const sleep = ms => { return new Promise(resolve => setTimeout(resolve, ms)); @@ -63,6 +62,7 @@ export const titleWithoutSpecialCharacters = (title: string): string => { }; export const creteSlugFromProject = (title: string): string => { + // @ts-expect-error old package return slugify(titleWithoutSpecialCharacters(title)); }; diff --git a/src/utils/validators/commonValidators.test.ts b/src/utils/validators/commonValidators.test.ts index 87f89d4b2..614f9335a 100644 --- a/src/utils/validators/commonValidators.test.ts +++ b/src/utils/validators/commonValidators.test.ts @@ -1,5 +1,5 @@ import { assert } from 'chai'; -import { validateEmail } from './commonValidators'; +import { validateEmail } from './commonValidators.js'; describe('validateEmail() test cases', validateEmailTestCases); diff --git a/src/utils/validators/graphqlQueryValidators.ts b/src/utils/validators/graphqlQueryValidators.ts index 0d0f6f0a0..d08f13497 100644 --- a/src/utils/validators/graphqlQueryValidators.ts +++ b/src/utils/validators/graphqlQueryValidators.ts @@ -1,16 +1,14 @@ -import { ObjectSchema, ValidationResult } from 'joi'; +import Joi, { ObjectSchema, ValidationResult } from 'joi'; import { errorMessages, i18n, translationErrorMessagesKeys, -} from '../errorMessages'; -import { NETWORK_IDS } from '../../provider'; -import { DONATION_STATUS } from '../../entities/donation'; -import { PROJECT_VERIFICATION_STATUSES } from '../../entities/projectVerificationForm'; -import { countriesList } from '../utils'; -import { ChainType } from '../../types/network'; -// eslint-disable-next-line @typescript-eslint/no-var-requires -const Joi = require('joi'); +} from '../errorMessages.js'; +import { NETWORK_IDS } from '../../provider.js'; +import { DONATION_STATUS } from '../../entities/donation.js'; +import { PROJECT_VERIFICATION_STATUSES } from '../../entities/projectVerificationForm.js'; +import { countriesList } from '../utils.js'; +import { ChainType } from '../../types/network.js'; const filterDateRegex = new RegExp('^[0-9]{8} [0-9]{2}:[0-9]{2}:[0-9]{2}$'); const resourcePerDateRegex = new RegExp( diff --git a/src/utils/validators/projectValidator.test.ts b/src/utils/validators/projectValidator.test.ts index 1b541ad27..42bc1ca86 100644 --- a/src/utils/validators/projectValidator.test.ts +++ b/src/utils/validators/projectValidator.test.ts @@ -4,7 +4,7 @@ import { isWalletAddressValid, validateProjectTitle, validateProjectWalletAddress, -} from './projectValidator'; +} from './projectValidator.js'; import { assertThrowsAsync, createProjectData, @@ -12,13 +12,13 @@ import { generateRandomSolanaAddress, saveProjectDirectlyToDb, SEED_DATA, -} from '../../../test/testUtils'; +} from '../../../test/testUtils.js'; import { errorMessages, i18n, translationErrorMessagesKeys, -} from '../errorMessages'; -import { ChainType } from '../../types/network'; +} from '../errorMessages.js'; +import { ChainType } from '../../types/network.js'; describe('isWalletAddressValid() test cases', isWalletAddressValidTestCases); diff --git a/src/utils/validators/projectValidator.ts b/src/utils/validators/projectValidator.ts index 27fec6e16..38b39c07b 100644 --- a/src/utils/validators/projectValidator.ts +++ b/src/utils/validators/projectValidator.ts @@ -1,13 +1,13 @@ -import { getProvider, NETWORK_IDS } from '../../provider'; -import { Project, ProjStatus } from '../../entities/project'; -import { i18n, translationErrorMessagesKeys } from '../errorMessages'; -import { logger } from '../logger'; -import { findRelatedAddressByWalletAddress } from '../../repositories/projectAddressRepository'; -import { RelatedAddressInputType } from '../../resolvers/types/ProjectVerificationUpdateInput'; -import { findProjectById } from '../../repositories/projectRepository'; -import { titleWithoutSpecialCharacters } from '../utils'; -import { ChainType } from '../../types/network'; -import { detectAddressChainType } from '../networks'; +import { getProvider, NETWORK_IDS } from '../../provider.js'; +import { Project, ProjStatus } from '../../entities/project.js'; +import { i18n, translationErrorMessagesKeys } from '../errorMessages.js'; +import { logger } from '../logger.js'; +import { findRelatedAddressByWalletAddress } from '../../repositories/projectAddressRepository.js'; +import { RelatedAddressInputType } from '../../resolvers/types/ProjectVerificationUpdateInput.js'; +import { findProjectById } from '../../repositories/projectRepository.js'; +import { titleWithoutSpecialCharacters } from '../utils.js'; +import { ChainType } from '../../types/network.js'; +import { detectAddressChainType } from '../networks.js'; export function isWalletAddressValid(address, chainType?: ChainType) { if (!address) { diff --git a/src/views/lastSnapshotProjectPowerView.ts b/src/views/lastSnapshotProjectPowerView.ts index 426bf2797..f89713995 100644 --- a/src/views/lastSnapshotProjectPowerView.ts +++ b/src/views/lastSnapshotProjectPowerView.ts @@ -7,7 +7,7 @@ import { ViewEntity, } from 'typeorm'; import { Field, Float, Int, ObjectType } from 'type-graphql'; -import { ColumnNumericTransformer } from '../utils/entities'; +import { ColumnNumericTransformer } from '../utils/entities.js'; @ViewEntity('last_snapshot_project_power_view', { synchronize: false }) @ObjectType() diff --git a/src/views/projectFuturePowerView.ts b/src/views/projectFuturePowerView.ts index ca613506e..0cec95794 100644 --- a/src/views/projectFuturePowerView.ts +++ b/src/views/projectFuturePowerView.ts @@ -6,9 +6,10 @@ import { RelationId, BaseEntity, PrimaryColumn, + Relation, } from 'typeorm'; import { Field, Int, ObjectType } from 'type-graphql'; -import { Project } from '../entities/project'; +import { Project } from '../entities/project.js'; @ViewEntity('project_future_power_view', { synchronize: false }) @ObjectType() @@ -29,7 +30,7 @@ export class ProjectFuturePowerView extends BaseEntity { @Field(_type => Project) @OneToOne(_type => Project, project => project.projectFuturePower) @JoinColumn({ referencedColumnName: 'id' }) - project: Project; + project: Relation; @ViewColumn() @Field(_type => Int) diff --git a/src/views/projectInstantPowerView.ts b/src/views/projectInstantPowerView.ts index 7787ceff0..963751b9e 100644 --- a/src/views/projectInstantPowerView.ts +++ b/src/views/projectInstantPowerView.ts @@ -7,10 +7,11 @@ import { BaseEntity, PrimaryColumn, Column, + Relation, } from 'typeorm'; import { Field, Float, ObjectType } from 'type-graphql'; -import { Project } from '../entities/project'; -import { ColumnNumericTransformer } from '../utils/entities'; +import { Project } from '../entities/project.js'; +import { ColumnNumericTransformer } from '../utils/entities.js'; @ViewEntity('project_instant_power_view', { synchronize: false }) @ObjectType() @@ -34,7 +35,7 @@ export class ProjectInstantPowerView extends BaseEntity { @Field(_type => Project) @OneToOne(_type => Project, project => project.projectPower) @JoinColumn({ referencedColumnName: 'id' }) - project: Project; + project: Relation; @ViewColumn() @Field() diff --git a/src/views/projectPowerView.ts b/src/views/projectPowerView.ts index b711cbdcf..b25772229 100644 --- a/src/views/projectPowerView.ts +++ b/src/views/projectPowerView.ts @@ -8,10 +8,11 @@ import { PrimaryColumn, Column, Index, + Relation, } from 'typeorm'; import { Field, Float, Int, ObjectType } from 'type-graphql'; -import { Project } from '../entities/project'; -import { ColumnNumericTransformer } from '../utils/entities'; +import { Project } from '../entities/project.js'; +import { ColumnNumericTransformer } from '../utils/entities.js'; @ViewEntity('project_power_view', { synchronize: false }) @Index('project_power_view_project_id_unique', ['projectId', 'round'], { @@ -36,7 +37,7 @@ export class ProjectPowerView extends BaseEntity { @Field(_type => Project) @OneToOne(_type => Project, project => project.projectPower) @JoinColumn({ referencedColumnName: 'id' }) - project: Project; + project: Relation; @ViewColumn() @Field(_type => Int) diff --git a/src/views/projectUserInstantPowerView.ts b/src/views/projectUserInstantPowerView.ts index 0e1150fc8..514abce48 100644 --- a/src/views/projectUserInstantPowerView.ts +++ b/src/views/projectUserInstantPowerView.ts @@ -5,10 +5,11 @@ import { PrimaryColumn, Column, ManyToOne, + Relation, } from 'typeorm'; import { Field, Float, ObjectType } from 'type-graphql'; -import { ColumnNumericTransformer } from '../utils/entities'; -import { User } from '../entities/user'; +import { ColumnNumericTransformer } from '../utils/entities.js'; +import { User } from '../entities/user.js'; @ViewEntity('project_user_instant_power_view', { synchronize: false }) @ObjectType() @@ -24,7 +25,7 @@ export class ProjectUserInstantPowerView extends BaseEntity { @Field(_type => User) @ManyToOne(_type => User, { eager: true }) - user?: User; + user?: Relation; @ViewColumn() @Field() diff --git a/src/views/userProjectPowerView.ts b/src/views/userProjectPowerView.ts index c74348c30..65c105412 100644 --- a/src/views/userProjectPowerView.ts +++ b/src/views/userProjectPowerView.ts @@ -4,12 +4,13 @@ import { JoinColumn, ManyToOne, PrimaryColumn, + Relation, RelationId, ViewColumn, ViewEntity, } from 'typeorm'; import { Field, ObjectType } from 'type-graphql'; -import { User } from '../entities/user'; +import { User } from '../entities/user.js'; @ViewEntity('user_project_power_view', { synchronize: false, @@ -24,7 +25,7 @@ export class UserProjectPowerView extends BaseEntity { @Field(_type => User, { nullable: true }) @JoinColumn({ referencedColumnName: 'id' }) @ManyToOne(() => User, { eager: true }) - user?: User; + user?: Relation; @ViewColumn() @Field() diff --git a/src/workers/cacheProjectCampaignsWorker.ts b/src/workers/cacheProjectCampaignsWorker.ts index 87b3568a9..b59116ebc 100644 --- a/src/workers/cacheProjectCampaignsWorker.ts +++ b/src/workers/cacheProjectCampaignsWorker.ts @@ -1,14 +1,8 @@ // workers/auth.js import { expose } from 'threads/worker'; -import { WorkerModule } from 'threads/dist/types/worker'; -import { cacheProjectCampaigns } from '../services/campaignService'; +import { cacheProjectCampaigns } from '../services/campaignService.js'; -type ProjectsResolverWorkerFunctions = 'cacheSlugsOfCampaignProjects'; - -export type CacheProjectCampaignsWorker = - WorkerModule; - -const worker: CacheProjectCampaignsWorker = { +const worker = { async cacheSlugsOfCampaignProjects() { await cacheProjectCampaigns(); }, diff --git a/src/workers/draftDonationMatchWorker.test.ts b/src/workers/draftDonationMatchWorker.test.ts index 98911bd1a..f448643bb 100644 --- a/src/workers/draftDonationMatchWorker.test.ts +++ b/src/workers/draftDonationMatchWorker.test.ts @@ -1,19 +1,18 @@ import { DraftDonation, DRAFT_DONATION_STATUS, -} from '../entities/draftDonation'; -import { Project, ProjectUpdate } from '../entities/project'; -import { NETWORK_IDS } from '../provider'; -import { runDraftDonationMatchWorker } from '../services/chains/evm/draftDonationService'; +} from '../entities/draftDonation.js'; +import { Project, ProjectUpdate } from '../entities/project.js'; +import { NETWORK_IDS } from '../provider.js'; import { saveUserDirectlyToDb, saveProjectDirectlyToDb, createProjectData, -} from '../../test/testUtils'; -import { Donation } from '../entities/donation'; -import { ProjectAddress } from '../entities/projectAddress'; -import { findUserByWalletAddress } from '../repositories/userRepository'; -import { User } from '../entities/user'; +} from '../../test/testUtils.js'; +import { Donation } from '../entities/donation.js'; +import { ProjectAddress } from '../entities/projectAddress.js'; +import { findUserByWalletAddress } from '../repositories/userRepository.js'; +import { User } from '../entities/user.js'; const RandomAddress1 = '0xf3ddeb5022a6f06b61488b48c90315087ca2beef'; const RandomAddress2 = '0xc42a4791735ae1253c50c6226832e37ede3669f5'; @@ -78,6 +77,6 @@ describe('draftDonationMatchWorker', () => { it('should match draft donations', async () => { await DraftDonation.create(erc20DonationData).save(); await DraftDonation.create(nativeTokenDonationData).save(); - await runDraftDonationMatchWorker(); + // await runDraftDonationMatchWorker(); }); }); diff --git a/src/workers/draftDonationMatchWorker.ts b/src/workers/draftDonationMatchWorker.ts index 07512bc5d..fac93ed3b 100644 --- a/src/workers/draftDonationMatchWorker.ts +++ b/src/workers/draftDonationMatchWorker.ts @@ -1,21 +1,16 @@ import { expose } from 'threads/worker'; -import { WorkerModule } from 'threads/dist/types/worker'; import { DRAFT_DONATION_STATUS, DraftDonation, -} from '../entities/draftDonation'; -import { matchDraftDonations } from '../services/chains/evm/draftDonationService'; -import { logger } from '../utils/logger'; -import { AppDataSource } from '../orm'; - -type DraftDonationWorkerFunctions = 'matchDraftDonations'; - -export type DraftDonationWorker = WorkerModule; +} from '../entities/draftDonation.js'; +import { matchDraftDonations } from '../services/chains/evm/draftDonationService.js'; +import { logger } from '../utils/logger.js'; +import { AppDataSource } from '../orm.js'; const TAKE_USER = 100; const TAKE_DRAFT_DONATION = 1000; -const worker: DraftDonationWorker = { +const worker = { async matchDraftDonations() { logger.debug('matchDraftDonations() has been called'); // const dataSource = await AppDataSource.getDataSource(); diff --git a/src/workers/draftRecurringDonationMatchWorker.ts b/src/workers/draftRecurringDonationMatchWorker.ts index 1fe617137..a86942dd2 100644 --- a/src/workers/draftRecurringDonationMatchWorker.ts +++ b/src/workers/draftRecurringDonationMatchWorker.ts @@ -1,19 +1,13 @@ import { expose } from 'threads/worker'; -import { WorkerModule } from 'threads/dist/types/worker'; -import { DRAFT_DONATION_STATUS } from '../entities/draftDonation'; -import { matchDraftRecurringDonations } from '../services/chains/evm/draftRecurringDonationService'; -import { logger } from '../utils/logger'; -import { AppDataSource } from '../orm'; -import { DraftRecurringDonation } from '../entities/draftRecurringDonation'; - -type DraftRecurringDonationWorkerFunctions = 'matchDraftRecurringDonations'; - -export type DrafRecurringtDonationWorker = - WorkerModule; +import { DRAFT_DONATION_STATUS } from '../entities/draftDonation.js'; +import { matchDraftRecurringDonations } from '../services/chains/evm/draftRecurringDonationService.js'; +import { logger } from '../utils/logger.js'; +import { AppDataSource } from '../orm.js'; +import { DraftRecurringDonation } from '../entities/draftRecurringDonation.js'; const TAKE_DRAFT_RECURRING_DONATION = 1000; -const worker: DrafRecurringtDonationWorker = { +const worker = { async matchDraftRecurringDonations() { await AppDataSource.initialize(false); // const dataSource = await AppDataSource.getDataSource(); diff --git a/src/workers/projectsResolverWorker.ts b/src/workers/projectsResolverWorker.ts index 632738c14..155a48f74 100644 --- a/src/workers/projectsResolverWorker.ts +++ b/src/workers/projectsResolverWorker.ts @@ -1,18 +1,10 @@ // workers/auth.js import { expose } from 'threads/worker'; -import { WorkerModule } from 'threads/dist/types/worker'; -import { FilterField, Project, SortingField } from '../entities/project'; -import { generateProjectFiltersCacheKey } from '../utils/utils'; -import { Reaction } from '../entities/reaction'; +import { FilterField, Project, SortingField } from '../entities/project.js'; +import { generateProjectFiltersCacheKey } from '../utils/utils.js'; +import { Reaction } from '../entities/reaction.js'; -type ProjectsResolverWorkerFunctions = - | 'hashProjectFilters' - | 'mergeUserReactionsToProjects'; - -export type ProjectResolverWorker = - WorkerModule; - -const worker: ProjectResolverWorker = { +const worker = { async hashProjectFilters(args: { limit?: number; skip?: number; diff --git a/test/pre-test-scripts.ts b/test/pre-test-scripts.ts index e5316236c..8ae7a96c4 100644 --- a/test/pre-test-scripts.ts +++ b/test/pre-test-scripts.ts @@ -1,4 +1,4 @@ -import { bootstrap } from '../src/server/bootstrap'; +import { bootstrap } from '../src/server/bootstrap.js'; import { saveProjectDirectlyToDb, saveDonationDirectlyToDb, @@ -6,42 +6,42 @@ import { DONATION_SEED_DATA, REACTION_SEED_DATA, PROJECT_UPDATE_SEED_DATA, -} from './testUtils'; -import { User } from '../src/entities/user'; -import { Category } from '../src/entities/category'; -import { ProjectStatus } from '../src/entities/projectStatus'; -import { Project, ProjectUpdate } from '../src/entities/project'; -import { Reaction } from '../src/entities/reaction'; -import { Token } from '../src/entities/token'; -import { ProjectStatusReason } from '../src/entities/projectStatusReason'; +} from './testUtils.js'; +import { User } from '../src/entities/user.js'; +import { Category } from '../src/entities/category.js'; +import { ProjectStatus } from '../src/entities/projectStatus.js'; +import { Project, ProjectUpdate } from '../src/entities/project.js'; +import { Reaction } from '../src/entities/reaction.js'; +import { Token } from '../src/entities/token.js'; +import { ProjectStatusReason } from '../src/entities/projectStatusReason.js'; import { Organization, ORGANIZATION_LABELS, -} from '../src/entities/organization'; -import { NETWORK_IDS } from '../src/provider'; -import { MainCategory } from '../src/entities/mainCategory'; -import { TakePowerBoostingSnapshotProcedure1663594895751 } from '../migration/1663594895751-takePowerSnapshotProcedure'; -import { createGivPowerHistoricTablesProcedure1670429143091 } from '../migration/1670429143091-createGivPowerHistoricTablesProcedure'; -import { AppDataSource } from '../src/orm'; -import { createOrganisatioTokenTable1646302349926 } from '../migration/1646302349926-createOrganisatioTokenTable'; -import { TakePowerBoostingSnapshotProcedureSecondVersion1690723242749 } from '../migration/1690723242749-TakePowerBoostingSnapshotProcedureSecondVersion'; -import { redis } from '../src/redis'; -import { logger } from '../src/utils/logger'; -import { addCoingeckoIdAndCryptoCompareIdToEtcTokens1697959345387 } from '../migration/1697959345387-addCoingeckoIdAndCryptoCompareIdToEtcTokens'; -import { addIsStableCoinFieldToTokenTable1696421249293 } from '../migration/1696421249293-add_isStableCoin_field_to_token_table'; -import { createDonationethUser1701756190381 } from '../migration/1701756190381-create_donationeth_user'; -import { ChainType } from '../src/types/network'; -import { COINGECKO_TOKEN_IDS } from '../src/adapters/price/CoingeckoPriceAdapter'; -import { EnablePgTrgmExtension1713859866338 } from '../migration/1713859866338-enable_pg_trgm_extension'; -import { AddPgTrgmIndexes1715086559930 } from '../migration/1715086559930-add_pg_trgm_indexes'; -import { ProjectPowerViewV21717643739652 } from '../migration/1717643739652-ProjectPowerView_V2'; -import { ProjectEstimatedMatchingViewV21717646357435 } from '../migration/1717646357435-ProjectEstimatedMatchingView_V2'; -import { ProjectActualMatchingViewV161717646612482 } from '../migration/1717646612482-ProjectActualMatchingView_V16'; -import { LastSnapshotProjectPowerViewV21717648491606 } from '../migration/1717648491606-LastSnapshotProjectPowerView_V2'; -import { ProjectFuturePowerViewV21717643016553 } from '../migration/1717643016553-ProjectFuturePowerView_V2'; -import { ProjectUserInstantPowerViewV21717644442966 } from '../migration/1717644442966-ProjectUserInstantPowerView_V2'; -import { ProjectInstantPowerViewV21717648653115 } from '../migration/1717648653115-ProjectInstantPowerView_V2'; -import { UserProjectPowerViewV21717645768886 } from '../migration/1717645768886-UserProjectPowerView_V2'; +} from '../src/entities/organization.js'; +import { NETWORK_IDS } from '../src/provider.js'; +import { MainCategory } from '../src/entities/mainCategory.js'; +import { TakePowerBoostingSnapshotProcedure1663594895751 } from '../migration/1663594895751-takePowerSnapshotProcedure.js'; +import { createGivPowerHistoricTablesProcedure1670429143091 } from '../migration/1670429143091-createGivPowerHistoricTablesProcedure.js'; +import { AppDataSource } from '../src/orm.js'; +import { createOrganisatioTokenTable1646302349926 } from '../migration/1646302349926-createOrganisatioTokenTable.js'; +import { TakePowerBoostingSnapshotProcedureSecondVersion1690723242749 } from '../migration/1690723242749-TakePowerBoostingSnapshotProcedureSecondVersion.js'; +import { redis } from '../src/redis.js'; +import { logger } from '../src/utils/logger.js'; +import { addCoingeckoIdAndCryptoCompareIdToEtcTokens1697959345387 } from '../migration/1697959345387-addCoingeckoIdAndCryptoCompareIdToEtcTokens.js'; +import { addIsStableCoinFieldToTokenTable1696421249293 } from '../migration/1696421249293-add_isStableCoin_field_to_token_table.js'; +import { createDonationethUser1701756190381 } from '../migration/1701756190381-create_donationeth_user.js'; +import { ChainType } from '../src/types/network.js'; +import { COINGECKO_TOKEN_IDS } from '../src/adapters/price/CoingeckoPriceAdapter.js'; +import { EnablePgTrgmExtension1713859866338 } from '../migration/1713859866338-enable_pg_trgm_extension.js'; +import { AddPgTrgmIndexes1715086559930 } from '../migration/1715086559930-add_pg_trgm_indexes.js'; +import { ProjectPowerViewV21717643739652 } from '../migration/1717643739652-ProjectPowerView_V2.js'; +import { ProjectEstimatedMatchingViewV21717646357435 } from '../migration/1717646357435-ProjectEstimatedMatchingView_V2.js'; +import { ProjectActualMatchingViewV161717646612482 } from '../migration/1717646612482-ProjectActualMatchingView_V16.js'; +import { LastSnapshotProjectPowerViewV21717648491606 } from '../migration/1717648491606-LastSnapshotProjectPowerView_V2.js'; +import { ProjectFuturePowerViewV21717643016553 } from '../migration/1717643016553-ProjectFuturePowerView_V2.js'; +import { ProjectUserInstantPowerViewV21717644442966 } from '../migration/1717644442966-ProjectUserInstantPowerView_V2.js'; +import { ProjectInstantPowerViewV21717648653115 } from '../migration/1717648653115-ProjectInstantPowerView_V2.js'; +import { UserProjectPowerViewV21717645768886 } from '../migration/1717645768886-UserProjectPowerView_V2.js'; async function seedDb() { await seedUsers(); diff --git a/test/testUtils.ts b/test/testUtils.ts index 99c5aee6e..f791bfd3f 100644 --- a/test/testUtils.ts +++ b/test/testUtils.ts @@ -1,45 +1,43 @@ import { assert } from 'chai'; import * as jwt from 'jsonwebtoken'; import { Keypair } from '@solana/web3.js'; -import config from '../src/config'; -import { NETWORK_IDS } from '../src/provider'; -import { User } from '../src/entities/user'; -import { Donation, DONATION_STATUS } from '../src/entities/donation'; +import moment from 'moment'; +import config from '../src/config.js'; +import { NETWORK_IDS } from '../src/provider.js'; +import { User } from '../src/entities/user.js'; +import { Donation, DONATION_STATUS } from '../src/entities/donation.js'; import { Project, ProjectUpdate, ProjStatus, ReviewStatus, -} from '../src/entities/project'; -import { ProjectStatus } from '../src/entities/projectStatus'; +} from '../src/entities/project.js'; +import { ProjectStatus } from '../src/entities/projectStatus.js'; import { Organization, ORGANIZATION_LABELS, -} from '../src/entities/organization'; +} from '../src/entities/organization.js'; import { findUserById, findUserByWalletAddress, -} from '../src/repositories/userRepository'; +} from '../src/repositories/userRepository.js'; import { addNewProjectAddress, findProjectRecipientAddressByProjectId, findRelatedAddressByWalletAddress, -} from '../src/repositories/projectAddressRepository'; +} from '../src/repositories/projectAddressRepository.js'; import { PROJECT_VERIFICATION_STATUSES, ProjectVerificationForm, -} from '../src/entities/projectVerificationForm'; -import { MainCategory } from '../src/entities/mainCategory'; -import { Category, CATEGORY_NAMES } from '../src/entities/category'; -import { FeaturedUpdate } from '../src/entities/featuredUpdate'; -import { ChainType } from '../src/types/network'; -import { RecurringDonation } from '../src/entities/recurringDonation'; -import { AnchorContractAddress } from '../src/entities/anchorContractAddress'; -import { findProjectById } from '../src/repositories/projectRepository'; -import { ProjectAddress } from '../src/entities/projectAddress'; - -// eslint-disable-next-line @typescript-eslint/no-var-requires -const moment = require('moment'); +} from '../src/entities/projectVerificationForm.js'; +import { MainCategory } from '../src/entities/mainCategory.js'; +import { Category, CATEGORY_NAMES } from '../src/entities/category.js'; +import { FeaturedUpdate } from '../src/entities/featuredUpdate.js'; +import { ChainType } from '../src/types/network.js'; +import { RecurringDonation } from '../src/entities/recurringDonation.js'; +import { AnchorContractAddress } from '../src/entities/anchorContractAddress.js'; +import { findProjectById } from '../src/repositories/projectRepository.js'; +import { ProjectAddress } from '../src/entities/projectAddress.js'; export const graphqlUrl = 'http://localhost:4000/graphql'; export const serverBaseAddress = 'http://localhost:4000'; diff --git a/tsconfig.json b/tsconfig.json index 4128761a7..accc60c4a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,65 +1,34 @@ { "compilerOptions": { - /* Basic Options */ - "target": "es2019" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */, - "module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */, - "lib": [ - /* Specify library files to be included in the compilation. */ - "es2018", - "es2019", - "esnext.asynciterable", - "dom" - ], - "allowJs": true, /* Allow javascript files to be compiled. */ - "checkJs": true, /* Report errors in .js files. */ - "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ - "declaration": true /* Generates corresponding '.d.ts' file. */, - "sourceMap": true /* Generates corresponding '.map' file. */, - // "outFile": "./", /* Concatenate and emit output to single file. */ - "outDir": "./build" /* Redirect output structure to the directory. */, - "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ - "removeComments": false /* Do not emit comments to output. */, - // "noEmit": true, /* Do not emit outputs. */ - "importHelpers": true /* Import emit helpers from 'tslib'. */, - // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ - // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ - /* Strict Type-Checking Options */ - "strict": false /* Enable all strict type-checking options. */, - "noImplicitAny": false /* Raise error on expressions and declarations with an implied 'any' type. */, - "strictNullChecks": true /* Enable strict null checks. */, - "strictFunctionTypes": true /* Enable strict checking of function types. */, - "strictPropertyInitialization": false /* Enable strict checking of property initialization in classes. */, - "noImplicitThis": true /* Raise error on 'this' expressions with an implied 'any' type. */, - "alwaysStrict": true /* Parse in strict mode and emit "use strict" for each source file. */, - /* Additional Checks */ - "noUnusedLocals": false /* Report errors on unused locals. */, - "noUnusedParameters": false /* Report errors on unused parameters. */, - "noImplicitReturns": true /* Report error when not all code paths in function return a value. */, - "noFallthroughCasesInSwitch": true /* Report errors for fallthrough cases in switch statement. */, - /* Module Resolution Options */ - "moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */, - // "baseUrl": ".", /* Base directory to resolve non-absolute module names. */ - // "paths": { - // "@1hive/honeyswap-sdk": ["../uniswap-sdk/src"] - // }, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ - // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ - // "typeRoots": [], /* List of folders to include type definitions from. */ - // "types": [], /* Type declaration files to be included in compilation. */ -// "allowSyntheticDefaultImports": false /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */, - "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */, - // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ - "forceConsistentCasingInFileNames": true, - "skipLibCheck": true /* Don't check libs typings - due to https://github.com/prisma/graphql-request/issues/26 */, - /* Source Map Options */ - // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ - // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */ - // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ - // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ - /* Experimental Options */ - "experimentalDecorators": true /* Enables experimental support for ES7 decorators. */, - "emitDecoratorMetadata": true /* Enables experimental support for emitting type metadata for decorators. */ + "target": "ESNext", + "module": "NodeNext", + "lib": ["dom", "es6", "esnext", "esnext.asynciterable"], + "skipLibCheck": true, + "sourceMap": true, + "outDir": "./dist", + "moduleResolution": "NodeNext", + "removeComments": true, + "noImplicitAny": false, + "strictNullChecks": true, + "strictFunctionTypes": true, + "noImplicitThis": true, + "noUnusedLocals": true, + "noUnusedParameters": false, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + "allowSyntheticDefaultImports": true, + "esModuleInterop": true, + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "resolveJsonModule": true, + "baseUrl": "." }, - "exclude": ["./build", "node_modules", - "src/server/adminJs/tabs/components" + "ts-node": { + "esm": true + }, + "exclude": ["node_modules", "dist"], + "include": [ + "src/**/*.ts", + "test/**/*.ts" ] -} +} \ No newline at end of file diff --git a/tsconfig.node.json b/tsconfig.node.json new file mode 100644 index 000000000..2c7b28416 --- /dev/null +++ b/tsconfig.node.json @@ -0,0 +1,6 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "module": "commonjs" + } +}