From 870e1aac9bb4fe26e08a4e7bcc2ca45c6effde6b Mon Sep 17 00:00:00 2001 From: Pascal Garber Date: Wed, 20 Mar 2024 12:15:19 +0100 Subject: [PATCH 1/3] chore(native-import-alias): First try and error (WIP) --- package.json | 29 +++++--- src/api/app.ts | 12 ++-- src/api/controllers/ApiKeyController.ts | 18 ++--- src/api/controllers/AuthController.ts | 20 +++--- src/api/controllers/CalloutController.ts | 50 ++++++------- .../CalloutResponseCommentController.ts | 20 +++--- .../controllers/CalloutResponseController.ts | 14 ++-- src/api/controllers/ContactController.ts | 70 +++++++++---------- src/api/controllers/ContentController.ts | 8 +-- src/api/controllers/EmailController.ts | 10 +-- src/api/controllers/NoticeController.ts | 18 ++--- src/api/controllers/PaymentController.ts | 10 +-- src/api/controllers/ResetDeviceController.ts | 8 +-- .../controllers/ResetPasswordController.ts | 8 +-- src/api/controllers/SegmentController.ts | 32 ++++----- src/api/controllers/SignupController.ts | 18 ++--- src/api/controllers/StatsController.ts | 8 +-- src/api/controllers/UploadController.ts | 12 ++-- src/api/decorators/CalloutId.ts | 4 +- src/api/decorators/CurrentAuth.ts | 4 +- src/api/decorators/TargetUser.ts | 8 +-- src/api/dto/AddressDto.ts | 4 +- src/api/dto/ApiKeyDto.ts | 4 +- src/api/dto/BaseDto.ts | 5 +- src/api/dto/CalloutDto.ts | 32 ++++----- src/api/dto/CalloutFormDto.ts | 14 ++-- src/api/dto/CalloutResponseCommentDto.ts | 4 +- src/api/dto/CalloutResponseDto.ts | 20 +++--- src/api/dto/CalloutTagDto.ts | 2 +- src/api/dto/CalloutVariantDto.ts | 2 +- src/api/dto/ContactDto.ts | 16 ++--- src/api/dto/ContactMfaDto.ts | 8 +-- src/api/dto/ContactProfileDto.ts | 2 +- src/api/dto/ContentDto.ts | 36 +++++----- src/api/dto/ContributionDto.ts | 9 ++- src/api/dto/JoinFlowDto.ts | 2 +- src/api/dto/NoticeDto.ts | 2 +- src/api/dto/PaymentDto.ts | 4 +- src/api/dto/PaymentFlowDto.ts | 2 +- src/api/dto/ResetDeviceDto.ts | 6 +- src/api/dto/ResetPasswordDto.ts | 4 +- src/api/dto/SegmentDto.ts | 2 +- src/api/dto/SignupFlowDto.ts | 10 +-- .../ValidateResponseInterceptor.ts | 4 +- src/api/middlewares/AuthMiddleware.ts | 10 +-- src/api/params/ContentParams.ts | 2 +- src/api/transformers/AddressTransformer.ts | 4 +- src/api/transformers/ApiKeyTransformer.ts | 4 +- .../BaseCalloutResponseTransformer.ts | 22 +++--- src/api/transformers/BaseTransformer.ts | 24 +++---- .../CalloutResponseCommentTransformer.ts | 12 ++-- .../transformers/CalloutResponseExporter.ts | 35 +++++----- .../CalloutResponseMapTransformer.ts | 20 +++--- .../CalloutResponseTransformer.ts | 36 +++++----- src/api/transformers/CalloutTagTransformer.ts | 4 +- src/api/transformers/CalloutTransformer.ts | 24 +++---- .../transformers/CalloutVariantTransformer.ts | 4 +- src/api/transformers/ContactExporter.ts | 14 ++-- .../transformers/ContactProfileTransformer.ts | 10 +-- .../transformers/ContactRoleTransformer.ts | 4 +- src/api/transformers/ContactTransformer.ts | 40 +++++------ src/api/transformers/ContentTransformer.ts | 16 ++--- src/api/transformers/NoticeTransformer.ts | 10 +-- src/api/transformers/PaymentTransformer.ts | 14 ++-- src/api/transformers/SegmentTransformer.ts | 10 +-- src/api/utils/index.ts | 2 +- src/api/utils/rules.ts | 8 +-- src/api/validators/IsVariantsObject.ts | 2 +- src/api/validators/MinContributionAmount.ts | 5 +- src/api/validators/ValidPayFee.ts | 2 +- src/app.ts | 22 +++--- src/apps/discourse/app.ts | 10 +-- src/apps/gift/app.ts | 32 ++++----- src/apps/home/app.ts | 2 +- src/apps/login/app.ts | 12 ++-- src/apps/logout/app.ts | 2 +- src/apps/members/app.ts | 26 +++---- src/apps/members/apps/add/app.ts | 26 +++---- src/apps/members/apps/member/app.ts | 24 +++---- .../apps/member/apps/contribution/app.ts | 10 +-- .../apps/member/apps/permissions/app.ts | 8 +-- .../members/apps/member/apps/profile/app.ts | 20 +++--- src/apps/members/apps/segments/app.ts | 34 ++++----- src/apps/projects/app.ts | 16 ++--- src/apps/reports/apps/map/app.ts | 18 ++--- src/apps/reports/apps/transactions/app.ts | 8 +-- src/apps/settings/apps/content/app.ts | 12 ++-- src/apps/settings/apps/newsletters/app.ts | 26 +++---- src/apps/settings/apps/options/app.ts | 6 +- src/apps/settings/apps/pages/app.ts | 10 +-- src/apps/share/app.ts | 10 +-- src/apps/tools/apps/emails/app.ts | 18 ++--- src/apps/tools/apps/exports/app.ts | 17 +++-- .../exports/exports/ActiveMembersExport.ts | 8 +-- .../tools/apps/exports/exports/BaseExport.ts | 6 +- .../apps/exports/exports/EditionExport.ts | 6 +- .../tools/apps/exports/exports/GiftsExport.ts | 44 ++++++------ .../apps/exports/exports/ReferralsExport.ts | 30 ++++---- src/apps/tools/apps/polls/app.ts | 10 +-- src/apps/tools/apps/referrals/app.ts | 8 +-- .../tools/apps/special-urls/actions/index.js | 4 +- src/apps/tools/apps/special-urls/app.js | 13 ++-- src/apps/tools/apps/special-urls/handler.js | 6 +- src/apps/tools/apps/special-urls/utils.js | 2 +- src/core/app-loader.ts | 6 +- src/core/database.ts | 4 +- src/core/lib/ajv.ts | 2 +- src/core/lib/captchafox.ts | 2 +- src/core/lib/gocardless.ts | 17 +++-- src/core/lib/passport.ts | 28 ++++---- src/core/lib/stripe.ts | 2 +- src/core/logging.ts | 2 +- src/core/middleware.ts | 16 ++--- src/core/providers/email/BaseProvider.ts | 28 ++++---- src/core/providers/email/MandrillProvider.ts | 6 +- src/core/providers/email/SMTPProvider.ts | 6 +- src/core/providers/email/SendGridProvider.ts | 4 +- src/core/providers/email/index.ts | 2 +- .../providers/newsletter/MailchimpProvider.ts | 12 ++-- src/core/providers/payment-flow/GCProvider.ts | 6 +- .../providers/payment-flow/StripeProvider.ts | 8 +-- src/core/providers/payment-flow/index.ts | 4 +- src/core/providers/payment/GCProvider.ts | 40 +++++------ src/core/providers/payment/ManualProvider.ts | 12 ++-- src/core/providers/payment/StripeProvider.ts | 40 +++++------ src/core/providers/payment/index.ts | 12 ++-- src/core/quickflash.ts | 2 +- src/core/server.ts | 8 +-- src/core/services/CalloutsService.ts | 34 ++++----- src/core/services/ContactMfaService.ts | 21 +++--- src/core/services/ContactsService.ts | 56 +++++++-------- src/core/services/EmailService.ts | 26 +++---- src/core/services/GiftService.ts | 27 ++++--- .../services/NetworkCommunicatorService.ts | 10 +-- src/core/services/NewsletterService.ts | 16 ++--- src/core/services/OptionsService.ts | 8 +-- src/core/services/PageSettingsService.ts | 16 ++--- src/core/services/PaymentFlowService.ts | 32 ++++----- src/core/services/PaymentService.ts | 26 +++---- src/core/services/ReferralsService.ts | 14 ++-- src/core/services/ResetSecurityFlowService.ts | 8 +-- src/core/services/SegmentService.ts | 12 ++-- src/core/sessions.ts | 6 +- src/core/template-locals.ts | 2 +- src/core/utils/auth.ts | 10 +-- src/core/utils/contact.ts | 2 +- src/core/utils/email.ts | 33 +++++---- src/core/utils/index.ts | 2 +- src/core/utils/payment.test.ts | 8 +-- src/core/utils/payment.ts | 10 +-- src/core/utils/payment/gocardless.ts | 10 +-- src/core/utils/payment/stripe.ts | 40 +++++------ src/locales/current.ts | 2 +- ...513644609-AddEmailAndPasswordToJoinFlow.ts | 5 +- src/migrations/1632397910432-AddButtonText.ts | 2 +- .../1634125137636-AddExcerptAndImageToPoll.ts | 5 +- ...650900384747-AddPaymentMethodToJoinForm.ts | 5 +- .../1652115873327-AddUrlsToJoinFlow.ts | 2 +- .../1696600862719-UpdateGCNextAmount.ts | 2 +- src/models/Callout.ts | 6 +- src/models/CalloutVariant.ts | 2 +- src/models/Contact.ts | 17 +++-- src/models/ContactMfa.ts | 2 +- src/models/Content.ts | 2 +- src/models/EmailMailing.ts | 2 +- src/models/Export.ts | 2 +- src/models/JoinForm.ts | 2 +- src/models/ResetSecurityFlow.ts | 2 +- src/tools/configure.ts | 10 +-- src/tools/database/anonymisers/index.ts | 8 +-- src/tools/database/anonymisers/models.ts | 56 +++++++-------- src/tools/database/export-demo.ts | 12 ++-- src/tools/database/export.ts | 4 +- src/tools/database/import-steady.ts | 16 ++--- src/tools/database/import.ts | 8 +-- src/tools/gocardless/fetch-customer.js | 2 +- src/tools/gocardless/fetch-data.js | 2 +- src/tools/gocardless/migrate-to-stripe.ts | 20 +++--- src/tools/mailchimp/sync.ts | 18 ++--- src/tools/new-user.ts | 18 ++--- src/tools/process-segments.ts | 24 +++---- src/tools/start-gifts.ts | 12 ++-- src/tools/stripe/resync.ts | 12 ++-- src/tools/test-users.ts | 16 ++--- src/type/auth-info.ts | 4 +- src/type/callout-data.ts | 4 +- src/type/contact-mfa-secure.ts | 2 +- src/type/content-data.ts | 30 ++++---- src/type/create-contact-mfa-data.ts | 2 +- src/type/delete-contact-mfa-data.ts | 2 +- src/type/passport-local-done-callback.ts | 6 +- src/type/passport-local-verify-options.ts | 2 +- src/type/passport-login-info.ts | 2 +- src/typings/index.d.ts | 12 ++-- src/webhooks/app.ts | 8 +-- src/webhooks/handlers/gocardless.ts | 6 +- src/webhooks/handlers/mailchimp.ts | 12 ++-- src/webhooks/handlers/stripe.ts | 22 +++--- src/webhooks/utils/gocardless.ts | 18 ++--- tsconfig.json | 16 ++--- 200 files changed, 1279 insertions(+), 1284 deletions(-) diff --git a/package.json b/package.json index 835b374d7..e5f17d4a5 100644 --- a/package.json +++ b/package.json @@ -138,19 +138,30 @@ "last 1 versions", "> 1%" ], + "imports": { + "#core/defaults.json": "./built/core/defaults.json", + "#core/*": "./built/core/*.js", + "#apps/*": "./built/apps/*.js", + "#api/*": "./built/api/*.js", + "#config": "./built/config/config.js", + "#locale": "./built/locales/current.js", + "#models/*": "./built/models/*.js", + "#type/*": "./built/type/*.js", + "#enums/*": "./built/enums/*.js" + }, "_moduleAliases": { - "@core": "./built/core", - "@api": "./built/api", - "@apps": "./built/apps", - "@config": "./built/config/config.js", - "@locale": "./built/locales/current.js", - "@models": "./built/models", - "@type": "./built/type", - "@enums": "./built/enums" + "#core": "./built/core", + "#api": "./built/api", + "#apps": "./built/apps", + "#config": "./built/config/config.js", + "#locale": "./built/locales/current.js", + "#models": "./built/models", + "#type": "./built/type", + "#enums": "./built/enums" }, "overrides": { "gulp-sourcemaps": { "postcss": "8.4.32" } } -} +} \ No newline at end of file diff --git a/src/api/app.ts b/src/api/app.ts index 5bedba1d7..7ae9fddcb 100644 --- a/src/api/app.ts +++ b/src/api/app.ts @@ -1,4 +1,4 @@ -import "module-alias/register"; +// import "module-alias/register"; import "reflect-metadata"; import { RoleType } from "@beabee/beabee-common"; @@ -38,13 +38,13 @@ import { log as mainLogger, requestErrorLogger, requestLogger -} from "@core/logging"; -import sessions from "@core/sessions"; -import { initApp, startServer } from "@core/server"; +} from "#core/logging"; +import sessions from "#core/sessions"; +import { initApp, startServer } from "#core/server"; -import Contact from "@models/Contact"; +import Contact from "#models/Contact"; -import config from "@config"; +import config from "#config"; function currentUserChecker(action: { request: Request }): Contact | undefined { return action.request.auth?.entity instanceof Contact diff --git a/src/api/controllers/ApiKeyController.ts b/src/api/controllers/ApiKeyController.ts index ca65172e4..a7764a000 100644 --- a/src/api/controllers/ApiKeyController.ts +++ b/src/api/controllers/ApiKeyController.ts @@ -13,23 +13,23 @@ import { Param } from "routing-controllers"; -import { getRepository } from "@core/database"; -import { generateApiKey } from "@core/utils/auth"; +import { getRepository } from "#core/database"; +import { generateApiKey } from "#core/utils/auth"; -import ApiKey from "@models/ApiKey"; -import Contact from "@models/Contact"; +import ApiKey from "#models/ApiKey"; +import Contact from "#models/Contact"; -import { CurrentAuth } from "@api/decorators/CurrentAuth"; +import { CurrentAuth } from "#api/decorators/CurrentAuth"; import { CreateApiKeyDto, GetApiKeyDto, ListApiKeysDto, NewApiKeyDto -} from "@api/dto/ApiKeyDto"; -import { PaginatedDto } from "@api/dto/PaginatedDto"; -import ApiKeyTransformer from "@api/transformers/ApiKeyTransformer"; +} from "#api/dto/ApiKeyDto"; +import { PaginatedDto } from "#api/dto/PaginatedDto"; +import ApiKeyTransformer from "#api/transformers/ApiKeyTransformer"; -import { AuthInfo } from "@type/auth-info"; +import { AuthInfo } from "#type/auth-info"; @JsonController("/api-key") @Authorized("admin") diff --git a/src/api/controllers/AuthController.ts b/src/api/controllers/AuthController.ts index 3251dd108..47a0f0b16 100644 --- a/src/api/controllers/AuthController.ts +++ b/src/api/controllers/AuthController.ts @@ -16,22 +16,22 @@ import { import { UnauthorizedError } from "../errors/UnauthorizedError"; -import { getRepository } from "@core/database"; -import passport from "@core/lib/passport"; +import { getRepository } from "#core/database"; +import passport from "#core/lib/passport"; -import ContactsService from "@core/services/ContactsService"; +import ContactsService from "#core/services/ContactsService"; -import { LoginDto } from "@api/dto/LoginDto"; -import { login } from "@api/utils"; +import { LoginDto } from "#api/dto/LoginDto"; +import { login } from "#api/utils"; -import Contact from "@models/Contact"; -import ContactRole from "@models/ContactRole"; +import Contact from "#models/Contact"; +import ContactRole from "#models/ContactRole"; -import { LOGIN_CODES } from "@enums/login-codes"; +import { LOGIN_CODES } from "#enums/login-codes"; -import { PassportLoginInfo } from "@type/passport-login-info"; +import { PassportLoginInfo } from "#type/passport-login-info"; -import config from "@config"; +import config from "#config"; @JsonController("/auth") export class AuthController { diff --git a/src/api/controllers/CalloutController.ts b/src/api/controllers/CalloutController.ts index 1b0a578a1..4a2af2736 100644 --- a/src/api/controllers/CalloutController.ts +++ b/src/api/controllers/CalloutController.ts @@ -16,48 +16,48 @@ import { Res } from "routing-controllers"; -import CalloutsService from "@core/services/CalloutsService"; +import CalloutsService from "#core/services/CalloutsService"; -import { getRepository } from "@core/database"; -import { verify } from "@core/lib/captchafox"; +import { getRepository } from "#core/database"; +import { verify } from "#core/lib/captchafox"; -import { GetExportQuery } from "@api/dto/BaseDto"; +import { GetExportQuery } from "#api/dto/BaseDto"; import { CreateCalloutDto, GetCalloutDto, GetCalloutOptsDto, ListCalloutsDto -} from "@api/dto/CalloutDto"; +} from "#api/dto/CalloutDto"; import { CreateCalloutResponseDto, GetCalloutResponseDto, GetCalloutResponseMapDto, ListCalloutResponsesDto -} from "@api/dto/CalloutResponseDto"; -import { CreateCalloutTagDto, GetCalloutTagDto } from "@api/dto/CalloutTagDto"; -import { PaginatedDto } from "@api/dto/PaginatedDto"; +} from "#api/dto/CalloutResponseDto"; +import { CreateCalloutTagDto, GetCalloutTagDto } from "#api/dto/CalloutTagDto"; +import { PaginatedDto } from "#api/dto/PaginatedDto"; -import { CalloutId } from "@api/decorators/CalloutId"; -import { CurrentAuth } from "@api/decorators/CurrentAuth"; -import PartialBody from "@api/decorators/PartialBody"; -import InvalidCalloutResponse from "@api/errors/InvalidCalloutResponse"; -import UnauthorizedError from "@api/errors/UnauthorizedError"; -import CalloutTagTransformer from "@api/transformers/CalloutTagTransformer"; -import CalloutTransformer from "@api/transformers/CalloutTransformer"; -import CalloutResponseExporter from "@api/transformers/CalloutResponseExporter"; -import CalloutResponseMapTransformer from "@api/transformers/CalloutResponseMapTransformer"; -import CalloutResponseTransformer from "@api/transformers/CalloutResponseTransformer"; -import { validateOrReject } from "@api/utils"; +import { CalloutId } from "#api/decorators/CalloutId"; +import { CurrentAuth } from "#api/decorators/CurrentAuth"; +import PartialBody from "#api/decorators/PartialBody"; +import InvalidCalloutResponse from "#api/errors/InvalidCalloutResponse"; +import UnauthorizedError from "#api/errors/UnauthorizedError"; +import CalloutTagTransformer from "#api/transformers/CalloutTagTransformer"; +import CalloutTransformer from "#api/transformers/CalloutTransformer"; +import CalloutResponseExporter from "#api/transformers/CalloutResponseExporter"; +import CalloutResponseMapTransformer from "#api/transformers/CalloutResponseMapTransformer"; +import CalloutResponseTransformer from "#api/transformers/CalloutResponseTransformer"; +import { validateOrReject } from "#api/utils"; -import Callout from "@models/Callout"; -import CalloutResponseTag from "@models/CalloutResponseTag"; -import CalloutTag from "@models/CalloutTag"; -import Contact from "@models/Contact"; +import Callout from "#models/Callout"; +import CalloutResponseTag from "#models/CalloutResponseTag"; +import CalloutTag from "#models/CalloutTag"; +import Contact from "#models/Contact"; -import { CalloutCaptcha } from "@enums/callout-captcha"; +import { CalloutCaptcha } from "#enums/callout-captcha"; -import { AuthInfo } from "@type/auth-info"; +import { AuthInfo } from "#type/auth-info"; @JsonController("/callout") export class CalloutController { diff --git a/src/api/controllers/CalloutResponseCommentController.ts b/src/api/controllers/CalloutResponseCommentController.ts index ad71ca5a8..c6b6a0246 100644 --- a/src/api/controllers/CalloutResponseCommentController.ts +++ b/src/api/controllers/CalloutResponseCommentController.ts @@ -13,24 +13,24 @@ import { QueryParams } from "routing-controllers"; -import { getRepository } from "@core/database"; +import { getRepository } from "#core/database"; -import { CurrentAuth } from "@api/decorators/CurrentAuth"; -import PartialBody from "@api/decorators/PartialBody"; +import { CurrentAuth } from "#api/decorators/CurrentAuth"; +import PartialBody from "#api/decorators/PartialBody"; import { CreateCalloutResponseCommentDto, GetCalloutResponseCommentDto, ListCalloutResponseCommentsDto -} from "@api/dto/CalloutResponseCommentDto"; -import { PaginatedDto } from "@api/dto/PaginatedDto"; -import { UUIDParams } from "@api/params/UUIDParams"; +} from "#api/dto/CalloutResponseCommentDto"; +import { PaginatedDto } from "#api/dto/PaginatedDto"; +import { UUIDParams } from "#api/params/UUIDParams"; -import CalloutResponseCommentTransformer from "@api/transformers/CalloutResponseCommentTransformer"; +import CalloutResponseCommentTransformer from "#api/transformers/CalloutResponseCommentTransformer"; -import CalloutResponseComment from "@models/CalloutResponseComment"; -import Contact from "@models/Contact"; +import CalloutResponseComment from "#models/CalloutResponseComment"; +import Contact from "#models/Contact"; -import { AuthInfo } from "@type/auth-info"; +import { AuthInfo } from "#type/auth-info"; @JsonController("/callout-response-comments") @Authorized("admin") diff --git a/src/api/controllers/CalloutResponseController.ts b/src/api/controllers/CalloutResponseController.ts index f1b65fbd4..f69605312 100644 --- a/src/api/controllers/CalloutResponseController.ts +++ b/src/api/controllers/CalloutResponseController.ts @@ -8,9 +8,9 @@ import { QueryParams } from "routing-controllers"; -import { CurrentAuth } from "@api/decorators/CurrentAuth"; -import PartialBody from "@api/decorators/PartialBody"; -import { UUIDParams } from "@api/params/UUIDParams"; +import { CurrentAuth } from "#api/decorators/CurrentAuth"; +import PartialBody from "#api/decorators/PartialBody"; +import { UUIDParams } from "#api/params/UUIDParams"; import { BatchUpdateCalloutResponseDto, @@ -19,11 +19,11 @@ import { GetCalloutResponseDto, GetCalloutResponseOptsDto, ListCalloutResponsesDto -} from "@api/dto/CalloutResponseDto"; -import { PaginatedDto } from "@api/dto/PaginatedDto"; -import CalloutResponseTransformer from "@api/transformers/CalloutResponseTransformer"; +} from "#api/dto/CalloutResponseDto"; +import { PaginatedDto } from "#api/dto/PaginatedDto"; +import CalloutResponseTransformer from "#api/transformers/CalloutResponseTransformer"; -import { AuthInfo } from "@type/auth-info"; +import { AuthInfo } from "#type/auth-info"; @JsonController("/callout-responses") export class CalloutResponseController { diff --git a/src/api/controllers/ContactController.ts b/src/api/controllers/ContactController.ts index b800a0506..843b3c199 100644 --- a/src/api/controllers/ContactController.ts +++ b/src/api/controllers/ContactController.ts @@ -18,18 +18,18 @@ import { Res } from "routing-controllers"; -import ContactsService from "@core/services/ContactsService"; -import OptionsService from "@core/services/OptionsService"; -import PaymentFlowService from "@core/services/PaymentFlowService"; -import PaymentService from "@core/services/PaymentService"; -import ContactMfaService from "@core/services/ContactMfaService"; +import ContactsService from "#core/services/ContactsService"; +import OptionsService from "#core/services/OptionsService"; +import PaymentFlowService from "#core/services/PaymentFlowService"; +import PaymentService from "#core/services/PaymentService"; +import ContactMfaService from "#core/services/ContactMfaService"; -import { generatePassword } from "@core/utils/auth"; +import { generatePassword } from "#core/utils/auth"; -import Contact from "@models/Contact"; -import JoinFlow from "@models/JoinFlow"; +import Contact from "#models/Contact"; +import JoinFlow from "#models/JoinFlow"; -import { GetExportQuery } from "@api/dto/BaseDto"; +import { GetExportQuery } from "#api/dto/BaseDto"; import { CreateContactDto, GetContactDto, @@ -37,43 +37,43 @@ import { GetContributionInfoDto, ListContactsDto, UpdateContactDto -} from "@api/dto/ContactDto"; +} from "#api/dto/ContactDto"; import { CreateContactMfaDto, DeleteContactMfaDto, GetContactMfaDto -} from "@api/dto/ContactMfaDto"; +} from "#api/dto/ContactMfaDto"; import { GetContactRoleDto, UpdateContactRoleDto -} from "@api/dto/ContactRoleDto"; +} from "#api/dto/ContactRoleDto"; import { StartContributionDto, ForceUpdateContributionDto, UpdateContributionDto -} from "@api/dto/ContributionDto"; -import { CompleteJoinFlowDto, StartJoinFlowDto } from "@api/dto/JoinFlowDto"; -import { PaginatedDto } from "@api/dto/PaginatedDto"; -import { GetPaymentDto, ListPaymentsDto } from "@api/dto/PaymentDto"; -import { GetPaymentFlowDto } from "@api/dto/PaymentFlowDto"; - -import { CurrentAuth } from "@api/decorators/CurrentAuth"; -import PartialBody from "@api/decorators/PartialBody"; -import { TargetUser } from "@api/decorators/TargetUser"; -import { UnauthorizedError } from "@api/errors/UnauthorizedError"; -import CantUpdateContribution from "@api/errors/CantUpdateContribution"; -import NoPaymentMethod from "@api/errors/NoPaymentMethod"; -import { ContactRoleParams } from "@api/params/ContactRoleParams"; -import { mergeRules } from "@api/utils/rules"; - -import ContactExporter from "@api/transformers/ContactExporter"; -import ContactTransformer from "@api/transformers/ContactTransformer"; -import ContactRoleTransformer from "@api/transformers/ContactRoleTransformer"; -import PaymentTransformer from "@api/transformers/PaymentTransformer"; - -import { GetContactWith } from "@enums/get-contact-with"; - -import { AuthInfo } from "@type/auth-info"; +} from "#api/dto/ContributionDto"; +import { CompleteJoinFlowDto, StartJoinFlowDto } from "#api/dto/JoinFlowDto"; +import { PaginatedDto } from "#api/dto/PaginatedDto"; +import { GetPaymentDto, ListPaymentsDto } from "#api/dto/PaymentDto"; +import { GetPaymentFlowDto } from "#api/dto/PaymentFlowDto"; + +import { CurrentAuth } from "#api/decorators/CurrentAuth"; +import PartialBody from "#api/decorators/PartialBody"; +import { TargetUser } from "#api/decorators/TargetUser"; +import { UnauthorizedError } from "#api/errors/UnauthorizedError"; +import CantUpdateContribution from "#api/errors/CantUpdateContribution"; +import NoPaymentMethod from "#api/errors/NoPaymentMethod"; +import { ContactRoleParams } from "#api/params/ContactRoleParams"; +import { mergeRules } from "#api/utils/rules"; + +import ContactExporter from "#api/transformers/ContactExporter"; +import ContactTransformer from "#api/transformers/ContactTransformer"; +import ContactRoleTransformer from "#api/transformers/ContactRoleTransformer"; +import PaymentTransformer from "#api/transformers/PaymentTransformer"; + +import { GetContactWith } from "#enums/get-contact-with"; + +import { AuthInfo } from "#type/auth-info"; @JsonController("/contact") @Authorized() diff --git a/src/api/controllers/ContentController.ts b/src/api/controllers/ContentController.ts index c3d199478..b4f3fd756 100644 --- a/src/api/controllers/ContentController.ts +++ b/src/api/controllers/ContentController.ts @@ -7,7 +7,7 @@ import { Patch } from "routing-controllers"; -import PartialBody from "@api/decorators/PartialBody"; +import PartialBody from "#api/decorators/PartialBody"; import { GetContactsContentDto, GetContentDto, @@ -17,9 +17,9 @@ import { GetJoinSetupContentDto, GetProfileContentDto, GetShareContentDto -} from "@api/dto/ContentDto"; -import { ContentParams } from "@api/params/ContentParams"; -import ContentTransformer from "@api/transformers/ContentTransformer"; +} from "#api/dto/ContentDto"; +import { ContentParams } from "#api/params/ContentParams"; +import ContentTransformer from "#api/transformers/ContentTransformer"; @JsonController("/content") export class ContentController { diff --git a/src/api/controllers/EmailController.ts b/src/api/controllers/EmailController.ts index aa5cc4e45..e0f52a4df 100644 --- a/src/api/controllers/EmailController.ts +++ b/src/api/controllers/EmailController.ts @@ -9,14 +9,14 @@ import { Put } from "routing-controllers"; -import EmailService from "@core/services/EmailService"; +import EmailService from "#core/services/EmailService"; -import { getRepository } from "@core/database"; +import { getRepository } from "#core/database"; -import Email from "@models/Email"; +import Email from "#models/Email"; -import { GetEmailDto, UpdateEmailDto } from "@api/dto/EmailDto"; -import ExternalEmailTemplate from "@api/errors/ExternalEmailTemplate"; +import { GetEmailDto, UpdateEmailDto } from "#api/dto/EmailDto"; +import ExternalEmailTemplate from "#api/errors/ExternalEmailTemplate"; async function findEmail(id: string): Promise { if (isUUID(id, "4")) { diff --git a/src/api/controllers/NoticeController.ts b/src/api/controllers/NoticeController.ts index 9075184c6..01f1793c0 100644 --- a/src/api/controllers/NoticeController.ts +++ b/src/api/controllers/NoticeController.ts @@ -12,22 +12,22 @@ import { QueryParams } from "routing-controllers"; -import { getRepository } from "@core/database"; +import { getRepository } from "#core/database"; -import { CurrentAuth } from "@api/decorators/CurrentAuth"; -import PartialBody from "@api/decorators/PartialBody"; +import { CurrentAuth } from "#api/decorators/CurrentAuth"; +import PartialBody from "#api/decorators/PartialBody"; import { CreateNoticeDto, GetNoticeDto, ListNoticesDto -} from "@api/dto/NoticeDto"; -import { PaginatedDto } from "@api/dto/PaginatedDto"; -import { UUIDParams } from "@api/params/UUIDParams"; -import NoticeTransformer from "@api/transformers/NoticeTransformer"; +} from "#api/dto/NoticeDto"; +import { PaginatedDto } from "#api/dto/PaginatedDto"; +import { UUIDParams } from "#api/params/UUIDParams"; +import NoticeTransformer from "#api/transformers/NoticeTransformer"; -import Notice from "@models/Notice"; +import Notice from "#models/Notice"; -import { AuthInfo } from "@type/auth-info"; +import { AuthInfo } from "#type/auth-info"; @JsonController("/notice") @Authorized() diff --git a/src/api/controllers/PaymentController.ts b/src/api/controllers/PaymentController.ts index 2ed709d0d..8a7d5fef2 100644 --- a/src/api/controllers/PaymentController.ts +++ b/src/api/controllers/PaymentController.ts @@ -6,16 +6,16 @@ import { QueryParams } from "routing-controllers"; -import { CurrentAuth } from "@api/decorators/CurrentAuth"; -import { PaginatedDto } from "@api/dto/PaginatedDto"; +import { CurrentAuth } from "#api/decorators/CurrentAuth"; +import { PaginatedDto } from "#api/dto/PaginatedDto"; import { GetPaymentDto, GetPaymentOptsDto, ListPaymentsDto -} from "@api/dto/PaymentDto"; -import PaymentTransformer from "@api/transformers/PaymentTransformer"; +} from "#api/dto/PaymentDto"; +import PaymentTransformer from "#api/transformers/PaymentTransformer"; -import { AuthInfo } from "@type/auth-info"; +import { AuthInfo } from "#type/auth-info"; @JsonController("/payment") @Authorized() diff --git a/src/api/controllers/ResetDeviceController.ts b/src/api/controllers/ResetDeviceController.ts index 5ff0ebb41..6bbccdc2b 100644 --- a/src/api/controllers/ResetDeviceController.ts +++ b/src/api/controllers/ResetDeviceController.ts @@ -9,14 +9,14 @@ import { Req } from "routing-controllers"; -import ContactsService from "@core/services/ContactsService"; +import ContactsService from "#core/services/ContactsService"; -import { login } from "@api/utils"; +import { login } from "#api/utils"; import { CreateResetDeviceDto, UpdateResetDeviceDto -} from "@api/dto/ResetDeviceDto"; -import { UUIDParams } from "@api/params/UUIDParams"; +} from "#api/dto/ResetDeviceDto"; +import { UUIDParams } from "#api/params/UUIDParams"; @JsonController("/reset-device") export class ResetDeviceController { diff --git a/src/api/controllers/ResetPasswordController.ts b/src/api/controllers/ResetPasswordController.ts index 0e3f3a527..5a6598fd6 100644 --- a/src/api/controllers/ResetPasswordController.ts +++ b/src/api/controllers/ResetPasswordController.ts @@ -9,14 +9,14 @@ import { Req } from "routing-controllers"; -import ContactsService from "@core/services/ContactsService"; +import ContactsService from "#core/services/ContactsService"; -import { login } from "@api/utils"; +import { login } from "#api/utils"; import { CreateResetPasswordDto, UpdateResetPasswordDto -} from "@api/dto/ResetPasswordDto"; -import { UUIDParams } from "@api/params/UUIDParams"; +} from "#api/dto/ResetPasswordDto"; +import { UUIDParams } from "#api/params/UUIDParams"; @JsonController("/reset-password") export class ResetPasswordController { diff --git a/src/api/controllers/SegmentController.ts b/src/api/controllers/SegmentController.ts index 7434ba406..7c9b9dc49 100644 --- a/src/api/controllers/SegmentController.ts +++ b/src/api/controllers/SegmentController.ts @@ -12,28 +12,28 @@ import { QueryParams } from "routing-controllers"; -import { getRepository } from "@core/database"; +import { getRepository } from "#core/database"; -import { CurrentAuth } from "@api/decorators/CurrentAuth"; -import PartialBody from "@api/decorators/PartialBody"; -import { GetContactDto, ListContactsDto } from "@api/dto/ContactDto"; +import { CurrentAuth } from "#api/decorators/CurrentAuth"; +import PartialBody from "#api/decorators/PartialBody"; +import { GetContactDto, ListContactsDto } from "#api/dto/ContactDto"; import { GetSegmentDto, ListSegmentsDto, CreateSegmentDto, GetSegmentWith, GetSegmentOptsDto -} from "@api/dto/SegmentDto"; -import { PaginatedDto } from "@api/dto/PaginatedDto"; -import { UUIDParams } from "@api/params/UUIDParams"; -import ContactTransformer from "@api/transformers/ContactTransformer"; -import SegmentTransformer from "@api/transformers/SegmentTransformer"; +} from "#api/dto/SegmentDto"; +import { PaginatedDto } from "#api/dto/PaginatedDto"; +import { UUIDParams } from "#api/params/UUIDParams"; +import ContactTransformer from "#api/transformers/ContactTransformer"; +import SegmentTransformer from "#api/transformers/SegmentTransformer"; -import Segment from "@models/Segment"; -import SegmentContact from "@models/SegmentContact"; -import SegmentOngoingEmail from "@models/SegmentOngoingEmail"; +import Segment from "#models/Segment"; +import SegmentContact from "#models/SegmentContact"; +import SegmentOngoingEmail from "#models/SegmentOngoingEmail"; -import { AuthInfo } from "@type/auth-info"; +import { AuthInfo } from "#type/auth-info"; @JsonController("/segments") @Authorized("admin") @@ -113,9 +113,9 @@ export class SegmentController { ...query, rules: query.rules ? { - condition: "AND", - rules: [segment.ruleGroup, query.rules] - } + condition: "AND", + rules: [segment.ruleGroup, query.rules] + } : segment.ruleGroup }); } diff --git a/src/api/controllers/SignupController.ts b/src/api/controllers/SignupController.ts index 15e603c35..b7a639e18 100644 --- a/src/api/controllers/SignupController.ts +++ b/src/api/controllers/SignupController.ts @@ -9,21 +9,21 @@ import { Req } from "routing-controllers"; -import { getRepository } from "@core/database"; -import { generatePassword } from "@core/utils/auth"; +import { getRepository } from "#core/database"; +import { generatePassword } from "#core/utils/auth"; -import PaymentFlowService from "@core/services/PaymentFlowService"; +import PaymentFlowService from "#core/services/PaymentFlowService"; -import { GetPaymentFlowDto } from "@api/dto/PaymentFlowDto"; +import { GetPaymentFlowDto } from "#api/dto/PaymentFlowDto"; import { StartSignupFlowDto, CompleteSignupFlowDto -} from "@api/dto/SignupFlowDto"; -import { SignupConfirmEmailParams } from "@api/params/SignupConfirmEmailParams"; -import { login } from "@api/utils"; +} from "#api/dto/SignupFlowDto"; +import { SignupConfirmEmailParams } from "#api/params/SignupConfirmEmailParams"; +import { login } from "#api/utils"; -import JoinFlow from "@models/JoinFlow"; -import Password from "@models/Password"; +import JoinFlow from "#models/JoinFlow"; +import Password from "#models/Password"; @JsonController("/signup") export class SignupController { diff --git a/src/api/controllers/StatsController.ts b/src/api/controllers/StatsController.ts index 67b00ed9c..b61edfc1a 100644 --- a/src/api/controllers/StatsController.ts +++ b/src/api/controllers/StatsController.ts @@ -7,12 +7,12 @@ import { QueryParams } from "routing-controllers"; -import { createQueryBuilder } from "@core/database"; +import { createQueryBuilder } from "#core/database"; -import { GetStatsDto, GetStatsOptsDto } from "@api/dto/StatsDto"; +import { GetStatsDto, GetStatsOptsDto } from "#api/dto/StatsDto"; -import Contact from "@models/Contact"; -import Payment from "@models/Payment"; +import Contact from "#models/Contact"; +import Payment from "#models/Payment"; @JsonController("/stats") export class StatsController { diff --git a/src/api/controllers/UploadController.ts b/src/api/controllers/UploadController.ts index 1bb67f738..5e8202e10 100644 --- a/src/api/controllers/UploadController.ts +++ b/src/api/controllers/UploadController.ts @@ -14,14 +14,14 @@ import { } from "routing-controllers"; import { MoreThan } from "typeorm"; -import { getRepository } from "@core/database"; +import { getRepository } from "#core/database"; -import Contact from "@models/Contact"; -import UploadFlow from "@models/UploadFlow"; +import Contact from "#models/Contact"; +import UploadFlow from "#models/UploadFlow"; -import { GetUploadFlowDto } from "@api/dto/UploadFlowDto"; -import BadRequestError from "@api/errors/BadRequestError"; -import { UUIDParams } from "@api/params/UUIDParams"; +import { GetUploadFlowDto } from "#api/dto/UploadFlowDto"; +import BadRequestError from "#api/errors/BadRequestError"; +import { UUIDParams } from "#api/params/UUIDParams"; async function canUploadOrFail(ipAddress: string, date: Date, max: number) { const uploadFlows = await getRepository(UploadFlow).find({ diff --git a/src/api/decorators/CalloutId.ts b/src/api/decorators/CalloutId.ts index a9d844771..8665f5632 100644 --- a/src/api/decorators/CalloutId.ts +++ b/src/api/decorators/CalloutId.ts @@ -1,9 +1,9 @@ import { isUUID } from "class-validator"; import { NotFoundError, createParamDecorator } from "routing-controllers"; -import { getRepository } from "@core/database"; +import { getRepository } from "#core/database"; -import Callout from "@models/Callout"; +import Callout from "#models/Callout"; /** * Allows the use of either a callout ID or slug in the route diff --git a/src/api/decorators/CurrentAuth.ts b/src/api/decorators/CurrentAuth.ts index e1cf14c80..961e641b9 100644 --- a/src/api/decorators/CurrentAuth.ts +++ b/src/api/decorators/CurrentAuth.ts @@ -1,9 +1,9 @@ import { Request } from "express"; import { createParamDecorator } from "routing-controllers"; -import UnauthorizedError from "@api/errors/UnauthorizedError"; +import UnauthorizedError from "#api/errors/UnauthorizedError"; -import { AuthInfo } from "@type/auth-info"; +import { AuthInfo } from "#type/auth-info"; export function CurrentAuth(options?: { required?: boolean }) { return createParamDecorator({ diff --git a/src/api/decorators/TargetUser.ts b/src/api/decorators/TargetUser.ts index 8004cbefb..47e4982a9 100644 --- a/src/api/decorators/TargetUser.ts +++ b/src/api/decorators/TargetUser.ts @@ -5,12 +5,12 @@ import { createParamDecorator } from "routing-controllers"; -import ContactsService from "@core/services/ContactsService"; +import ContactsService from "#core/services/ContactsService"; -import { UUIDParams } from "@api/params/UUIDParams"; -import { validateOrReject } from "@api/utils"; +import { UUIDParams } from "#api/params/UUIDParams"; +import { validateOrReject } from "#api/utils"; -import Contact from "@models/Contact"; +import Contact from "#models/Contact"; /** * The target user can either be the current user or for admins diff --git a/src/api/dto/AddressDto.ts b/src/api/dto/AddressDto.ts index 0d4ba83ed..4d056e938 100644 --- a/src/api/dto/AddressDto.ts +++ b/src/api/dto/AddressDto.ts @@ -1,4 +1,4 @@ -import Address from "@models/Address"; +import Address from "#models/Address"; import { IsDefined, IsOptional, IsString } from "class-validator"; export class UpdateAddressDto implements Address { @@ -19,4 +19,4 @@ export class UpdateAddressDto implements Address { postcode!: string; } -export class GetAddressDto extends UpdateAddressDto {} +export class GetAddressDto extends UpdateAddressDto { } diff --git a/src/api/dto/ApiKeyDto.ts b/src/api/dto/ApiKeyDto.ts index ebd34c39e..01cb9a9fc 100644 --- a/src/api/dto/ApiKeyDto.ts +++ b/src/api/dto/ApiKeyDto.ts @@ -7,8 +7,8 @@ import { } from "class-validator"; import { Type } from "class-transformer"; -import { GetPaginatedQuery } from "@api/dto/BaseDto"; -import { GetContactDto } from "@api/dto/ContactDto"; +import { GetPaginatedQuery } from "#api/dto/BaseDto"; +import { GetContactDto } from "#api/dto/ContactDto"; export class CreateApiKeyDto { @IsString() diff --git a/src/api/dto/BaseDto.ts b/src/api/dto/BaseDto.ts index d51c8a794..6c2a7e2df 100644 --- a/src/api/dto/BaseDto.ts +++ b/src/api/dto/BaseDto.ts @@ -23,7 +23,7 @@ import { Max } from "class-validator"; -import { IsType } from "@api/validators/IsType"; +import { IsType } from "#api/validators/IsType"; export class GetPaginatedRule implements Rule { @IsString() @@ -68,8 +68,7 @@ export class GetExportQuery { export class GetPaginatedQuery extends GetExportQuery - implements PaginatedQuery -{ + implements PaginatedQuery { @IsOptional() @Min(1) @Max(100) diff --git a/src/api/dto/CalloutDto.ts b/src/api/dto/CalloutDto.ts index 56081eb94..d2df47d39 100644 --- a/src/api/dto/CalloutDto.ts +++ b/src/api/dto/CalloutDto.ts @@ -20,22 +20,22 @@ import { ValidateNested } from "class-validator"; -import { GetExportQuery, GetPaginatedQuery } from "@api/dto/BaseDto"; -import { GetCalloutFormDto, SetCalloutFormDto } from "@api/dto/CalloutFormDto"; -import { CalloutVariantDto } from "@api/dto/CalloutVariantDto"; -import { LinkDto } from "@api/dto/LinkDto"; -import IsSlug from "@api/validators/IsSlug"; -import IsUrl from "@api/validators/IsUrl"; -import IsMapBounds from "@api/validators/IsMapBounds"; -import IsLngLat from "@api/validators/IsLngLat"; -import IsVariantsObject from "@api/validators/IsVariantsObject"; - -import { CalloutAccess } from "@enums/callout-access"; -import { CalloutCaptcha } from "@enums/callout-captcha"; - -import { CalloutData } from "@type/callout-data"; -import { CalloutMapSchema } from "@type/callout-map-schema"; -import { CalloutResponseViewSchema } from "@type/callout-response-view-schema"; +import { GetExportQuery, GetPaginatedQuery } from "#api/dto/BaseDto"; +import { GetCalloutFormDto, SetCalloutFormDto } from "#api/dto/CalloutFormDto"; +import { CalloutVariantDto } from "#api/dto/CalloutVariantDto"; +import { LinkDto } from "#api/dto/LinkDto"; +import IsSlug from "#api/validators/IsSlug"; +import IsUrl from "#api/validators/IsUrl"; +import IsMapBounds from "#api/validators/IsMapBounds"; +import IsLngLat from "#api/validators/IsLngLat"; +import IsVariantsObject from "#api/validators/IsVariantsObject"; + +import { CalloutAccess } from "#enums/callout-access"; +import { CalloutCaptcha } from "#enums/callout-captcha"; + +import { CalloutData } from "#type/callout-data"; +import { CalloutMapSchema } from "#type/callout-map-schema"; +import { CalloutResponseViewSchema } from "#type/callout-response-view-schema"; export enum GetCalloutWith { Form = "form", diff --git a/src/api/dto/CalloutFormDto.ts b/src/api/dto/CalloutFormDto.ts index f17cd7cf2..313faf8be 100644 --- a/src/api/dto/CalloutFormDto.ts +++ b/src/api/dto/CalloutFormDto.ts @@ -26,7 +26,7 @@ import { validate } from "class-validator"; -import { log as mainLogger } from "@core/logging"; +import { log as mainLogger } from "#core/logging"; const log = mainLogger.child({ app: "callout-form-validation" }); @@ -84,8 +84,7 @@ class ContentCalloutComponentDto extends BaseCalloutComponentDto { class InputCalloutComponentDto extends BaseCalloutComponentDto - implements InputCalloutComponentSchema -{ + implements InputCalloutComponentSchema { @IsIn(inputTypes) type!: (typeof inputTypes)[number]; @@ -109,8 +108,7 @@ class SelectCalloutComponentDataDto { class SelectCalloutComponentDto extends BaseCalloutComponentDto - implements SelectCalloutComponentSchema -{ + implements SelectCalloutComponentSchema { @IsIn(selectTypes) type!: (typeof selectTypes)[number]; @@ -136,8 +134,7 @@ class RadioCalloutComponentValueDto { class RadioCalloutComponentDto extends BaseCalloutComponentDto - implements RadioCalloutComponentSchema -{ + implements RadioCalloutComponentSchema { @IsIn(radioTypes) type!: (typeof radioTypes)[number]; @@ -214,8 +211,7 @@ type CalloutComponentDto = class NestableCalloutComponentDto extends BaseCalloutComponentDto - implements NestableCalloutComponentSchema -{ + implements NestableCalloutComponentSchema { @IsIn(nestedTypes) type!: (typeof nestedTypes)[number]; diff --git a/src/api/dto/CalloutResponseCommentDto.ts b/src/api/dto/CalloutResponseCommentDto.ts index dfca1626c..53e55f34e 100644 --- a/src/api/dto/CalloutResponseCommentDto.ts +++ b/src/api/dto/CalloutResponseCommentDto.ts @@ -1,7 +1,7 @@ import { IsDate, IsIn, IsString, ValidateNested } from "class-validator"; -import { GetPaginatedQuery } from "@api/dto/BaseDto"; -import { GetContactDto } from "@api/dto/ContactDto"; +import { GetPaginatedQuery } from "#api/dto/BaseDto"; +import { GetContactDto } from "#api/dto/ContactDto"; export class CreateCalloutResponseCommentDto { @IsString() diff --git a/src/api/dto/CalloutResponseDto.ts b/src/api/dto/CalloutResponseDto.ts index 8e24af956..1a59adf31 100644 --- a/src/api/dto/CalloutResponseDto.ts +++ b/src/api/dto/CalloutResponseDto.ts @@ -25,15 +25,15 @@ import { GetExportQuery, GetPaginatedQuery, GetPaginatedRuleGroup -} from "@api/dto/BaseDto"; -import { GetContactDto } from "@api/dto/ContactDto"; -import { GetCalloutDto } from "@api/dto/CalloutDto"; -import { GetCalloutResponseCommentDto } from "@api/dto/CalloutResponseCommentDto"; -import { GetCalloutTagDto } from "@api/dto/CalloutTagDto"; +} from "#api/dto/BaseDto"; +import { GetContactDto } from "#api/dto/ContactDto"; +import { GetCalloutDto } from "#api/dto/CalloutDto"; +import { GetCalloutResponseCommentDto } from "#api/dto/CalloutResponseCommentDto"; +import { GetCalloutTagDto } from "#api/dto/CalloutTagDto"; -import Callout from "@models/Callout"; +import Callout from "#models/Callout"; -import { CalloutResponseViewSchema } from "@type/callout-response-view-schema"; +import { CalloutResponseViewSchema } from "#type/callout-response-view-schema"; export interface BaseGetCalloutResponseOptsDto { callout?: Callout; @@ -65,9 +65,9 @@ export class ListCalloutResponsesDto extends GetPaginatedQuery { // TODO: this is a bit hacky export interface GetCalloutResponseOptsDto - extends BaseGetCalloutResponseOptsDto {} + extends BaseGetCalloutResponseOptsDto { } export interface ListCalloutResponsesDto - extends BaseGetCalloutResponseOptsDto {} + extends BaseGetCalloutResponseOptsDto { } export class GetCalloutResponseDto { @IsString() @@ -179,7 +179,7 @@ export type ExportCalloutResponseDto = [ export interface ExportCalloutResponsesOptsDto extends GetExportQuery, - BaseGetCalloutResponseOptsDto { + BaseGetCalloutResponseOptsDto { callout: Callout; components: (CalloutComponentSchema & { slideId: string })[]; } diff --git a/src/api/dto/CalloutTagDto.ts b/src/api/dto/CalloutTagDto.ts index 3329926f4..cf2158593 100644 --- a/src/api/dto/CalloutTagDto.ts +++ b/src/api/dto/CalloutTagDto.ts @@ -1,6 +1,6 @@ import { IsIn, IsString } from "class-validator"; -import { GetPaginatedQuery } from "@api/dto/BaseDto"; +import { GetPaginatedQuery } from "#api/dto/BaseDto"; export class GetCalloutTagDto { @IsString() diff --git a/src/api/dto/CalloutVariantDto.ts b/src/api/dto/CalloutVariantDto.ts index f8489c24b..8a9fed04c 100644 --- a/src/api/dto/CalloutVariantDto.ts +++ b/src/api/dto/CalloutVariantDto.ts @@ -1,7 +1,7 @@ import { CalloutVariantData, CalloutVariantNavigationData -} from "@type/callout-variant-data"; +} from "#type/callout-variant-data"; import { IsString, IsOptional, IsUrl, IsObject } from "class-validator"; export class CalloutVariantDto implements CalloutVariantData { diff --git a/src/api/dto/ContactDto.ts b/src/api/dto/ContactDto.ts index 201e85f70..2663eeea1 100644 --- a/src/api/dto/ContactDto.ts +++ b/src/api/dto/ContactDto.ts @@ -22,23 +22,23 @@ import { ValidateNested } from "class-validator"; -import { GetPaginatedQuery } from "@api/dto/BaseDto"; +import { GetPaginatedQuery } from "#api/dto/BaseDto"; import { GetContactProfileDto, UpdateContactProfileDto -} from "@api/dto/ContactProfileDto"; +} from "#api/dto/ContactProfileDto"; import { CreateContactRoleDto, GetContactRoleDto -} from "@api/dto/ContactRoleDto"; -import { ForceUpdateContributionDto } from "@api/dto/ContributionDto"; +} from "#api/dto/ContactRoleDto"; +import { ForceUpdateContributionDto } from "#api/dto/ContributionDto"; -import IsPassword from "@api/validators/IsPassword"; +import IsPassword from "#api/validators/IsPassword"; -import { GetContactWith } from "@enums/get-contact-with"; +import { GetContactWith } from "#enums/get-contact-with"; -import { ContributionInfo } from "@type/contribution-info"; -import { PaymentSource } from "@type/payment-source"; +import { ContributionInfo } from "#type/contribution-info"; +import { PaymentSource } from "#type/payment-source"; const contactSortFields = [ "firstname", diff --git a/src/api/dto/ContactMfaDto.ts b/src/api/dto/ContactMfaDto.ts index ba1858cbd..da4bc1ffe 100644 --- a/src/api/dto/ContactMfaDto.ts +++ b/src/api/dto/ContactMfaDto.ts @@ -1,10 +1,10 @@ import { IsOptional, IsString } from "class-validator"; -import { CONTACT_MFA_TYPE } from "@enums/contact-mfa-type"; +import { CONTACT_MFA_TYPE } from "#enums/contact-mfa-type"; -import { CreateContactMfaData } from "@type/create-contact-mfa-data"; -import { DeleteContactMfaData } from "@type/delete-contact-mfa-data"; -import { ContactMfaSecure } from "@type/contact-mfa-secure"; +import { CreateContactMfaData } from "#type/create-contact-mfa-data"; +import { DeleteContactMfaData } from "#type/delete-contact-mfa-data"; +import { ContactMfaSecure } from "#type/contact-mfa-secure"; /** * Get contact multi factor authentication validation data diff --git a/src/api/dto/ContactProfileDto.ts b/src/api/dto/ContactProfileDto.ts index eee5f90aa..119f70e07 100644 --- a/src/api/dto/ContactProfileDto.ts +++ b/src/api/dto/ContactProfileDto.ts @@ -9,7 +9,7 @@ import { ValidateNested } from "class-validator"; -import { GetAddressDto, UpdateAddressDto } from "@api/dto/AddressDto"; +import { GetAddressDto, UpdateAddressDto } from "#api/dto/AddressDto"; export class GetContactProfileDto { @IsString() diff --git a/src/api/dto/ContentDto.ts b/src/api/dto/ContentDto.ts index 661356151..0f5e1541d 100644 --- a/src/api/dto/ContentDto.ts +++ b/src/api/dto/ContentDto.ts @@ -14,9 +14,9 @@ import { ValidateNested } from "class-validator"; -import { LinkDto } from "@api/dto/LinkDto"; +import { LinkDto } from "#api/dto/LinkDto"; -import { Locale } from "@locale"; +import { Locale } from "#locale"; import { ContactsContentData, @@ -27,8 +27,8 @@ import { JoinSetupContentData, ProfileContentData, ShareContentData -} from "@type/content-data"; -import { ContentId } from "@type/content-id"; +} from "#type/content-data"; +import { ContentId } from "#type/content-id"; export class GetContactsContentDto implements ContactsContentData { @IsString({ each: true }) @@ -197,17 +197,17 @@ export class GetShareContentDto implements ShareContentData { export type GetContentDto = Id extends "contacts" - ? GetContactsContentDto - : never | Id extends "email" - ? GetEmailContentDto - : never | Id extends "general" - ? GetGeneralContentDto - : never | Id extends "join" - ? GetJoinContentDto - : never | Id extends "join/setup" - ? GetJoinSetupContentDto - : never | Id extends "profile" - ? GetProfileContentDto - : never | Id extends "share" - ? GetShareContentDto - : never; + ? GetContactsContentDto + : never | Id extends "email" + ? GetEmailContentDto + : never | Id extends "general" + ? GetGeneralContentDto + : never | Id extends "join" + ? GetJoinContentDto + : never | Id extends "join/setup" + ? GetJoinSetupContentDto + : never | Id extends "profile" + ? GetProfileContentDto + : never | Id extends "share" + ? GetShareContentDto + : never; diff --git a/src/api/dto/ContributionDto.ts b/src/api/dto/ContributionDto.ts index 5908fe1b6..ce9cf8b42 100644 --- a/src/api/dto/ContributionDto.ts +++ b/src/api/dto/ContributionDto.ts @@ -13,9 +13,9 @@ import { Validate } from "class-validator"; -import IsUrl from "@api/validators/IsUrl"; -import MinContributionAmount from "@api/validators/MinContributionAmount"; -import ValidPayFee from "@api/validators/ValidPayFee"; +import IsUrl from "#api/validators/IsUrl"; +import MinContributionAmount from "#api/validators/MinContributionAmount"; +import ValidPayFee from "#api/validators/ValidPayFee"; import { StartJoinFlowDto } from "./JoinFlowDto"; @@ -41,8 +41,7 @@ export class UpdateContributionDto { export class StartContributionDto extends UpdateContributionDto - implements StartJoinFlowDto -{ + implements StartJoinFlowDto { @IsUrl() completeUrl!: string; diff --git a/src/api/dto/JoinFlowDto.ts b/src/api/dto/JoinFlowDto.ts index 182171aeb..11b8bbd7f 100644 --- a/src/api/dto/JoinFlowDto.ts +++ b/src/api/dto/JoinFlowDto.ts @@ -1,5 +1,5 @@ import { PaymentMethod } from "@beabee/beabee-common"; -import IsUrl from "@api/validators/IsUrl"; +import IsUrl from "#api/validators/IsUrl"; import { IsEnum, IsOptional, IsString } from "class-validator"; export class StartJoinFlowDto { diff --git a/src/api/dto/NoticeDto.ts b/src/api/dto/NoticeDto.ts index 22055dd13..b61891725 100644 --- a/src/api/dto/NoticeDto.ts +++ b/src/api/dto/NoticeDto.ts @@ -2,7 +2,7 @@ import { ItemStatus } from "@beabee/beabee-common"; import { Type } from "class-transformer"; import { IsDate, IsEnum, IsIn, IsOptional, IsString } from "class-validator"; -import { GetPaginatedQuery } from "@api/dto/BaseDto"; +import { GetPaginatedQuery } from "#api/dto/BaseDto"; const sortFields = ["createdAt", "updatedAt", "name", "expires"] as const; diff --git a/src/api/dto/PaymentDto.ts b/src/api/dto/PaymentDto.ts index ae30fbead..9e1fd8c13 100644 --- a/src/api/dto/PaymentDto.ts +++ b/src/api/dto/PaymentDto.ts @@ -9,8 +9,8 @@ import { ValidateNested } from "class-validator"; -import { GetPaginatedQuery } from "@api/dto/BaseDto"; -import { GetContactDto } from "@api/dto/ContactDto"; +import { GetPaginatedQuery } from "#api/dto/BaseDto"; +import { GetContactDto } from "#api/dto/ContactDto"; export class GetPaymentDto { @IsNumber() diff --git a/src/api/dto/PaymentFlowDto.ts b/src/api/dto/PaymentFlowDto.ts index 9f5b689da..e10f7a3f3 100644 --- a/src/api/dto/PaymentFlowDto.ts +++ b/src/api/dto/PaymentFlowDto.ts @@ -1,6 +1,6 @@ import { IsOptional, IsString } from "class-validator"; -import { PaymentFlowParams } from "@core/providers/payment-flow"; +import { PaymentFlowParams } from "#core/providers/payment-flow"; export class GetPaymentFlowDto implements PaymentFlowParams { @IsOptional() diff --git a/src/api/dto/ResetDeviceDto.ts b/src/api/dto/ResetDeviceDto.ts index ec3a49db9..e31b8ca59 100644 --- a/src/api/dto/ResetDeviceDto.ts +++ b/src/api/dto/ResetDeviceDto.ts @@ -1,7 +1,7 @@ import { IsEmail, Validate, IsIn } from "class-validator"; -import IsPassword from "@api/validators/IsPassword"; -import IsUrl from "@api/validators/IsUrl"; -import { RESET_SECURITY_FLOW_TYPE } from "@enums/reset-security-flow-type"; +import IsPassword from "#api/validators/IsPassword"; +import IsUrl from "#api/validators/IsUrl"; +import { RESET_SECURITY_FLOW_TYPE } from "#enums/reset-security-flow-type"; export class CreateResetDeviceDto { @IsEmail() diff --git a/src/api/dto/ResetPasswordDto.ts b/src/api/dto/ResetPasswordDto.ts index 0945f2d2d..4d40ff096 100644 --- a/src/api/dto/ResetPasswordDto.ts +++ b/src/api/dto/ResetPasswordDto.ts @@ -1,6 +1,6 @@ import { IsEmail, Validate, IsOptional, IsString } from "class-validator"; -import IsPassword from "@api/validators/IsPassword"; -import IsUrl from "@api/validators/IsUrl"; +import IsPassword from "#api/validators/IsPassword"; +import IsUrl from "#api/validators/IsUrl"; export class CreateResetPasswordDto { @IsEmail() diff --git a/src/api/dto/SegmentDto.ts b/src/api/dto/SegmentDto.ts index 10759ff18..7d662270c 100644 --- a/src/api/dto/SegmentDto.ts +++ b/src/api/dto/SegmentDto.ts @@ -8,7 +8,7 @@ import { ValidateNested } from "class-validator"; -import { GetPaginatedQuery, GetPaginatedRuleGroup } from "@api/dto/BaseDto"; +import { GetPaginatedQuery, GetPaginatedRuleGroup } from "#api/dto/BaseDto"; export enum GetSegmentWith { contactCount = "contactCount" diff --git a/src/api/dto/SignupFlowDto.ts b/src/api/dto/SignupFlowDto.ts index adda78ab7..5e7b50b44 100644 --- a/src/api/dto/SignupFlowDto.ts +++ b/src/api/dto/SignupFlowDto.ts @@ -7,12 +7,12 @@ import { IsString } from "class-validator"; -import { StartContributionDto } from "@api/dto/ContributionDto"; -import { CompleteJoinFlowDto } from "@api/dto/JoinFlowDto"; -import IsPassword from "@api/validators/IsPassword"; -import IsUrl from "@api/validators/IsUrl"; +import { StartContributionDto } from "#api/dto/ContributionDto"; +import { CompleteJoinFlowDto } from "#api/dto/JoinFlowDto"; +import IsPassword from "#api/validators/IsPassword"; +import IsUrl from "#api/validators/IsUrl"; -import { CompleteUrls } from "@type/complete-urls"; +import { CompleteUrls } from "#type/complete-urls"; export class StartSignupFlowDto implements CompleteUrls { @IsUrl() diff --git a/src/api/interceptors/ValidateResponseInterceptor.ts b/src/api/interceptors/ValidateResponseInterceptor.ts index 3991c86bf..2ebefc647 100644 --- a/src/api/interceptors/ValidateResponseInterceptor.ts +++ b/src/api/interceptors/ValidateResponseInterceptor.ts @@ -8,8 +8,8 @@ import { InternalServerError } from "routing-controllers"; -import { log as mainLogger } from "@core/logging"; -import { validateOrReject } from "@api/utils"; +import { log as mainLogger } from "#core/logging"; +import { validateOrReject } from "#api/utils"; const log = mainLogger.child({ app: "validate-response-interceptor" }); diff --git a/src/api/middlewares/AuthMiddleware.ts b/src/api/middlewares/AuthMiddleware.ts index 275aaa1b9..efaa62e0a 100644 --- a/src/api/middlewares/AuthMiddleware.ts +++ b/src/api/middlewares/AuthMiddleware.ts @@ -3,14 +3,14 @@ import crypto from "node:crypto"; import { Request, Response } from "express"; import { Middleware, ExpressMiddlewareInterface } from "routing-controllers"; -import { getRepository } from "@core/database"; +import { getRepository } from "#core/database"; -import ContactsService from "@core/services/ContactsService"; -import { extractToken } from "@core/utils/auth"; +import ContactsService from "#core/services/ContactsService"; +import { extractToken } from "#core/utils/auth"; -import ApiKey from "@models/ApiKey"; +import ApiKey from "#models/ApiKey"; -import { AuthInfo } from "@type/auth-info"; +import { AuthInfo } from "#type/auth-info"; @Middleware({ type: "before" }) export class AuthMiddleware implements ExpressMiddlewareInterface { diff --git a/src/api/params/ContentParams.ts b/src/api/params/ContentParams.ts index 7e02087ce..85fcabee2 100644 --- a/src/api/params/ContentParams.ts +++ b/src/api/params/ContentParams.ts @@ -1,4 +1,4 @@ -import { ContentId } from "@type/content-id"; +import { ContentId } from "#type/content-id"; import { IsIn } from "class-validator"; export class ContentParams { diff --git a/src/api/transformers/AddressTransformer.ts b/src/api/transformers/AddressTransformer.ts index 76829b1d3..66c0b651c 100644 --- a/src/api/transformers/AddressTransformer.ts +++ b/src/api/transformers/AddressTransformer.ts @@ -1,6 +1,6 @@ -import { GetAddressDto } from "@api/dto/AddressDto"; +import { GetAddressDto } from "#api/dto/AddressDto"; -import Address from "@models/Address"; +import Address from "#models/Address"; import { TransformPlainToInstance } from "class-transformer"; // TODO: make Address into a proper model diff --git a/src/api/transformers/ApiKeyTransformer.ts b/src/api/transformers/ApiKeyTransformer.ts index bd8165163..a6d250d9c 100644 --- a/src/api/transformers/ApiKeyTransformer.ts +++ b/src/api/transformers/ApiKeyTransformer.ts @@ -6,9 +6,9 @@ import { import { TransformPlainToInstance } from "class-transformer"; import { SelectQueryBuilder } from "typeorm"; -import { GetApiKeyDto } from "@api/dto/ApiKeyDto"; +import { GetApiKeyDto } from "#api/dto/ApiKeyDto"; -import ApiKey from "@models/ApiKey"; +import ApiKey from "#models/ApiKey"; import { BaseTransformer } from "./BaseTransformer"; import ContactTransformer, { loadContactRoles } from "./ContactTransformer"; diff --git a/src/api/transformers/BaseCalloutResponseTransformer.ts b/src/api/transformers/BaseCalloutResponseTransformer.ts index 18f25d648..600c4c17b 100644 --- a/src/api/transformers/BaseCalloutResponseTransformer.ts +++ b/src/api/transformers/BaseCalloutResponseTransformer.ts @@ -7,17 +7,17 @@ import { RuleOperator } from "@beabee/beabee-common"; -import { createQueryBuilder } from "@core/database"; +import { createQueryBuilder } from "#core/database"; -import { BaseGetCalloutResponseOptsDto } from "@api/dto/CalloutResponseDto"; -import { BaseTransformer } from "@api/transformers/BaseTransformer"; -import { mergeRules } from "@api/utils/rules"; +import { BaseGetCalloutResponseOptsDto } from "#api/dto/CalloutResponseDto"; +import { BaseTransformer } from "#api/transformers/BaseTransformer"; +import { mergeRules } from "#api/utils/rules"; -import CalloutResponse from "@models/CalloutResponse"; -import CalloutResponseTag from "@models/CalloutResponseTag"; +import CalloutResponse from "#models/CalloutResponse"; +import CalloutResponseTag from "#models/CalloutResponseTag"; -import { AuthInfo } from "@type/auth-info"; -import { FilterHandler, FilterHandlers } from "@type/filter-handlers"; +import { AuthInfo } from "#type/auth-info"; +import { FilterHandler, FilterHandlers } from "#type/filter-handlers"; export abstract class BaseCalloutResponseTransformer< GetDto, @@ -35,9 +35,9 @@ export abstract class BaseCalloutResponseTransformer< protected transformFilters( query: GetOptsDto & PaginatedQuery ): [ - Partial>, - FilterHandlers - ] { + Partial>, + FilterHandlers + ] { // If looking for responses for a particular callout then add answer filtering if (query.callout) { const answerFilters = getCalloutFilters(query.callout.formSchema); diff --git a/src/api/transformers/BaseTransformer.ts b/src/api/transformers/BaseTransformer.ts index 4b6e0f252..fc9046fe2 100644 --- a/src/api/transformers/BaseTransformer.ts +++ b/src/api/transformers/BaseTransformer.ts @@ -8,18 +8,18 @@ import { import { plainToInstance } from "class-transformer"; import { ObjectLiteral, SelectQueryBuilder } from "typeorm"; -import { createQueryBuilder } from "@core/database"; +import { createQueryBuilder } from "#core/database"; -import { PaginatedDto } from "@api/dto/PaginatedDto"; -import NotFoundError from "@api/errors/NotFoundError"; -import InvalidRuleError from "@api/errors/InvalidRuleError"; -import UnauthorizedError from "@api/errors/UnauthorizedError"; -import { convertRulesToWhereClause } from "@api/utils/rules"; +import { PaginatedDto } from "#api/dto/PaginatedDto"; +import NotFoundError from "#api/errors/NotFoundError"; +import InvalidRuleError from "#api/errors/InvalidRuleError"; +import UnauthorizedError from "#api/errors/UnauthorizedError"; +import { convertRulesToWhereClause } from "#api/utils/rules"; -import Contact from "@models/Contact"; +import Contact from "#models/Contact"; -import { AuthInfo } from "@type/auth-info"; -import { FilterHandlers } from "@type/filter-handlers"; +import { AuthInfo } from "#type/auth-info"; +import { FilterHandlers } from "#type/filter-handlers"; /** * Base transformer for querying and converting models to DTOs @@ -31,7 +31,7 @@ export abstract class BaseTransformer< GetDtoOpts = unknown, Query extends GetDtoOpts & PaginatedQuery = GetDtoOpts & PaginatedQuery > { - protected abstract model: { new (): Model }; + protected abstract model: { new(): Model }; protected modelIdField = "id"; protected abstract filters: Filters; @@ -91,7 +91,7 @@ export abstract class BaseTransformer< fieldPrefix: string, query: Query, auth: AuthInfo | undefined - ): void {} + ): void { } /** * Modify the items after they are fetched. @@ -107,7 +107,7 @@ export abstract class BaseTransformer< items: Model[], query: Query, auth: AuthInfo | undefined - ): Promise {} + ): Promise { } /** * Check for sufficient authentication and prepare the query, diff --git a/src/api/transformers/CalloutResponseCommentTransformer.ts b/src/api/transformers/CalloutResponseCommentTransformer.ts index aa66d8d8f..382019843 100644 --- a/src/api/transformers/CalloutResponseCommentTransformer.ts +++ b/src/api/transformers/CalloutResponseCommentTransformer.ts @@ -8,16 +8,16 @@ import { SelectQueryBuilder } from "typeorm"; import { GetCalloutResponseCommentDto, ListCalloutResponseCommentsDto -} from "@api/dto/CalloutResponseCommentDto"; -import { BaseTransformer } from "@api/transformers/BaseTransformer"; +} from "#api/dto/CalloutResponseCommentDto"; +import { BaseTransformer } from "#api/transformers/BaseTransformer"; import ContactTransformer, { loadContactRoles -} from "@api/transformers/ContactTransformer"; -import { mergeRules } from "@api/utils/rules"; +} from "#api/transformers/ContactTransformer"; +import { mergeRules } from "#api/utils/rules"; -import CalloutResponseComment from "@models/CalloutResponseComment"; +import CalloutResponseComment from "#models/CalloutResponseComment"; -import { AuthInfo } from "@type/auth-info"; +import { AuthInfo } from "#type/auth-info"; class CalloutResponseCommentTransformer extends BaseTransformer< CalloutResponseComment, diff --git a/src/api/transformers/CalloutResponseExporter.ts b/src/api/transformers/CalloutResponseExporter.ts index abd063427..ae49c767d 100644 --- a/src/api/transformers/CalloutResponseExporter.ts +++ b/src/api/transformers/CalloutResponseExporter.ts @@ -7,22 +7,22 @@ import { stringify } from "csv-stringify/sync"; import { format } from "date-fns"; import { In, SelectQueryBuilder } from "typeorm"; -import { getRepository } from "@core/database"; +import { getRepository } from "#core/database"; -import { GetExportQuery } from "@api/dto/BaseDto"; +import { GetExportQuery } from "#api/dto/BaseDto"; import { ExportCalloutResponseDto, ExportCalloutResponsesOptsDto -} from "@api/dto/CalloutResponseDto"; -import { BaseCalloutResponseTransformer } from "@api/transformers/BaseCalloutResponseTransformer"; -import NotFoundError from "@api/errors/NotFoundError"; -import { groupBy } from "@api/utils"; +} from "#api/dto/CalloutResponseDto"; +import { BaseCalloutResponseTransformer } from "#api/transformers/BaseCalloutResponseTransformer"; +import NotFoundError from "#api/errors/NotFoundError"; +import { groupBy } from "#api/utils"; -import CalloutResponse from "@models/CalloutResponse"; -import CalloutResponseComment from "@models/CalloutResponseComment"; -import Callout from "@models/Callout"; +import CalloutResponse from "#models/CalloutResponse"; +import CalloutResponseComment from "#models/CalloutResponseComment"; +import Callout from "#models/Callout"; -import { AuthInfo } from "@type/auth-info"; +import { AuthInfo } from "#type/auth-info"; class CalloutResponseExporter extends BaseCalloutResponseTransformer< ExportCalloutResponseDto, @@ -36,11 +36,11 @@ class CalloutResponseExporter extends BaseCalloutResponseTransformer< ): ExportCalloutResponseDto { const contact: [string, string, string, string] = response.contact ? [ - response.contact.firstname, - response.contact.lastname, - response.contact.fullname, - response.contact.email - ] + response.contact.firstname, + response.contact.lastname, + response.contact.fullname, + response.contact.email + ] : ["", "", response.guestName || "", response.guestEmail || ""]; return [ @@ -110,9 +110,8 @@ class CalloutResponseExporter extends BaseCalloutResponseTransformer< components }); - const exportName = `responses-${ - callout.slug - }_${new Date().toISOString()}.csv`; + const exportName = `responses-${callout.slug + }_${new Date().toISOString()}.csv`; const headers = [ "Date", diff --git a/src/api/transformers/CalloutResponseMapTransformer.ts b/src/api/transformers/CalloutResponseMapTransformer.ts index 1f3f45b72..d019bb118 100644 --- a/src/api/transformers/CalloutResponseMapTransformer.ts +++ b/src/api/transformers/CalloutResponseMapTransformer.ts @@ -8,24 +8,24 @@ import { } from "@beabee/beabee-common"; import { TransformPlainToInstance } from "class-transformer"; -import { getRepository } from "@core/database"; +import { getRepository } from "#core/database"; import { GetCalloutResponseMapDto, GetCalloutResponseMapOptsDto, ListCalloutResponseMapDto, ListCalloutResponsesDto -} from "@api/dto/CalloutResponseDto"; -import { PaginatedDto } from "@api/dto/PaginatedDto"; -import NotFoundError from "@api/errors/NotFoundError"; -import { BaseCalloutResponseTransformer } from "@api/transformers/BaseCalloutResponseTransformer"; -import { mergeRules } from "@api/utils/rules"; +} from "#api/dto/CalloutResponseDto"; +import { PaginatedDto } from "#api/dto/PaginatedDto"; +import NotFoundError from "#api/errors/NotFoundError"; +import { BaseCalloutResponseTransformer } from "#api/transformers/BaseCalloutResponseTransformer"; +import { mergeRules } from "#api/utils/rules"; -import Callout from "@models/Callout"; -import CalloutResponse from "@models/CalloutResponse"; +import Callout from "#models/Callout"; +import CalloutResponse from "#models/CalloutResponse"; -import { AuthInfo } from "@type/auth-info"; -import { CalloutResponseViewSchema } from "@type/callout-response-view-schema"; +import { AuthInfo } from "#type/auth-info"; +import { CalloutResponseViewSchema } from "#type/callout-response-view-schema"; class CalloutResponseMapTransformer extends BaseCalloutResponseTransformer< GetCalloutResponseMapDto, diff --git a/src/api/transformers/CalloutResponseTransformer.ts b/src/api/transformers/CalloutResponseTransformer.ts index 3d89648b1..6a2a6b547 100644 --- a/src/api/transformers/CalloutResponseTransformer.ts +++ b/src/api/transformers/CalloutResponseTransformer.ts @@ -2,7 +2,7 @@ import { TransformPlainToInstance } from "class-transformer"; import { SelectQueryBuilder } from "typeorm"; import { QueryDeepPartialEntity } from "typeorm/query-builder/QueryPartialEntity.js"; -import { createQueryBuilder, getRepository } from "@core/database"; +import { createQueryBuilder, getRepository } from "#core/database"; import { BatchUpdateCalloutResponseDto, @@ -11,25 +11,25 @@ import { GetCalloutResponseOptsDto, GetCalloutResponseWith, ListCalloutResponsesDto -} from "@api/dto/CalloutResponseDto"; -import { PaginatedDto } from "@api/dto/PaginatedDto"; -import NotFoundError from "@api/errors/NotFoundError"; +} from "#api/dto/CalloutResponseDto"; +import { PaginatedDto } from "#api/dto/PaginatedDto"; +import NotFoundError from "#api/errors/NotFoundError"; import ContactTransformer, { loadContactRoles -} from "@api/transformers/ContactTransformer"; -import CalloutTransformer from "@api/transformers/CalloutTransformer"; -import CalloutResponseCommentTransformer from "@api/transformers/CalloutResponseCommentTransformer"; -import CalloutTagTransformer from "@api/transformers/CalloutTagTransformer"; -import { BaseCalloutResponseTransformer } from "@api/transformers/BaseCalloutResponseTransformer"; -import { batchUpdate } from "@api/utils/rules"; +} from "#api/transformers/ContactTransformer"; +import CalloutTransformer from "#api/transformers/CalloutTransformer"; +import CalloutResponseCommentTransformer from "#api/transformers/CalloutResponseCommentTransformer"; +import CalloutTagTransformer from "#api/transformers/CalloutTagTransformer"; +import { BaseCalloutResponseTransformer } from "#api/transformers/BaseCalloutResponseTransformer"; +import { batchUpdate } from "#api/utils/rules"; -import Callout from "@models/Callout"; -import CalloutResponse from "@models/CalloutResponse"; -import CalloutResponseComment from "@models/CalloutResponseComment"; -import CalloutResponseTag from "@models/CalloutResponseTag"; -import Contact from "@models/Contact"; +import Callout from "#models/Callout"; +import CalloutResponse from "#models/CalloutResponse"; +import CalloutResponseComment from "#models/CalloutResponseComment"; +import CalloutResponseTag from "#models/CalloutResponseTag"; +import Contact from "#models/Contact"; -import { AuthInfo } from "@type/auth-info"; +import { AuthInfo } from "#type/auth-info"; export class CalloutResponseTransformer extends BaseCalloutResponseTransformer< GetCalloutResponseDto, @@ -69,8 +69,8 @@ export class CalloutResponseTransformer extends BaseCalloutResponseTransformer< }), ...(opts.with?.includes(GetCalloutResponseWith.Tags) && response.tags && { - tags: response.tags.map((rt) => CalloutTagTransformer.convert(rt.tag)) - }) + tags: response.tags.map((rt) => CalloutTagTransformer.convert(rt.tag)) + }) }; } diff --git a/src/api/transformers/CalloutTagTransformer.ts b/src/api/transformers/CalloutTagTransformer.ts index a3be9bae0..1b737039a 100644 --- a/src/api/transformers/CalloutTagTransformer.ts +++ b/src/api/transformers/CalloutTagTransformer.ts @@ -5,9 +5,9 @@ import { } from "@beabee/beabee-common"; import { TransformPlainToInstance } from "class-transformer"; -import { GetCalloutTagDto } from "@api/dto/CalloutTagDto"; +import { GetCalloutTagDto } from "#api/dto/CalloutTagDto"; -import CalloutTag from "@models/CalloutTag"; +import CalloutTag from "#models/CalloutTag"; import { BaseTransformer } from "./BaseTransformer"; diff --git a/src/api/transformers/CalloutTransformer.ts b/src/api/transformers/CalloutTransformer.ts index e9e330c94..96767ceb0 100644 --- a/src/api/transformers/CalloutTransformer.ts +++ b/src/api/transformers/CalloutTransformer.ts @@ -13,26 +13,26 @@ import { } from "routing-controllers"; import { SelectQueryBuilder } from "typeorm"; -import { createQueryBuilder } from "@core/database"; +import { createQueryBuilder } from "#core/database"; import { GetCalloutWith, ListCalloutsDto, GetCalloutDto, GetCalloutOptsDto -} from "@api/dto/CalloutDto"; -import { BaseTransformer } from "@api/transformers/BaseTransformer"; -import CalloutVariantTransformer from "@api/transformers/CalloutVariantTransformer"; -import { groupBy } from "@api/utils"; -import { mergeRules, statusFilterHandler } from "@api/utils/rules"; +} from "#api/dto/CalloutDto"; +import { BaseTransformer } from "#api/transformers/BaseTransformer"; +import CalloutVariantTransformer from "#api/transformers/CalloutVariantTransformer"; +import { groupBy } from "#api/utils"; +import { mergeRules, statusFilterHandler } from "#api/utils/rules"; -import Contact from "@models/Contact"; -import Callout from "@models/Callout"; -import CalloutResponse from "@models/CalloutResponse"; -import CalloutVariant from "@models/CalloutVariant"; +import Contact from "#models/Contact"; +import Callout from "#models/Callout"; +import CalloutResponse from "#models/CalloutResponse"; +import CalloutVariant from "#models/CalloutVariant"; -import { AuthInfo } from "@type/auth-info"; -import { FilterHandlers } from "@type/filter-handlers"; +import { AuthInfo } from "#type/auth-info"; +import { FilterHandlers } from "#type/filter-handlers"; class CalloutTransformer extends BaseTransformer< Callout, diff --git a/src/api/transformers/CalloutVariantTransformer.ts b/src/api/transformers/CalloutVariantTransformer.ts index 2071f12fb..31e0019d7 100644 --- a/src/api/transformers/CalloutVariantTransformer.ts +++ b/src/api/transformers/CalloutVariantTransformer.ts @@ -1,5 +1,5 @@ -import { CalloutVariantDto } from "@api/dto/CalloutVariantDto"; -import CalloutVariant from "@models/CalloutVariant"; +import { CalloutVariantDto } from "#api/dto/CalloutVariantDto"; +import CalloutVariant from "#models/CalloutVariant"; import { TransformPlainToInstance } from "class-transformer"; import { BaseTransformer } from "./BaseTransformer"; diff --git a/src/api/transformers/ContactExporter.ts b/src/api/transformers/ContactExporter.ts index d4c724d43..d51976688 100644 --- a/src/api/transformers/ContactExporter.ts +++ b/src/api/transformers/ContactExporter.ts @@ -6,16 +6,16 @@ import { import { stringify } from "csv-stringify/sync"; import { SelectQueryBuilder } from "typeorm"; -import { getMembershipStatus } from "@core/services/PaymentService"; +import { getMembershipStatus } from "#core/services/PaymentService"; -import { GetExportQuery } from "@api/dto/BaseDto"; -import { ExportContactDto } from "@api/dto/ContactDto"; -import { BaseTransformer } from "@api/transformers/BaseTransformer"; -import ContactTransformer from "@api/transformers/ContactTransformer"; +import { GetExportQuery } from "#api/dto/BaseDto"; +import { ExportContactDto } from "#api/dto/ContactDto"; +import { BaseTransformer } from "#api/transformers/BaseTransformer"; +import ContactTransformer from "#api/transformers/ContactTransformer"; -import Contact from "@models/Contact"; +import Contact from "#models/Contact"; -import { AuthInfo } from "@type/auth-info"; +import { AuthInfo } from "#type/auth-info"; class ContactExporter extends BaseTransformer< Contact, diff --git a/src/api/transformers/ContactProfileTransformer.ts b/src/api/transformers/ContactProfileTransformer.ts index ee3d7d4d7..f82abf637 100644 --- a/src/api/transformers/ContactProfileTransformer.ts +++ b/src/api/transformers/ContactProfileTransformer.ts @@ -1,12 +1,12 @@ import { TransformPlainToInstance } from "class-transformer"; -import { GetContactProfileDto } from "@api/dto/ContactProfileDto"; -import AddressTransformer from "@api/transformers/AddressTransformer"; -import { BaseTransformer } from "@api/transformers/BaseTransformer"; +import { GetContactProfileDto } from "#api/dto/ContactProfileDto"; +import AddressTransformer from "#api/transformers/AddressTransformer"; +import { BaseTransformer } from "#api/transformers/BaseTransformer"; -import ContactProfile from "@models/ContactProfile"; +import ContactProfile from "#models/ContactProfile"; -import { AuthInfo } from "@type/auth-info"; +import { AuthInfo } from "#type/auth-info"; class ContactProfileTransformer extends BaseTransformer< ContactProfile, diff --git a/src/api/transformers/ContactRoleTransformer.ts b/src/api/transformers/ContactRoleTransformer.ts index 46d69111c..c1c74524b 100644 --- a/src/api/transformers/ContactRoleTransformer.ts +++ b/src/api/transformers/ContactRoleTransformer.ts @@ -1,9 +1,9 @@ import { BaseTransformer } from "./BaseTransformer"; import { TransformPlainToInstance } from "class-transformer"; -import { GetContactRoleDto } from "@api/dto/ContactRoleDto"; +import { GetContactRoleDto } from "#api/dto/ContactRoleDto"; -import ContactRole from "@models/ContactRole"; +import ContactRole from "#models/ContactRole"; class ContactRoleTransformer extends BaseTransformer< ContactRole, diff --git a/src/api/transformers/ContactTransformer.ts b/src/api/transformers/ContactTransformer.ts index 9e200acf8..d1c6145e4 100644 --- a/src/api/transformers/ContactTransformer.ts +++ b/src/api/transformers/ContactTransformer.ts @@ -2,27 +2,27 @@ import { ContactFilterName, contactFilters } from "@beabee/beabee-common"; import { TransformPlainToInstance } from "class-transformer"; import { Brackets, SelectQueryBuilder } from "typeorm"; -import { createQueryBuilder } from "@core/database"; -import PaymentService from "@core/services/PaymentService"; +import { createQueryBuilder } from "#core/database"; +import PaymentService from "#core/services/PaymentService"; -import Contact from "@models/Contact"; -import ContactRole from "@models/ContactRole"; -import ContactProfile from "@models/ContactProfile"; -import PaymentData from "@models/PaymentData"; +import Contact from "#models/Contact"; +import ContactRole from "#models/ContactRole"; +import ContactProfile from "#models/ContactProfile"; +import PaymentData from "#models/PaymentData"; import { GetContactDto, GetContactOptsDto, ListContactsDto -} from "@api/dto/ContactDto"; -import { BaseTransformer } from "@api/transformers/BaseTransformer"; -import ContactRoleTransformer from "@api/transformers/ContactRoleTransformer"; -import ContactProfileTransformer from "@api/transformers/ContactProfileTransformer"; -import { mergeRules } from "@api/utils/rules"; +} from "#api/dto/ContactDto"; +import { BaseTransformer } from "#api/transformers/BaseTransformer"; +import ContactRoleTransformer from "#api/transformers/ContactRoleTransformer"; +import ContactProfileTransformer from "#api/transformers/ContactProfileTransformer"; +import { mergeRules } from "#api/utils/rules"; -import { GetContactWith } from "@enums/get-contact-with"; +import { GetContactWith } from "#enums/get-contact-with"; -import { AuthInfo } from "@type/auth-info"; -import { FilterHandler, FilterHandlers } from "@type/filter-handlers"; +import { AuthInfo } from "#type/auth-info"; +import { FilterHandler, FilterHandlers } from "#type/filter-handlers"; class ContactTransformer extends BaseTransformer< Contact, @@ -59,12 +59,12 @@ class ContactTransformer extends BaseTransformer< }), ...(opts?.with?.includes(GetContactWith.Profile) && contact.profile && { - profile: ContactProfileTransformer.convert( - contact.profile, - undefined, - auth - ) - }), + profile: ContactProfileTransformer.convert( + contact.profile, + undefined, + auth + ) + }), ...(opts?.with?.includes(GetContactWith.Roles) && { roles: contact.roles.map(ContactRoleTransformer.convert) }), diff --git a/src/api/transformers/ContentTransformer.ts b/src/api/transformers/ContentTransformer.ts index 1492b086b..e8e864aa0 100644 --- a/src/api/transformers/ContentTransformer.ts +++ b/src/api/transformers/ContentTransformer.ts @@ -1,9 +1,9 @@ import { plainToInstance } from "class-transformer"; -import { createQueryBuilder, getRepository } from "@core/database"; -import { getEmailFooter } from "@core/utils/email"; +import { createQueryBuilder, getRepository } from "#core/database"; +import { getEmailFooter } from "#core/utils/email"; -import OptionsService, { OptionKey } from "@core/services/OptionsService"; +import OptionsService, { OptionKey } from "#core/services/OptionsService"; import { GetContactsContentDto, GetContentDto, @@ -13,14 +13,14 @@ import { GetJoinSetupContentDto, GetProfileContentDto, GetShareContentDto -} from "@api/dto/ContentDto"; +} from "#api/dto/ContentDto"; -import Content from "@models/Content"; +import Content from "#models/Content"; -import config from "@config"; +import config from "#config"; -import { ContentId } from "@type/content-id"; -import { ContentData } from "@type/content-data"; +import { ContentId } from "#type/content-id"; +import { ContentData } from "#type/content-data"; class ContentTransformer { convert( diff --git a/src/api/transformers/NoticeTransformer.ts b/src/api/transformers/NoticeTransformer.ts index 655585eb4..d8b26ccbe 100644 --- a/src/api/transformers/NoticeTransformer.ts +++ b/src/api/transformers/NoticeTransformer.ts @@ -5,13 +5,13 @@ import { } from "@beabee/beabee-common"; import { TransformPlainToInstance } from "class-transformer"; -import { BaseTransformer } from "@api/transformers/BaseTransformer"; -import { GetNoticeDto, ListNoticesDto } from "@api/dto/NoticeDto"; -import { mergeRules, statusFilterHandler } from "@api/utils/rules"; +import { BaseTransformer } from "#api/transformers/BaseTransformer"; +import { GetNoticeDto, ListNoticesDto } from "#api/dto/NoticeDto"; +import { mergeRules, statusFilterHandler } from "#api/utils/rules"; -import Notice from "@models/Notice"; +import Notice from "#models/Notice"; -import { AuthInfo } from "@type/auth-info"; +import { AuthInfo } from "#type/auth-info"; export class NoticeTransformer extends BaseTransformer< Notice, diff --git a/src/api/transformers/PaymentTransformer.ts b/src/api/transformers/PaymentTransformer.ts index 7069613c4..9cb8cbe24 100644 --- a/src/api/transformers/PaymentTransformer.ts +++ b/src/api/transformers/PaymentTransformer.ts @@ -7,17 +7,17 @@ import { GetPaymentOptsDto, GetPaymentWith, ListPaymentsDto -} from "@api/dto/PaymentDto"; +} from "#api/dto/PaymentDto"; import ContactTransformer, { loadContactRoles -} from "@api/transformers/ContactTransformer"; -import { BaseTransformer } from "@api/transformers/BaseTransformer"; -import { mergeRules } from "@api/utils/rules"; +} from "#api/transformers/ContactTransformer"; +import { BaseTransformer } from "#api/transformers/BaseTransformer"; +import { mergeRules } from "#api/utils/rules"; -import Contact from "@models/Contact"; -import Payment from "@models/Payment"; +import Contact from "#models/Contact"; +import Payment from "#models/Payment"; -import { AuthInfo } from "@type/auth-info"; +import { AuthInfo } from "#type/auth-info"; class PaymentTransformer extends BaseTransformer< Payment, diff --git a/src/api/transformers/SegmentTransformer.ts b/src/api/transformers/SegmentTransformer.ts index 1ef52cfde..960f1180f 100644 --- a/src/api/transformers/SegmentTransformer.ts +++ b/src/api/transformers/SegmentTransformer.ts @@ -10,13 +10,13 @@ import { GetSegmentOptsDto, GetSegmentWith, ListSegmentsDto -} from "@api/dto/SegmentDto"; -import { BaseTransformer } from "@api/transformers/BaseTransformer"; -import ContactTransformer from "@api/transformers/ContactTransformer"; +} from "#api/dto/SegmentDto"; +import { BaseTransformer } from "#api/transformers/BaseTransformer"; +import ContactTransformer from "#api/transformers/ContactTransformer"; -import Segment from "@models/Segment"; +import Segment from "#models/Segment"; -import { AuthInfo } from "@type/auth-info"; +import { AuthInfo } from "#type/auth-info"; class SegmentTransformer extends BaseTransformer< Segment, diff --git a/src/api/utils/index.ts b/src/api/utils/index.ts index d62a6338b..92f5006f1 100644 --- a/src/api/utils/index.ts +++ b/src/api/utils/index.ts @@ -1,7 +1,7 @@ import { ValidatorOptions, validate } from "class-validator"; import { Request } from "express"; -import Contact from "@models/Contact"; +import Contact from "#models/Contact"; import { BadRequestError } from "routing-controllers"; export function login(req: Request, contact: Contact): Promise { diff --git a/src/api/utils/rules.ts b/src/api/utils/rules.ts index 7e7cc6222..1fa26e85d 100644 --- a/src/api/utils/rules.ts +++ b/src/api/utils/rules.ts @@ -25,20 +25,20 @@ import { } from "typeorm"; import { QueryDeepPartialEntity } from "typeorm/query-builder/QueryPartialEntity"; -import { createQueryBuilder } from "@core/database"; +import { createQueryBuilder } from "#core/database"; import type { GetPaginatedRuleGroupRule, GetPaginatedRuleGroup -} from "@api/dto/BaseDto"; +} from "#api/dto/BaseDto"; import { FilterHandler, FilterHandlers, RichRuleValue -} from "@type/filter-handlers"; +} from "#type/filter-handlers"; -import Contact from "@models/Contact"; +import Contact from "#models/Contact"; // Operator definitions diff --git a/src/api/validators/IsVariantsObject.ts b/src/api/validators/IsVariantsObject.ts index 8a4494f6e..c7cc23251 100644 --- a/src/api/validators/IsVariantsObject.ts +++ b/src/api/validators/IsVariantsObject.ts @@ -1,6 +1,6 @@ import { ValidateBy, ValidationOptions, buildMessage } from "class-validator"; -import { validateOrReject } from "@api/utils"; +import { validateOrReject } from "#api/utils"; async function isVariantsObject(value: unknown): Promise { if (typeof value !== "object" || value === null) { diff --git a/src/api/validators/MinContributionAmount.ts b/src/api/validators/MinContributionAmount.ts index d354d8ca1..47080f501 100644 --- a/src/api/validators/MinContributionAmount.ts +++ b/src/api/validators/MinContributionAmount.ts @@ -5,12 +5,11 @@ import { ValidatorConstraintInterface } from "class-validator"; -import OptionsService from "@core/services/OptionsService"; +import OptionsService from "#core/services/OptionsService"; @ValidatorConstraint({ name: "minContributionAmount" }) export default class MinContributionAmount - implements ValidatorConstraintInterface -{ + implements ValidatorConstraintInterface { validate(amount: unknown, args: ValidationArguments): boolean { return typeof amount === "number" && amount >= this.minAmount(args); } diff --git a/src/api/validators/ValidPayFee.ts b/src/api/validators/ValidPayFee.ts index e88deb4a5..19c2b97d8 100644 --- a/src/api/validators/ValidPayFee.ts +++ b/src/api/validators/ValidPayFee.ts @@ -5,7 +5,7 @@ import { ValidatorConstraintInterface } from "class-validator"; -import OptionsService from "@core/services/OptionsService"; +import OptionsService from "#core/services/OptionsService"; @ValidatorConstraint({ name: "validPayFee" }) export default class ValidPayFee implements ValidatorConstraintInterface { diff --git a/src/app.ts b/src/app.ts index de9e6d160..e99922dd1 100644 --- a/src/app.ts +++ b/src/app.ts @@ -1,4 +1,4 @@ -import "module-alias/register"; +// import "module-alias/register"; import cleanDeep from "clean-deep"; import cookie from "cookie-parser"; @@ -7,19 +7,19 @@ import express, { ErrorRequestHandler } from "express"; import flash from "express-flash"; import helmet from "helmet"; -import appLoader from "@core/app-loader"; -import { log, requestErrorLogger, requestLogger } from "@core/logging"; -import quickflash from "@core/quickflash"; -import { initApp, startServer } from "@core/server"; -import sessions from "@core/sessions"; -import { isInvalidType } from "@core/utils"; +import appLoader from "#core/app-loader"; +import { log, requestErrorLogger, requestLogger } from "#core/logging"; +import quickflash from "#core/quickflash"; +import { initApp, startServer } from "#core/server"; +import sessions from "#core/sessions"; +import { isInvalidType } from "#core/utils"; -import OptionsService, { OptionKey } from "@core/services/OptionsService"; -import PageSettingsService from "@core/services/PageSettingsService"; +import OptionsService, { OptionKey } from "#core/services/OptionsService"; +import PageSettingsService from "#core/services/PageSettingsService"; -//import specialUrlHandler from '@apps/tools/apps/special-urls/handler'; +//import specialUrlHandler from '#apps/tools/apps/special-urls/handler'; -import config from "@config"; +import config from "#config"; if (!config.gocardless.sandbox && config.dev) { log.error( diff --git a/src/apps/discourse/app.ts b/src/apps/discourse/app.ts index 47f6f6d31..c0e3d4298 100644 --- a/src/apps/discourse/app.ts +++ b/src/apps/discourse/app.ts @@ -1,13 +1,13 @@ import express from "express"; import DiscourseSSO from "discourse-sso"; -import config from "@config"; +import config from "#config"; -import { getRepository } from "@core/database"; -import { isLoggedIn } from "@core/middleware"; -import { hasUser, wrapAsync } from "@core/utils"; +import { getRepository } from "#core/database"; +import { isLoggedIn } from "#core/middleware"; +import { hasUser, wrapAsync } from "#core/utils"; -import ProjectContact from "@models/ProjectContact"; +import ProjectContact from "#models/ProjectContact"; const sso = new DiscourseSSO(config.discourse.ssoSecret); diff --git a/src/apps/gift/app.ts b/src/apps/gift/app.ts index dfeda504f..2cc04e0dc 100644 --- a/src/apps/gift/app.ts +++ b/src/apps/gift/app.ts @@ -1,18 +1,18 @@ import express from "express"; import moment from "moment"; -import config from "@config"; +import config from "#config"; -import { hasNewModel, hasSchema } from "@core/middleware"; -import { wrapAsync } from "@core/utils"; -import { loginAndRedirect } from "@core/utils/contact"; +import { hasNewModel, hasSchema } from "#core/middleware"; +import { wrapAsync } from "#core/utils"; +import { loginAndRedirect } from "#core/utils/contact"; -import GiftService from "@core/services/GiftService"; -import ContactsService from "@core/services/ContactsService"; -import OptionsService from "@core/services/OptionsService"; +import GiftService from "#core/services/GiftService"; +import ContactsService from "#core/services/ContactsService"; +import OptionsService from "#core/services/OptionsService"; -import Address from "@models/Address"; -import GiftFlow, { GiftForm } from "@models/GiftFlow"; +import Address from "#models/Address"; +import GiftFlow, { GiftForm } from "#models/GiftFlow"; import { createGiftSchema, updateGiftAddressSchema } from "./schema.json"; @@ -38,14 +38,14 @@ interface AddressSchema { type UpdateGiftAddressSchema = | { - sameAddress: true; - giftAddress: AddressSchema; - } + sameAddress: true; + giftAddress: AddressSchema; + } | { - sameAddress: false; - giftAddress: AddressSchema; - deliveryAddress: AddressSchema; - }; + sameAddress: false; + giftAddress: AddressSchema; + deliveryAddress: AddressSchema; + }; function schemaToGiftForm(data: CreateGiftSchema): GiftForm { const giftForm = new GiftForm(); diff --git a/src/apps/home/app.ts b/src/apps/home/app.ts index 92b51511c..bc4c31b98 100644 --- a/src/apps/home/app.ts +++ b/src/apps/home/app.ts @@ -1,5 +1,5 @@ import express from "express"; -import OptionsService, { OptionKey } from "@core/services/OptionsService"; +import OptionsService, { OptionKey } from "#core/services/OptionsService"; const app = express(); diff --git a/src/apps/login/app.ts b/src/apps/login/app.ts index bc17745fd..dbb9fd182 100644 --- a/src/apps/login/app.ts +++ b/src/apps/login/app.ts @@ -2,15 +2,15 @@ import { RoleTypes, RoleType } from "@beabee/beabee-common"; import express from "express"; import passport from "passport"; -import { getRepository } from "@core/database"; -import { isValidNextUrl, getNextParam, wrapAsync } from "@core/utils"; -import { loginAndRedirect } from "@core/utils/contact"; +import { getRepository } from "#core/database"; +import { isValidNextUrl, getNextParam, wrapAsync } from "#core/utils"; +import { loginAndRedirect } from "#core/utils/contact"; -import ContactsService from "@core/services/ContactsService"; +import ContactsService from "#core/services/ContactsService"; -import ContactRole from "@models/ContactRole"; +import ContactRole from "#models/ContactRole"; -import config from "@config"; +import config from "#config"; const app = express(); diff --git a/src/apps/logout/app.ts b/src/apps/logout/app.ts index f42792ccd..0ba84d846 100644 --- a/src/apps/logout/app.ts +++ b/src/apps/logout/app.ts @@ -1,4 +1,4 @@ -import { wrapAsync } from "@core/utils"; +import { wrapAsync } from "#core/utils"; import express from "express"; const app = express(); diff --git a/src/apps/members/app.ts b/src/apps/members/app.ts index 7d9406f14..6b8899e6e 100644 --- a/src/apps/members/app.ts +++ b/src/apps/members/app.ts @@ -2,19 +2,19 @@ import { RuleGroup } from "@beabee/beabee-common"; import express, { Request } from "express"; import queryString from "query-string"; -import { getRepository } from "@core/database"; -import { isAdmin } from "@core/middleware"; -import { userToAuth, wrapAsync } from "@core/utils"; +import { getRepository } from "#core/database"; +import { isAdmin } from "#core/middleware"; +import { userToAuth, wrapAsync } from "#core/utils"; -import OptionsService from "@core/services/OptionsService"; -import SegmentService from "@core/services/SegmentService"; +import OptionsService from "#core/services/OptionsService"; +import SegmentService from "#core/services/SegmentService"; -import ContactTransformer from "@api/transformers/ContactTransformer"; +import ContactTransformer from "#api/transformers/ContactTransformer"; -import Project from "@models/Project"; -import Contact from "@models/Contact"; +import Project from "#models/Project"; +import Contact from "#models/Contact"; -import { GetContactWith } from "@enums/get-contact-with"; +import { GetContactWith } from "#enums/get-contact-with"; const app = express(); @@ -84,10 +84,10 @@ export function cleanRuleGroup(group: RuleGroup): RuleGroup { "condition" in rule ? cleanRuleGroup(rule) : { - field: rule.field, - operator: rule.operator, - value: Array.isArray(rule.value) ? rule.value : [rule.value] - } + field: rule.field, + operator: rule.operator, + value: Array.isArray(rule.value) ? rule.value : [rule.value] + } ) }; } diff --git a/src/apps/members/apps/add/app.ts b/src/apps/members/apps/add/app.ts index 0a2a6cb19..c38628a41 100644 --- a/src/apps/members/apps/add/app.ts +++ b/src/apps/members/apps/add/app.ts @@ -6,19 +6,19 @@ import { } from "@beabee/beabee-common"; import express from "express"; -import { getRepository } from "@core/database"; -import { hasSchema, isSuperAdmin } from "@core/middleware"; -import { createDateTime, wrapAsync } from "@core/utils"; +import { getRepository } from "#core/database"; +import { hasSchema, isSuperAdmin } from "#core/middleware"; +import { createDateTime, wrapAsync } from "#core/utils"; -import ContactsService from "@core/services/ContactsService"; -import OptionsService from "@core/services/OptionsService"; +import ContactsService from "#core/services/ContactsService"; +import OptionsService from "#core/services/OptionsService"; -import ContactRole from "@models/ContactRole"; +import ContactRole from "#models/ContactRole"; import { addContactSchema } from "./schemas.json"; -import DuplicateEmailError from "@api/errors/DuplicateEmailError"; -import PaymentService from "@core/services/PaymentService"; +import DuplicateEmailError from "#api/errors/DuplicateEmailError"; +import PaymentService from "#core/services/PaymentService"; interface BaseAddContactSchema { email: string; @@ -86,11 +86,11 @@ app.post( }, data.addToNewsletter ? { - newsletterStatus: NewsletterStatus.Subscribed, - newsletterGroups: OptionsService.getList( - "newsletter-default-groups" - ) - } + newsletterStatus: NewsletterStatus.Subscribed, + newsletterGroups: OptionsService.getList( + "newsletter-default-groups" + ) + } : undefined ); } catch (error) { diff --git a/src/apps/members/apps/member/app.ts b/src/apps/members/apps/member/app.ts index f8ad09086..e71367247 100644 --- a/src/apps/members/apps/member/app.ts +++ b/src/apps/members/apps/member/app.ts @@ -1,22 +1,22 @@ import express from "express"; import moment from "moment"; -import config from "@config"; +import config from "#config"; -import { getRepository } from "@core/database"; -import { isAdmin } from "@core/middleware"; -import { wrapAsync } from "@core/utils"; -import { canSuperAdmin, generateCode } from "@core/utils/auth"; +import { getRepository } from "#core/database"; +import { isAdmin } from "#core/middleware"; +import { wrapAsync } from "#core/utils"; +import { canSuperAdmin, generateCode } from "#core/utils/auth"; -import ContactsService from "@core/services/ContactsService"; -import OptionsService from "@core/services/OptionsService"; -import PaymentService from "@core/services/PaymentService"; -import ReferralsService from "@core/services/ReferralsService"; +import ContactsService from "#core/services/ContactsService"; +import OptionsService from "#core/services/OptionsService"; +import PaymentService from "#core/services/PaymentService"; +import ReferralsService from "#core/services/ReferralsService"; -import Contact from "@models/Contact"; -import ResetSecurityFlow from "@models/ResetSecurityFlow"; +import Contact from "#models/Contact"; +import ResetSecurityFlow from "#models/ResetSecurityFlow"; -import { RESET_SECURITY_FLOW_TYPE } from "@enums/reset-security-flow-type"; +import { RESET_SECURITY_FLOW_TYPE } from "#enums/reset-security-flow-type"; const app = express(); diff --git a/src/apps/members/apps/member/apps/contribution/app.ts b/src/apps/members/apps/member/apps/contribution/app.ts index 802432961..ff9bc8552 100644 --- a/src/apps/members/apps/member/apps/contribution/app.ts +++ b/src/apps/members/apps/member/apps/contribution/app.ts @@ -1,13 +1,13 @@ import { ContributionType } from "@beabee/beabee-common"; import express from "express"; -import { wrapAsync } from "@core/utils"; -import { calcMonthsLeft } from "@core/utils/payment"; +import { wrapAsync } from "#core/utils"; +import { calcMonthsLeft } from "#core/utils/payment"; -import PaymentService from "@core/services/PaymentService"; -import ContactsService from "@core/services/ContactsService"; +import PaymentService from "#core/services/PaymentService"; +import ContactsService from "#core/services/ContactsService"; -import Contact from "@models/Contact"; +import Contact from "#models/Contact"; const app = express(); diff --git a/src/apps/members/apps/member/apps/permissions/app.ts b/src/apps/members/apps/member/apps/permissions/app.ts index ee3069118..3d8ac3869 100644 --- a/src/apps/members/apps/member/apps/permissions/app.ts +++ b/src/apps/members/apps/member/apps/permissions/app.ts @@ -1,12 +1,12 @@ import { RoleType } from "@beabee/beabee-common"; import express, { NextFunction, Request, Response } from "express"; -import { hasSchema } from "@core/middleware"; -import { createDateTime, wrapAsync } from "@core/utils"; +import { hasSchema } from "#core/middleware"; +import { createDateTime, wrapAsync } from "#core/utils"; -import ContactsService from "@core/services/ContactsService"; +import ContactsService from "#core/services/ContactsService"; -import Contact from "@models/Contact"; +import Contact from "#models/Contact"; import { createPermissionSchema, updatePermissionSchema } from "./schemas.json"; diff --git a/src/apps/members/apps/member/apps/profile/app.ts b/src/apps/members/apps/member/apps/profile/app.ts index 305d96266..52603d9ea 100644 --- a/src/apps/members/apps/member/apps/profile/app.ts +++ b/src/apps/members/apps/member/apps/profile/app.ts @@ -1,14 +1,14 @@ import express from "express"; -import { hasSchema } from "@core/middleware"; -import { wrapAsync } from "@core/utils"; +import { hasSchema } from "#core/middleware"; +import { wrapAsync } from "#core/utils"; -import ContactsService from "@core/services/ContactsService"; +import ContactsService from "#core/services/ContactsService"; -import Contact from "@models/Contact"; +import Contact from "#models/Contact"; import { updateProfileSchema } from "./schemas.json"; -import DuplicateEmailError from "@api/errors/DuplicateEmailError"; +import DuplicateEmailError from "#api/errors/DuplicateEmailError"; const app = express(); @@ -46,11 +46,11 @@ app.post( deliveryOptIn: delivery_optin, deliveryAddress: delivery_optin ? { - line1: delivery_line1, - line2: delivery_line2, - city: delivery_city, - postcode: delivery_postcode - } + line1: delivery_line1, + line2: delivery_line2, + city: delivery_city, + postcode: delivery_postcode + } : null }); } catch (error) { diff --git a/src/apps/members/apps/segments/app.ts b/src/apps/members/apps/segments/app.ts index 3e44e954c..dc6bfb968 100644 --- a/src/apps/members/apps/segments/app.ts +++ b/src/apps/members/apps/segments/app.ts @@ -1,20 +1,20 @@ import express from "express"; -import { getRepository } from "@core/database"; -import { hasNewModel } from "@core/middleware"; -import { userToAuth, wrapAsync } from "@core/utils"; +import { getRepository } from "#core/database"; +import { hasNewModel } from "#core/middleware"; +import { userToAuth, wrapAsync } from "#core/utils"; -import SegmentService from "@core/services/SegmentService"; +import SegmentService from "#core/services/SegmentService"; -import Email from "@models/Email"; -import EmailMailing from "@models/EmailMailing"; -import Segment from "@models/Segment"; -import SegmentOngoingEmail from "@models/SegmentOngoingEmail"; -import SegmentContact from "@models/SegmentContact"; +import Email from "#models/Email"; +import EmailMailing from "#models/EmailMailing"; +import Segment from "#models/Segment"; +import SegmentOngoingEmail from "#models/SegmentOngoingEmail"; +import SegmentContact from "#models/SegmentContact"; -import { EmailSchema, schemaToEmail } from "@apps/tools/apps/emails/app"; -import { cleanRuleGroup } from "@apps/members/app"; -import ContactTransformer from "@api/transformers/ContactTransformer"; +import { EmailSchema, schemaToEmail } from "#apps/tools/apps/emails/app"; +import { cleanRuleGroup } from "#apps/members/app"; +import ContactTransformer from "#api/transformers/ContactTransformer"; const app = express(); @@ -137,11 +137,11 @@ app.post( const email = data.email === "__new__" ? await getRepository(Email).save( - schemaToEmail({ - ...data, - name: "Email to segment " + segment.name - }) - ) + schemaToEmail({ + ...data, + name: "Email to segment " + segment.name + }) + ) : await getRepository(Email).findOneByOrFail({ id: data.email }); if (data.type === "ongoing") { diff --git a/src/apps/projects/app.ts b/src/apps/projects/app.ts index 9c3891107..3a068872d 100644 --- a/src/apps/projects/app.ts +++ b/src/apps/projects/app.ts @@ -2,14 +2,14 @@ import express from "express"; import _ from "lodash"; import moment from "moment"; -import { createQueryBuilder, getRepository } from "@core/database"; -import { hasNewModel, hasSchema, isAdmin } from "@core/middleware"; -import { wrapAsync } from "@core/utils"; - -import Contact from "@models/Contact"; -import Project from "@models/Project"; -import ProjectContact from "@models/ProjectContact"; -import ProjectEngagement from "@models/ProjectEngagement"; +import { createQueryBuilder, getRepository } from "#core/database"; +import { hasNewModel, hasSchema, isAdmin } from "#core/middleware"; +import { wrapAsync } from "#core/utils"; + +import Contact from "#models/Contact"; +import Project from "#models/Project"; +import ProjectContact from "#models/ProjectContact"; +import ProjectEngagement from "#models/ProjectEngagement"; import { createProjectSchema } from "./schemas.json"; diff --git a/src/apps/reports/apps/map/app.ts b/src/apps/reports/apps/map/app.ts index 49223437a..ab001c57f 100644 --- a/src/apps/reports/apps/map/app.ts +++ b/src/apps/reports/apps/map/app.ts @@ -2,13 +2,13 @@ import axios from "axios"; import express from "express"; import { Brackets } from "typeorm"; -import { createQueryBuilder } from "@core/database"; -import { log } from "@core/logging"; -import { isAdmin } from "@core/middleware"; -import { wrapAsync } from "@core/utils"; +import { createQueryBuilder } from "#core/database"; +import { log } from "#core/logging"; +import { isAdmin } from "#core/middleware"; +import { wrapAsync } from "#core/utils"; -import ContactRole from "@models/ContactRole"; -import ContactProfile from "@models/ContactProfile"; +import ContactRole from "#models/ContactRole"; +import ContactProfile from "#models/ContactProfile"; const app = express(); @@ -65,9 +65,9 @@ async function getPostcodes(postcodes: string[]): Promise { for (const result of data.result) { postcodeCache[result.query] = result.result ? { - latitude: result.result.latitude, - longitude: result.result.longitude - } + latitude: result.result.latitude, + longitude: result.result.longitude + } : null; } } diff --git a/src/apps/reports/apps/transactions/app.ts b/src/apps/reports/apps/transactions/app.ts index ea2757c39..d20090a9a 100644 --- a/src/apps/reports/apps/transactions/app.ts +++ b/src/apps/reports/apps/transactions/app.ts @@ -2,11 +2,11 @@ import express from "express"; import moment from "moment"; import { Between } from "typeorm"; -import { getRepository } from "@core/database"; -import { isSuperAdmin } from "@core/middleware"; -import { wrapAsync } from "@core/utils"; +import { getRepository } from "#core/database"; +import { isSuperAdmin } from "#core/middleware"; +import { wrapAsync } from "#core/utils"; -import Payment from "@models/Payment"; +import Payment from "#models/Payment"; const app = express(); diff --git a/src/apps/settings/apps/content/app.ts b/src/apps/settings/apps/content/app.ts index c4ccae529..fb6d863b5 100644 --- a/src/apps/settings/apps/content/app.ts +++ b/src/apps/settings/apps/content/app.ts @@ -1,14 +1,14 @@ import express, { Request, Response, NextFunction } from "express"; -import { getRepository } from "@core/database"; -import { isAdmin } from "@core/middleware"; -import { wrapAsync } from "@core/utils"; +import { getRepository } from "#core/database"; +import { isAdmin } from "#core/middleware"; +import { wrapAsync } from "#core/utils"; -import OptionsService from "@core/services/OptionsService"; +import OptionsService from "#core/services/OptionsService"; -import Content from "@models/Content"; +import Content from "#models/Content"; -import { ContentId } from "@type/content-id"; +import { ContentId } from "#type/content-id"; const app = express(); diff --git a/src/apps/settings/apps/newsletters/app.ts b/src/apps/settings/apps/newsletters/app.ts index b5e925270..335af808a 100644 --- a/src/apps/settings/apps/newsletters/app.ts +++ b/src/apps/settings/apps/newsletters/app.ts @@ -2,19 +2,19 @@ import { NewsletterStatus } from "@beabee/beabee-common"; import express from "express"; import moment from "moment"; -import { log as mainLogger } from "@core/logging"; -import { isSuperAdmin } from "@core/middleware"; -import { wrapAsync } from "@core/utils"; +import { log as mainLogger } from "#core/logging"; +import { isSuperAdmin } from "#core/middleware"; +import { wrapAsync } from "#core/utils"; -import ContactsService from "@core/services/ContactsService"; -import NewsletterService from "@core/services/NewsletterService"; -import OptionsService from "@core/services/OptionsService"; +import ContactsService from "#core/services/ContactsService"; +import NewsletterService from "#core/services/NewsletterService"; +import OptionsService from "#core/services/OptionsService"; -import { NewsletterContact } from "@core/providers/newsletter"; +import { NewsletterContact } from "#core/providers/newsletter"; -import Contact from "@models/Contact"; +import Contact from "#models/Contact"; -import config from "@config"; +import config from "#config"; const log = mainLogger.child({ app: "newsletter-settings" }); @@ -47,11 +47,11 @@ function isMismatchedContact(contact: Contact, nlContact: NewsletterContact) { return ( contact.profile.newsletterStatus !== nlContact.status || groupsList(contact.profile.newsletterGroups) !== - groupsList(nlContact.groups) || + groupsList(nlContact.groups) || !!contact.membership?.isActive !== - nlContact.tags.includes( - OptionsService.getText("newsletter-active-member-tag") - ) + nlContact.tags.includes( + OptionsService.getText("newsletter-active-member-tag") + ) ); } diff --git a/src/apps/settings/apps/options/app.ts b/src/apps/settings/apps/options/app.ts index f01a87c9f..618c1b9a4 100644 --- a/src/apps/settings/apps/options/app.ts +++ b/src/apps/settings/apps/options/app.ts @@ -1,9 +1,9 @@ import express from "express"; -import { isSuperAdmin } from "@core/middleware"; -import { wrapAsync } from "@core/utils"; +import { isSuperAdmin } from "#core/middleware"; +import { wrapAsync } from "#core/utils"; -import OptionsService from "@core/services/OptionsService"; +import OptionsService from "#core/services/OptionsService"; const app = express(); diff --git a/src/apps/settings/apps/pages/app.ts b/src/apps/settings/apps/pages/app.ts index 29a411cfa..031df51d1 100644 --- a/src/apps/settings/apps/pages/app.ts +++ b/src/apps/settings/apps/pages/app.ts @@ -1,12 +1,12 @@ import express from "express"; -import { getRepository } from "@core/database"; -import { hasNewModel, hasSchema, isAdmin } from "@core/middleware"; -import { wrapAsync } from "@core/utils"; +import { getRepository } from "#core/database"; +import { hasNewModel, hasSchema, isAdmin } from "#core/middleware"; +import { wrapAsync } from "#core/utils"; -import PageSettingsService from "@core/services/PageSettingsService"; +import PageSettingsService from "#core/services/PageSettingsService"; -import PageSettings from "@models/PageSettings"; +import PageSettings from "#models/PageSettings"; import { createPageSchema } from "./schema.json"; diff --git a/src/apps/share/app.ts b/src/apps/share/app.ts index 2dfdb04b3..33ca9cf1d 100644 --- a/src/apps/share/app.ts +++ b/src/apps/share/app.ts @@ -1,15 +1,15 @@ import express from "express"; -import { createQueryBuilder, getRepository } from "@core/database"; -import { wrapAsync } from "@core/utils"; +import { createQueryBuilder, getRepository } from "#core/database"; +import { wrapAsync } from "#core/utils"; import PageSettingsService, { JustPageSettings -} from "@core/services/PageSettingsService"; +} from "#core/services/PageSettingsService"; -import Callout from "@models/Callout"; +import Callout from "#models/Callout"; -import config from "@config"; +import config from "#config"; const app = express(); diff --git a/src/apps/tools/apps/emails/app.ts b/src/apps/tools/apps/emails/app.ts index 647a34f43..364f93eff 100644 --- a/src/apps/tools/apps/emails/app.ts +++ b/src/apps/tools/apps/emails/app.ts @@ -3,17 +3,17 @@ import express from "express"; import _ from "lodash"; import Papa from "papaparse"; -import { createQueryBuilder, getRepository } from "@core/database"; -import { hasNewModel, isAdmin } from "@core/middleware"; -import { wrapAsync } from "@core/utils"; -import { formatEmailBody } from "@core/utils/email"; +import { createQueryBuilder, getRepository } from "#core/database"; +import { hasNewModel, isAdmin } from "#core/middleware"; +import { wrapAsync } from "#core/utils"; +import { formatEmailBody } from "#core/utils/email"; -import EmailService from "@core/services/EmailService"; -import OptionsService from "@core/services/OptionsService"; +import EmailService from "#core/services/EmailService"; +import OptionsService from "#core/services/OptionsService"; -import Email from "@models/Email"; -import EmailMailing, { EmailMailingRecipient } from "@models/EmailMailing"; -import SegmentOngoingEmail from "@models/SegmentOngoingEmail"; +import Email from "#models/Email"; +import EmailMailing, { EmailMailingRecipient } from "#models/EmailMailing"; +import SegmentOngoingEmail from "#models/SegmentOngoingEmail"; const app = express(); diff --git a/src/apps/tools/apps/exports/app.ts b/src/apps/tools/apps/exports/app.ts index d8fba5a96..c0a19d5ff 100644 --- a/src/apps/tools/apps/exports/app.ts +++ b/src/apps/tools/apps/exports/app.ts @@ -2,13 +2,13 @@ import express from "express"; import Papa from "papaparse"; import { ObjectLiteral, SelectQueryBuilder } from "typeorm"; -import { getRepository } from "@core/database"; -import { hasNewModel, hasSchema, isAdmin } from "@core/middleware"; -import { wrapAsync } from "@core/utils"; -import { Param, parseParams } from "@core/utils/params"; +import { getRepository } from "#core/database"; +import { hasNewModel, hasSchema, isAdmin } from "#core/middleware"; +import { wrapAsync } from "#core/utils"; +import { Param, parseParams } from "#core/utils/params"; -import Export, { ExportTypeId } from "@models/Export"; -import ExportItem from "@models/ExportItem"; +import Export, { ExportTypeId } from "#models/Export"; +import ExportItem from "#models/ExportItem"; import { createSchema, updateSchema } from "./schemas.json"; @@ -192,9 +192,8 @@ app.post( } else if (data.action === "export") { const items = await exportType.getItems(data.status); - const exportName = `export-${ - exportDetails.description - }_${new Date().toISOString()}.csv`; + const exportName = `export-${exportDetails.description + }_${new Date().toISOString()}.csv`; const exportData = await exportType.getExport(items as any); res.attachment(exportName).send(Papa.unparse(exportData as any)); // TODO: fix diff --git a/src/apps/tools/apps/exports/exports/ActiveMembersExport.ts b/src/apps/tools/apps/exports/exports/ActiveMembersExport.ts index d839e7539..df6d13292 100644 --- a/src/apps/tools/apps/exports/exports/ActiveMembersExport.ts +++ b/src/apps/tools/apps/exports/exports/ActiveMembersExport.ts @@ -1,10 +1,10 @@ import { Brackets, SelectQueryBuilder } from "typeorm"; -import { createQueryBuilder } from "@core/database"; -import { Param } from "@core/utils/params"; +import { createQueryBuilder } from "#core/database"; +import { Param } from "#core/utils/params"; -import PaymentData from "@models/PaymentData"; -import Contact from "@models/Contact"; +import PaymentData from "#models/PaymentData"; +import Contact from "#models/Contact"; import BaseExport, { ExportResult } from "./BaseExport"; diff --git a/src/apps/tools/apps/exports/exports/BaseExport.ts b/src/apps/tools/apps/exports/exports/BaseExport.ts index a6707fc07..2a6aed69e 100644 --- a/src/apps/tools/apps/exports/exports/BaseExport.ts +++ b/src/apps/tools/apps/exports/exports/BaseExport.ts @@ -1,9 +1,9 @@ import { ObjectLiteral, SelectQueryBuilder } from "typeorm"; -import { Param } from "@core/utils/params"; +import { Param } from "#core/utils/params"; -import Export from "@models/Export"; -import ExportItem from "@models/ExportItem"; +import Export from "#models/Export"; +import ExportItem from "#models/ExportItem"; export type ExportResult = | Record[] diff --git a/src/apps/tools/apps/exports/exports/EditionExport.ts b/src/apps/tools/apps/exports/exports/EditionExport.ts index 2ce934ee6..16cf4db14 100644 --- a/src/apps/tools/apps/exports/exports/EditionExport.ts +++ b/src/apps/tools/apps/exports/exports/EditionExport.ts @@ -2,10 +2,10 @@ import { ContributionType } from "@beabee/beabee-common"; import _ from "lodash"; import { SelectQueryBuilder } from "typeorm"; -import { createQueryBuilder } from "@core/database"; -import { Param } from "@core/utils/params"; +import { createQueryBuilder } from "#core/database"; +import { Param } from "#core/utils/params"; -import Contact from "@models/Contact"; +import Contact from "#models/Contact"; import { ExportResult } from "./BaseExport"; import ActiveMembersExport from "./ActiveMembersExport"; diff --git a/src/apps/tools/apps/exports/exports/GiftsExport.ts b/src/apps/tools/apps/exports/exports/GiftsExport.ts index 1d481cb55..43b484d47 100644 --- a/src/apps/tools/apps/exports/exports/GiftsExport.ts +++ b/src/apps/tools/apps/exports/exports/GiftsExport.ts @@ -1,10 +1,10 @@ import { ContributionType } from "@beabee/beabee-common"; import { SelectQueryBuilder } from "typeorm"; -import { createQueryBuilder } from "@core/database"; +import { createQueryBuilder } from "#core/database"; -import Address from "@models/Address"; -import GiftFlow from "@models/GiftFlow"; +import Address from "#models/Address"; +import GiftFlow from "#models/GiftFlow"; import BaseExport, { ExportResult } from "./BaseExport"; @@ -39,26 +39,26 @@ export default class GiftsExport extends BaseExport { return giftFlows.map(({ date, giftee, giftForm, setupCode }) => { const gifteeDetails = giftee ? { - GifteeName: giftee.fullname, - GifteeFirstName: giftee.firstname, - GifteeEmail: giftee.email, - GifteeExpiryDate: giftee.roles - .find((p) => p.type === "member") - ?.dateExpires?.toISOString(), - GifteeHasActivated: !giftee.password.hash, - GifteeHasConverted: - giftee.contributionType !== ContributionType.Gift, - ...addressFields(giftee.profile.deliveryAddress) - } + GifteeName: giftee.fullname, + GifteeFirstName: giftee.firstname, + GifteeEmail: giftee.email, + GifteeExpiryDate: giftee.roles + .find((p) => p.type === "member") + ?.dateExpires?.toISOString(), + GifteeHasActivated: !giftee.password.hash, + GifteeHasConverted: + giftee.contributionType !== ContributionType.Gift, + ...addressFields(giftee.profile.deliveryAddress) + } : { - GifteeName: giftForm.firstname + " " + giftForm.lastname, - GifteeFirstName: giftForm.firstname, - GifteeEmail: giftForm.email, - GifteeExpiryDate: "", - GifteeHasActivated: false, - GifteeHasConverted: false, - ...addressFields(giftForm.deliveryAddress) - }; + GifteeName: giftForm.firstname + " " + giftForm.lastname, + GifteeFirstName: giftForm.firstname, + GifteeEmail: giftForm.email, + GifteeExpiryDate: "", + GifteeHasActivated: false, + GifteeHasConverted: false, + ...addressFields(giftForm.deliveryAddress) + }; return { GiftPurchaseDate: date.toISOString(), diff --git a/src/apps/tools/apps/exports/exports/ReferralsExport.ts b/src/apps/tools/apps/exports/exports/ReferralsExport.ts index 04ac56533..09a929678 100644 --- a/src/apps/tools/apps/exports/exports/ReferralsExport.ts +++ b/src/apps/tools/apps/exports/exports/ReferralsExport.ts @@ -1,27 +1,27 @@ import { SelectQueryBuilder } from "typeorm"; -import { createQueryBuilder } from "@core/database"; +import { createQueryBuilder } from "#core/database"; -import Contact from "@models/Contact"; -import Referral from "@models/Referral"; +import Contact from "#models/Contact"; +import Referral from "#models/Referral"; import BaseExport, { ExportResult } from "./BaseExport"; function contactDetails(contact: Contact | null) { return contact ? [ - contact.email, - contact.firstname, - contact.lastname, - ...(contact.profile.deliveryOptIn && contact.profile.deliveryAddress - ? [ - contact.profile.deliveryAddress.line1, - contact.profile.deliveryAddress.line2, - contact.profile.deliveryAddress.city, - contact.profile.deliveryAddress.postcode - ] - : ["", "", "", ""]) - ] + contact.email, + contact.firstname, + contact.lastname, + ...(contact.profile.deliveryOptIn && contact.profile.deliveryAddress + ? [ + contact.profile.deliveryAddress.line1, + contact.profile.deliveryAddress.line2, + contact.profile.deliveryAddress.city, + contact.profile.deliveryAddress.postcode + ] + : ["", "", "", ""]) + ] : ["", "", "", "", "", "", ""]; } diff --git a/src/apps/tools/apps/polls/app.ts b/src/apps/tools/apps/polls/app.ts index 57c02bbe9..3412132e7 100644 --- a/src/apps/tools/apps/polls/app.ts +++ b/src/apps/tools/apps/polls/app.ts @@ -2,12 +2,12 @@ import express from "express"; import moment from "moment"; import { createQueryBuilder } from "typeorm"; -import { getRepository } from "@core/database"; -import { hasNewModel, isAdmin } from "@core/middleware"; -import { wrapAsync } from "@core/utils"; +import { getRepository } from "#core/database"; +import { hasNewModel, isAdmin } from "#core/middleware"; +import { wrapAsync } from "#core/utils"; -import Callout from "@models/Callout"; -import CalloutResponse from "@models/CalloutResponse"; +import Callout from "#models/Callout"; +import CalloutResponse from "#models/CalloutResponse"; const app = express(); diff --git a/src/apps/tools/apps/referrals/app.ts b/src/apps/tools/apps/referrals/app.ts index 3210767f9..edabd0fad 100644 --- a/src/apps/tools/apps/referrals/app.ts +++ b/src/apps/tools/apps/referrals/app.ts @@ -1,11 +1,11 @@ import express from "express"; import _ from "lodash"; -import { getRepository } from "@core/database"; -import { hasNewModel, hasSchema, isAdmin } from "@core/middleware"; -import { wrapAsync } from "@core/utils"; +import { getRepository } from "#core/database"; +import { hasNewModel, hasSchema, isAdmin } from "#core/middleware"; +import { wrapAsync } from "#core/utils"; -import ReferralGift from "@models/ReferralGift"; +import ReferralGift from "#models/ReferralGift"; import { updateSchema } from "./schemas.json"; diff --git a/src/apps/tools/apps/special-urls/actions/index.js b/src/apps/tools/apps/special-urls/actions/index.js index 044f60965..dad7dcc1d 100644 --- a/src/apps/tools/apps/special-urls/actions/index.js +++ b/src/apps/tools/apps/special-urls/actions/index.js @@ -1,7 +1,7 @@ -const { Members } = require("@core/database"); +const { Members } = require("#core/database"); const { default: GCPaymentService -} = require("@core/services/GCPaymentService"); +} = require("#core/services/GCPaymentService"); module.exports = [ { diff --git a/src/apps/tools/apps/special-urls/app.js b/src/apps/tools/apps/special-urls/app.js index ed440b3c0..29bd6648d 100644 --- a/src/apps/tools/apps/special-urls/app.js +++ b/src/apps/tools/apps/special-urls/app.js @@ -4,10 +4,10 @@ const _ = require("lodash"); const moment = require("moment"); const Papa = require("papaparse"); -const { SpecialUrlGroups, SpecialUrls } = require("@core/database"); -const { hasModel, hasSchema, isAdmin } = require("@core/middleware"); -const { wrapAsync } = require("@core/utils"); -const { loadParams, parseParams } = require("@core/utils/params"); +const { SpecialUrlGroups, SpecialUrls } = require("#core/database"); +const { hasModel, hasSchema, isAdmin } = require("#core/middleware"); +const { wrapAsync } = require("#core/utils"); +const { loadParams, parseParams } = require("#core/utils/params"); const actions = require("./actions"); const { @@ -107,9 +107,8 @@ app.post( }); break; case "export-urls": { - const exportName = `export-${ - req.model.name - }_${new Date().toISOString()}.csv`; + const exportName = `export-${req.model.name + }_${new Date().toISOString()}.csv`; const exportData = (await SpecialUrls.find({ group: req.model })) .filter((specialUrl) => !req.body.onlyActive || specialUrl.active) .map((specialUrl) => ({ diff --git a/src/apps/tools/apps/special-urls/handler.js b/src/apps/tools/apps/special-urls/handler.js index 62f1fb4fa..167baca0a 100644 --- a/src/apps/tools/apps/special-urls/handler.js +++ b/src/apps/tools/apps/special-urls/handler.js @@ -3,10 +3,10 @@ const _ = require("lodash"); const moment = require("moment"); const mongoose = require("mongoose"); -const { SpecialUrls } = require("@core/database"); -const { wrapAsync } = require("@core/utils"); +const { SpecialUrls } = require("#core/database"); +const { wrapAsync } = require("#core/utils"); -const { default: EmailService } = require("@core/services/EmailService"); +const { default: EmailService } = require("#core/services/EmailService"); const actions = require("./actions"); const { getSpecialUrlUrl } = require("./utils"); diff --git a/src/apps/tools/apps/special-urls/utils.js b/src/apps/tools/apps/special-urls/utils.js index 208624f0e..1f6e78e76 100644 --- a/src/apps/tools/apps/special-urls/utils.js +++ b/src/apps/tools/apps/special-urls/utils.js @@ -1,4 +1,4 @@ -const config = require("@config"); +const config = require("#config"); module.exports = { getSpecialUrlUrl(specialUrl) { diff --git a/src/core/app-loader.ts b/src/core/app-loader.ts index 56ec593d5..cbb48f481 100644 --- a/src/core/app-loader.ts +++ b/src/core/app-loader.ts @@ -7,10 +7,10 @@ import config, { AppConfig, AppConfigOverride, AppConfigOverrides -} from "@config"; +} from "#config"; -import { log as mainLogger } from "@core/logging"; -import templateLocals from "@core/template-locals"; +import { log as mainLogger } from "#core/logging"; +import templateLocals from "#core/template-locals"; let git = ""; try { diff --git a/src/core/database.ts b/src/core/database.ts index b1c97b76e..74818ed0c 100644 --- a/src/core/database.ts +++ b/src/core/database.ts @@ -10,9 +10,9 @@ import { SelectQueryBuilder } from "typeorm"; -import { log as mainLogger } from "@core/logging"; +import { log as mainLogger } from "#core/logging"; -import config from "@config"; +import config from "#config"; const log = mainLogger.child({ app: "database" }); diff --git a/src/core/lib/ajv.ts b/src/core/lib/ajv.ts index f98f89ab3..b11506bd5 100644 --- a/src/core/lib/ajv.ts +++ b/src/core/lib/ajv.ts @@ -1,4 +1,4 @@ -import config from "@config"; +import config from "#config"; import Ajv from "ajv"; import addFormats from "ajv-formats"; diff --git a/src/core/lib/captchafox.ts b/src/core/lib/captchafox.ts index a231a1282..3da69cda3 100644 --- a/src/core/lib/captchafox.ts +++ b/src/core/lib/captchafox.ts @@ -1,6 +1,6 @@ import { verify as cfVerify } from "@captchafox/node"; -import config from "@config"; +import config from "#config"; export async function verify(token: string): Promise { const resp = await cfVerify(config.captchaFox.secret, token); diff --git a/src/core/lib/gocardless.ts b/src/core/lib/gocardless.ts index a0137a1a7..4bc8a4496 100644 --- a/src/core/lib/gocardless.ts +++ b/src/core/lib/gocardless.ts @@ -13,17 +13,16 @@ import { } from "gocardless-nodejs/types/Types"; import { v4 as uuidv4 } from "uuid"; -import { log as mainLogger } from "@core/logging"; +import { log as mainLogger } from "#core/logging"; -import config from "@config"; +import config from "#config"; import { DeepPartial } from "typeorm"; const log = mainLogger.child({ app: "gocardless-api" }); const gocardless = axios.create({ - baseURL: `https://${ - config.gocardless.sandbox ? "api-sandbox" : "api" - }.gocardless.com`, + baseURL: `https://${config.gocardless.sandbox ? "api-sandbox" : "api" + }.gocardless.com`, headers: { Authorization: `Bearer ${config.gocardless.accessToken}`, "GoCardless-Version": "2015-07-06", @@ -195,10 +194,10 @@ export default { req.body && req.headers["content-type"] === "application/json" && req.headers["webhook-signature"] === - crypto - .createHmac("sha256", config.gocardless.secret) - .update(req.body) - .digest("hex") + crypto + .createHmac("sha256", config.gocardless.secret) + .update(req.body) + .digest("hex") ); } } diff --git a/src/core/lib/passport.ts b/src/core/lib/passport.ts index 81bac1333..827bbaa3b 100644 --- a/src/core/lib/passport.ts +++ b/src/core/lib/passport.ts @@ -1,25 +1,25 @@ import passport from "passport"; import passportLocal from "passport-local"; -import config from "@config"; +import config from "#config"; -import { getRepository } from "@core/database"; -import { log } from "@core/logging"; -import { cleanEmailAddress, sleep } from "@core/utils"; -import { generatePassword, isValidPassword } from "@core/utils/auth"; +import { getRepository } from "#core/database"; +import { log } from "#core/logging"; +import { cleanEmailAddress, sleep } from "#core/utils"; +import { generatePassword, isValidPassword } from "#core/utils/auth"; -import ContactsService from "@core/services/ContactsService"; -import ContactMfaService from "@core/services/ContactMfaService"; +import ContactsService from "#core/services/ContactsService"; +import ContactMfaService from "#core/services/ContactMfaService"; -import { CONTACT_MFA_TYPE } from "@enums/contact-mfa-type"; -import { LOGIN_CODES } from "@enums/login-codes"; -import { LoginDto } from "@api/dto/LoginDto"; -import { UnauthorizedError } from "@api/errors/UnauthorizedError"; +import { CONTACT_MFA_TYPE } from "#enums/contact-mfa-type"; +import { LOGIN_CODES } from "#enums/login-codes"; +import { LoginDto } from "#api/dto/LoginDto"; +import { UnauthorizedError } from "#api/errors/UnauthorizedError"; -import Contact from "@models/Contact"; +import Contact from "#models/Contact"; -import type { ContactMfaSecure } from "@type/contact-mfa-secure"; -import type { PassportLocalDoneCallback } from "@type/passport-local-done-callback"; +import type { ContactMfaSecure } from "#type/contact-mfa-secure"; +import type { PassportLocalDoneCallback } from "#type/passport-local-done-callback"; // Add support for local authentication in Passport.js passport.use( diff --git a/src/core/lib/stripe.ts b/src/core/lib/stripe.ts index 21b66539b..1b2214131 100644 --- a/src/core/lib/stripe.ts +++ b/src/core/lib/stripe.ts @@ -1,5 +1,5 @@ import Stripe from "stripe"; -import config from "@config"; +import config from "#config"; export default new Stripe(config.stripe.secretKey, { apiVersion: "2020-08-27", diff --git a/src/core/logging.ts b/src/core/logging.ts index 217b4ed1a..ebb2efadd 100644 --- a/src/core/logging.ts +++ b/src/core/logging.ts @@ -1,7 +1,7 @@ import expressWinston from "express-winston"; import winston from "winston"; -import config from "@config"; +import config from "#config"; const appFormat = winston.format((info) => { const { app, ...rest } = info; diff --git a/src/core/middleware.ts b/src/core/middleware.ts index d31fe13f8..7ca8bf2cc 100644 --- a/src/core/middleware.ts +++ b/src/core/middleware.ts @@ -2,14 +2,14 @@ import { ErrorObject, ValidateFunction } from "ajv"; import { NextFunction, Request, RequestHandler, Response } from "express"; import { EntityTarget, FindOneOptions, ObjectLiteral } from "typeorm"; -import { getRepository } from "@core/database"; -import ajv from "@core/lib/ajv"; -import { wrapAsync, isInvalidType } from "@core/utils"; -import * as auth from "@core/utils/auth"; +import { getRepository } from "#core/database"; +import ajv from "#core/lib/ajv"; +import { wrapAsync, isInvalidType } from "#core/utils"; +import * as auth from "#core/utils/auth"; -import OptionsService from "@core/services/OptionsService"; +import OptionsService from "#core/services/OptionsService"; -import config from "@config"; +import config from "#config"; interface OnErrorHandler { ( @@ -75,8 +75,8 @@ const send400: OnErrorHandler = (errors, req, res) => { const redirectTo = (url: string): OnErrorHandler => - (errors, req, res) => - res.redirect(url); + (errors, req, res) => + res.redirect(url); const replyWithJSON: OnErrorHandler = (errors, req, res) => { res.status(400).send(convertErrorsToMessages(errors)); diff --git a/src/core/providers/email/BaseProvider.ts b/src/core/providers/email/BaseProvider.ts index 204e2b63c..bae6f924a 100644 --- a/src/core/providers/email/BaseProvider.ts +++ b/src/core/providers/email/BaseProvider.ts @@ -1,14 +1,14 @@ -import { createQueryBuilder, getRepository } from "@core/database"; -import { log as mainLogger } from "@core/logging"; -import { formatEmailBody } from "@core/utils/email"; +import { createQueryBuilder, getRepository } from "#core/database"; +import { log as mainLogger } from "#core/logging"; +import { formatEmailBody } from "#core/utils/email"; -import OptionsService from "@core/services/OptionsService"; -import ResetSecurityFlowService from "@core/services/ResetSecurityFlowService"; +import OptionsService from "#core/services/OptionsService"; +import ResetSecurityFlowService from "#core/services/ResetSecurityFlowService"; -import Email from "@models/Email"; -import Contact from "@models/Contact"; +import Email from "#models/Email"; +import Contact from "#models/Contact"; -import { RESET_SECURITY_FLOW_TYPE } from "@enums/reset-security-flow-type"; +import { RESET_SECURITY_FLOW_TYPE } from "#enums/reset-security-flow-type"; import { EmailProvider, @@ -18,7 +18,7 @@ import { PreparedEmail } from "."; -import config from "@config"; +import config from "#config"; const log = mainLogger.child({ app: "base-email-provider" }); @@ -85,12 +85,12 @@ const magicMergeFieldsProcessors = { recipient.mergeFields?.LOGINLINK ? recipient : { - ...recipient, - mergeFields: { - ...recipient.mergeFields, - LOGINLINK: `${config.audience}/auth/login` - } + ...recipient, + mergeFields: { + ...recipient.mergeFields, + LOGINLINK: `${config.audience}/auth/login` } + } ); } } as const; diff --git a/src/core/providers/email/MandrillProvider.ts b/src/core/providers/email/MandrillProvider.ts index bcb796130..2f68f4384 100644 --- a/src/core/providers/email/MandrillProvider.ts +++ b/src/core/providers/email/MandrillProvider.ts @@ -1,13 +1,13 @@ import axios, { AxiosRequestTransformer } from "axios"; -import { log as mainLogger } from "@core/logging"; +import { log as mainLogger } from "#core/logging"; -import Email from "@models/Email"; +import Email from "#models/Email"; import { EmailOptions, EmailRecipient, EmailTemplate, PreparedEmail } from "."; import BaseProvider from "./BaseProvider"; -import { MandrillEmailConfig } from "@config"; +import { MandrillEmailConfig } from "#config"; const log = mainLogger.child({ app: "mandrill-email-provider" }); diff --git a/src/core/providers/email/SMTPProvider.ts b/src/core/providers/email/SMTPProvider.ts index 7f554d4da..aaac926b5 100644 --- a/src/core/providers/email/SMTPProvider.ts +++ b/src/core/providers/email/SMTPProvider.ts @@ -1,14 +1,14 @@ import nodemailer from "nodemailer"; import Mail from "nodemailer/lib/mailer"; -import { log as mainLogger } from "@core/logging"; +import { log as mainLogger } from "#core/logging"; -import OptionsService from "@core/services/OptionsService"; +import OptionsService from "#core/services/OptionsService"; import { EmailOptions, EmailRecipient, PreparedEmail } from "."; import BaseProvider from "./BaseProvider"; -import { SMTPEmailConfig } from "@config"; +import { SMTPEmailConfig } from "#config"; const log = mainLogger.child({ app: "smtp-email-provider" }); diff --git a/src/core/providers/email/SendGridProvider.ts b/src/core/providers/email/SendGridProvider.ts index 2b266b644..61cdc7749 100644 --- a/src/core/providers/email/SendGridProvider.ts +++ b/src/core/providers/email/SendGridProvider.ts @@ -1,11 +1,11 @@ import sgMail from "@sendgrid/mail"; -import { log as mainLogger } from "@core/logging"; +import { log as mainLogger } from "#core/logging"; import { EmailOptions, EmailRecipient, PreparedEmail } from "."; import BaseProvider from "./BaseProvider"; -import { SendGridEmailConfig } from "@config"; +import { SendGridEmailConfig } from "#config"; const log = mainLogger.child({ app: "sendgrid-email-provider" }); diff --git a/src/core/providers/email/index.ts b/src/core/providers/email/index.ts index 4f2b9bea2..59e7f9174 100644 --- a/src/core/providers/email/index.ts +++ b/src/core/providers/email/index.ts @@ -1,4 +1,4 @@ -import Email from "@models/Email"; +import Email from "#models/Email"; export interface EmailTemplate { id: string; diff --git a/src/core/providers/newsletter/MailchimpProvider.ts b/src/core/providers/newsletter/MailchimpProvider.ts index 94518d1c3..226bc8e72 100644 --- a/src/core/providers/newsletter/MailchimpProvider.ts +++ b/src/core/providers/newsletter/MailchimpProvider.ts @@ -4,8 +4,8 @@ import gunzip from "gunzip-maybe"; import JSONStream from "JSONStream"; import tar from "tar-stream"; -import { log as mainLogger } from "@core/logging"; -import { cleanEmailAddress } from "@core/utils"; +import { log as mainLogger } from "#core/logging"; +import { cleanEmailAddress } from "#core/utils"; import { NewsletterContact, @@ -13,7 +13,7 @@ import { UpdateNewsletterContact } from "."; -import { MailchimpNewsletterConfig } from "@config"; +import { MailchimpNewsletterConfig } from "#config"; import { NewsletterStatus } from "@beabee/beabee-common"; const log = mainLogger.child({ app: "mailchimp-provider" }); @@ -157,8 +157,8 @@ function mcMemberToNlContact(member: MCMember): NewsletterContact { status: mcStatusToStatus(member.status), groups: member.interests ? Object.entries(member.interests) - .filter(([group, isOptedIn]) => isOptedIn) - .map(([group]) => group) + .filter(([group, isOptedIn]) => isOptedIn) + .map(([group]) => group) : [], tags: member.tags.map((tag) => tag.name), fields @@ -211,7 +211,7 @@ export default class MailchimpProvider implements NewsletterProvider { try { const resp = await this.instance.get(this.emailUrl(email)); return mcMemberToNlContact(resp.data); - } catch (err) {} + } catch (err) { } } async getContacts(): Promise { diff --git a/src/core/providers/payment-flow/GCProvider.ts b/src/core/providers/payment-flow/GCProvider.ts index 87eb1caf5..f690ef95c 100644 --- a/src/core/providers/payment-flow/GCProvider.ts +++ b/src/core/providers/payment-flow/GCProvider.ts @@ -1,7 +1,7 @@ -import gocardless from "@core/lib/gocardless"; -import { log as mainLogger } from "@core/logging"; +import gocardless from "#core/lib/gocardless"; +import { log as mainLogger } from "#core/logging"; -import JoinFlow from "@models/JoinFlow"; +import JoinFlow from "#models/JoinFlow"; import { CompletedPaymentFlow, diff --git a/src/core/providers/payment-flow/StripeProvider.ts b/src/core/providers/payment-flow/StripeProvider.ts index 215338aa3..28fd55b64 100644 --- a/src/core/providers/payment-flow/StripeProvider.ts +++ b/src/core/providers/payment-flow/StripeProvider.ts @@ -1,6 +1,6 @@ -import stripe from "@core/lib/stripe"; -import { log as mainLogger } from "@core/logging"; -import { paymentMethodToStripeType } from "@core/utils/payment/stripe"; +import stripe from "#core/lib/stripe"; +import { log as mainLogger } from "#core/logging"; +import { paymentMethodToStripeType } from "#core/utils/payment/stripe"; import { CompletedPaymentFlow, @@ -9,7 +9,7 @@ import { PaymentFlowProvider } from "."; -import JoinFlow from "@models/JoinFlow"; +import JoinFlow from "#models/JoinFlow"; const log = mainLogger.child({ app: "stripe-payment-flow-provider" }); diff --git a/src/core/providers/payment-flow/index.ts b/src/core/providers/payment-flow/index.ts index 50700d167..6b3f68f29 100644 --- a/src/core/providers/payment-flow/index.ts +++ b/src/core/providers/payment-flow/index.ts @@ -1,7 +1,7 @@ import { PaymentMethod } from "@beabee/beabee-common"; -import Address from "@models/Address"; -import JoinFlow from "@models/JoinFlow"; +import Address from "#models/Address"; +import JoinFlow from "#models/JoinFlow"; export interface PaymentFlow { id: string; diff --git a/src/core/providers/payment/GCProvider.ts b/src/core/providers/payment/GCProvider.ts index c0edba829..be6c95c04 100644 --- a/src/core/providers/payment/GCProvider.ts +++ b/src/core/providers/payment/GCProvider.ts @@ -2,30 +2,30 @@ import { PaymentMethod } from "@beabee/beabee-common"; import { Subscription } from "gocardless-nodejs"; import moment from "moment"; -import gocardless from "@core/lib/gocardless"; -import { log as mainLogger } from "@core/logging"; -import { getActualAmount, PaymentForm } from "@core/utils"; +import gocardless from "#core/lib/gocardless"; +import { log as mainLogger } from "#core/logging"; +import { getActualAmount, PaymentForm } from "#core/utils"; import { updateSubscription, createSubscription, prorateSubscription, hasPendingPayment, getSubscriptionNextChargeDate -} from "@core/utils/payment/gocardless"; -import { calcRenewalDate } from "@core/utils/payment"; +} from "#core/utils/payment/gocardless"; +import { calcRenewalDate } from "#core/utils/payment"; import { PaymentProvider, UpdateContributionResult } from "."; -import { CompletedPaymentFlow } from "@core/providers/payment-flow"; +import { CompletedPaymentFlow } from "#core/providers/payment-flow"; -import Contact from "@models/Contact"; -import { GCPaymentData } from "@models/PaymentData"; +import Contact from "#models/Contact"; +import { GCPaymentData } from "#models/PaymentData"; -import NoPaymentMethod from "@api/errors/NoPaymentMethod"; +import NoPaymentMethod from "#api/errors/NoPaymentMethod"; -import config from "@config"; +import config from "#config"; -import { ContributionInfo } from "@type/contribution-info"; -import { PaymentSource } from "@type/payment-source"; +import { ContributionInfo } from "#type/contribution-info"; +import { PaymentSource } from "#type/payment-source"; const log = mainLogger.child({ app: "gc-payment-provider" }); @@ -61,11 +61,11 @@ export default class GCProvider extends PaymentProvider { hasPendingPayment: pendingPayment, ...(this.data.nextAmount && this.contact.contributionPeriod && { - nextAmount: getActualAmount( - this.data.nextAmount.monthly, - this.contact.contributionPeriod - ) - }), + nextAmount: getActualAmount( + this.data.nextAmount.monthly, + this.contact.contributionPeriod + ) + }), ...(paymentSource && { paymentSource }) }; } @@ -161,9 +161,9 @@ export default class GCProvider extends PaymentProvider { this.data.nextAmount = startNow ? null : { - monthly: paymentForm.monthlyAmount, - chargeable: Number(subscription.amount) - }; + monthly: paymentForm.monthlyAmount, + chargeable: Number(subscription.amount) + }; await this.updateData(); diff --git a/src/core/providers/payment/ManualProvider.ts b/src/core/providers/payment/ManualProvider.ts index 3c90aae69..ed091d603 100644 --- a/src/core/providers/payment/ManualProvider.ts +++ b/src/core/providers/payment/ManualProvider.ts @@ -1,9 +1,9 @@ -import { PaymentForm } from "@core/utils"; -import Contact from "@models/Contact"; -import { ManualPaymentData } from "@models/PaymentData"; +import { PaymentForm } from "#core/utils"; +import Contact from "#models/Contact"; +import { ManualPaymentData } from "#models/PaymentData"; import { PaymentProvider, UpdateContributionResult } from "."; import { CompletedPaymentFlow } from "../payment-flow"; -import { ContributionInfo } from "@type/contribution-info"; +import { ContributionInfo } from "#type/contribution-info"; export default class ManualProvider extends PaymentProvider< ManualPaymentData | {} @@ -20,8 +20,8 @@ export default class ManualProvider extends PaymentProvider< }; } - async cancelContribution(keepMandate: boolean): Promise {} - async updateContact(updates: Partial): Promise {} + async cancelContribution(keepMandate: boolean): Promise { } + async updateContact(updates: Partial): Promise { } async updateContribution( paymentForm: PaymentForm diff --git a/src/core/providers/payment/StripeProvider.ts b/src/core/providers/payment/StripeProvider.ts index 03097d547..820208a66 100644 --- a/src/core/providers/payment/StripeProvider.ts +++ b/src/core/providers/payment/StripeProvider.ts @@ -3,28 +3,28 @@ import { add } from "date-fns"; import Stripe from "stripe"; import { PaymentProvider, UpdateContributionResult } from "."; -import { CompletedPaymentFlow } from "@core/providers/payment-flow"; +import { CompletedPaymentFlow } from "#core/providers/payment-flow"; -import stripe from "@core/lib/stripe"; -import { log as mainLogger } from "@core/logging"; -import { getActualAmount, PaymentForm } from "@core/utils"; -import { calcRenewalDate, getChargeableAmount } from "@core/utils/payment"; +import stripe from "#core/lib/stripe"; +import { log as mainLogger } from "#core/logging"; +import { getActualAmount, PaymentForm } from "#core/utils"; +import { calcRenewalDate, getChargeableAmount } from "#core/utils/payment"; import { createSubscription, deleteSubscription, manadateToSource, updateSubscription -} from "@core/utils/payment/stripe"; +} from "#core/utils/payment/stripe"; -import Contact from "@models/Contact"; -import { StripePaymentData } from "@models/PaymentData"; +import Contact from "#models/Contact"; +import { StripePaymentData } from "#models/PaymentData"; -import NoPaymentMethod from "@api/errors/NoPaymentMethod"; +import NoPaymentMethod from "#api/errors/NoPaymentMethod"; -import config from "@config"; +import config from "#config"; -import { ContributionInfo } from "@type/contribution-info"; -import { PaymentSource } from "@type/payment-source"; +import { ContributionInfo } from "#type/contribution-info"; +import { PaymentSource } from "#type/payment-source"; const log = mainLogger.child({ app: "stripe-payment-provider" }); @@ -58,11 +58,11 @@ export default class StripeProvider extends PaymentProvider { ...(paymentSource && { paymentSource }), ...(this.data.nextAmount && this.contact.contributionPeriod && { - nextAmount: getActualAmount( - this.data.nextAmount.monthly, - this.contact.contributionPeriod - ) - }) + nextAmount: getActualAmount( + this.data.nextAmount.monthly, + this.contact.contributionPeriod + ) + }) }; } @@ -151,9 +151,9 @@ export default class StripeProvider extends PaymentProvider { this.data.nextAmount = startNow ? null : { - chargeable: getChargeableAmount(paymentForm, this.method), - monthly: paymentForm.monthlyAmount - }; + chargeable: getChargeableAmount(paymentForm, this.method), + monthly: paymentForm.monthlyAmount + }; await this.updateData(); diff --git a/src/core/providers/payment/index.ts b/src/core/providers/payment/index.ts index 9adbc6a45..776e95464 100644 --- a/src/core/providers/payment/index.ts +++ b/src/core/providers/payment/index.ts @@ -1,13 +1,13 @@ import { PaymentMethod } from "@beabee/beabee-common"; -import { getRepository } from "@core/database"; -import { PaymentForm } from "@core/utils"; +import { getRepository } from "#core/database"; +import { PaymentForm } from "#core/utils"; -import { CompletedPaymentFlow } from "@core/providers/payment-flow"; +import { CompletedPaymentFlow } from "#core/providers/payment-flow"; -import Contact from "@models/Contact"; -import PaymentData, { PaymentProviderData } from "@models/PaymentData"; -import { ContributionInfo } from "@type/contribution-info"; +import Contact from "#models/Contact"; +import PaymentData, { PaymentProviderData } from "#models/PaymentData"; +import { ContributionInfo } from "#type/contribution-info"; export interface UpdateContributionResult { startNow: boolean; diff --git a/src/core/quickflash.ts b/src/core/quickflash.ts index 22aa87e8b..3d6df83d0 100644 --- a/src/core/quickflash.ts +++ b/src/core/quickflash.ts @@ -1,4 +1,4 @@ -import OptionsService from "@core/services/OptionsService"; +import OptionsService from "#core/services/OptionsService"; import { NextFunction, Request, Response } from "express"; export default function ( diff --git a/src/core/server.ts b/src/core/server.ts index 29c08a5c7..ffeb5c7db 100644 --- a/src/core/server.ts +++ b/src/core/server.ts @@ -1,10 +1,10 @@ import { Express } from "express"; -import * as db from "@core/database"; -import { log as mainLogger } from "@core/logging"; +import * as db from "#core/database"; +import { log as mainLogger } from "#core/logging"; -import OptionsService from "@core/services/OptionsService"; -import NetworkCommunicatorService from "@core/services/NetworkCommunicatorService"; +import OptionsService from "#core/services/OptionsService"; +import NetworkCommunicatorService from "#core/services/NetworkCommunicatorService"; const log = mainLogger.child({ app: "server" }); diff --git a/src/core/services/CalloutsService.ts b/src/core/services/CalloutsService.ts index 05ba74589..799bf0b36 100644 --- a/src/core/services/CalloutsService.ts +++ b/src/core/services/CalloutsService.ts @@ -6,28 +6,28 @@ import slugify from "slugify"; import { BadRequestError } from "routing-controllers"; import { QueryDeepPartialEntity } from "typeorm/query-builder/QueryPartialEntity"; -import EmailService from "@core/services/EmailService"; -import NewsletterService from "@core/services/NewsletterService"; -import OptionsService from "@core/services/OptionsService"; +import EmailService from "#core/services/EmailService"; +import NewsletterService from "#core/services/NewsletterService"; +import OptionsService from "#core/services/OptionsService"; -import { getRepository, runTransaction } from "@core/database"; -import { isDuplicateIndex } from "@core/utils"; +import { getRepository, runTransaction } from "#core/database"; +import { isDuplicateIndex } from "#core/utils"; -import Contact from "@models/Contact"; -import Callout from "@models/Callout"; -import CalloutResponse from "@models/CalloutResponse"; -import CalloutResponseComment from "@models/CalloutResponseComment"; -import CalloutResponseTag from "@models/CalloutResponseTag"; -import CalloutTag from "@models/CalloutTag"; -import CalloutVariant from "@models/CalloutVariant"; +import Contact from "#models/Contact"; +import Callout from "#models/Callout"; +import CalloutResponse from "#models/CalloutResponse"; +import CalloutResponseComment from "#models/CalloutResponseComment"; +import CalloutResponseTag from "#models/CalloutResponseTag"; +import CalloutTag from "#models/CalloutTag"; +import CalloutVariant from "#models/CalloutVariant"; -import DuplicateId from "@api/errors/DuplicateId"; +import DuplicateId from "#api/errors/DuplicateId"; -import InvalidCalloutResponse from "@api/errors/InvalidCalloutResponse"; +import InvalidCalloutResponse from "#api/errors/InvalidCalloutResponse"; -import { CalloutAccess } from "@enums/callout-access"; -import { CreateCalloutData } from "@type/callout-data"; -import NotFoundError from "@api/errors/NotFoundError"; +import { CalloutAccess } from "#enums/callout-access"; +import { CreateCalloutData } from "#type/callout-data"; +import NotFoundError from "#api/errors/NotFoundError"; class CalloutsService { /** diff --git a/src/core/services/ContactMfaService.ts b/src/core/services/ContactMfaService.ts index a680ebbae..5431546ae 100644 --- a/src/core/services/ContactMfaService.ts +++ b/src/core/services/ContactMfaService.ts @@ -1,19 +1,20 @@ import { NotFoundError } from "routing-controllers"; -import Contact from "@models/Contact"; -import ContactMfa from "@models/ContactMfa"; +import ContactMfa from "#models/ContactMfa"; -import { getRepository } from "@core/database"; -import { validateTotpToken } from "@core/utils/auth"; +import { getRepository } from "#core/database"; +import { validateTotpToken } from "#core/utils/auth"; -import { LOGIN_CODES } from "@enums/login-codes"; +import { LOGIN_CODES } from "#enums/login-codes"; -import BadRequestError from "@api/errors/BadRequestError"; -import UnauthorizedError from "@api/errors/UnauthorizedError"; +import BadRequestError from "#api/errors/BadRequestError"; +import UnauthorizedError from "#api/errors/UnauthorizedError"; -import { ContactMfaSecure } from "@type/contact-mfa-secure"; -import { CreateContactMfaData } from "@type/create-contact-mfa-data"; -import { DeleteContactMfaData } from "@type/delete-contact-mfa-data"; +import { ContactMfaSecure } from "#type/contact-mfa-secure"; +import { CreateContactMfaData } from "#type/create-contact-mfa-data"; +import { DeleteContactMfaData } from "#type/delete-contact-mfa-data"; + +import type Contact from "#models/Contact"; /** * Contact multi factor authentication service diff --git a/src/core/services/ContactsService.ts b/src/core/services/ContactsService.ts index 02a3071bd..d5ad61f7f 100644 --- a/src/core/services/ContactsService.ts +++ b/src/core/services/ContactsService.ts @@ -6,34 +6,34 @@ import { } from "@beabee/beabee-common"; import { FindManyOptions, FindOneOptions, FindOptionsWhere, In } from "typeorm"; -import { createQueryBuilder, getRepository } from "@core/database"; -import { log as mainLogger } from "@core/logging"; -import { cleanEmailAddress, isDuplicateIndex, PaymentForm } from "@core/utils"; -import { generatePassword, isValidPassword } from "@core/utils/auth"; -import { generateContactCode } from "@core/utils/contact"; - -import ContactMfaService from "@core/services/ContactMfaService"; -import EmailService from "@core/services/EmailService"; -import NewsletterService from "@core/services/NewsletterService"; -import OptionsService from "@core/services/OptionsService"; -import PaymentService from "@core/services/PaymentService"; -import ResetSecurityFlowService from "@core/services/ResetSecurityFlowService"; - -import Contact from "@models/Contact"; -import ContactProfile from "@models/ContactProfile"; -import ContactRole from "@models/ContactRole"; -import Password from "@models/Password"; - -import BadRequestError from "@api/errors/BadRequestError"; -import CantUpdateContribution from "@api/errors/CantUpdateContribution"; -import DuplicateEmailError from "@api/errors/DuplicateEmailError"; -import NotFoundError from "@api/errors/NotFoundError"; -import UnauthorizedError from "@api/errors/UnauthorizedError"; - -import { CONTACT_MFA_TYPE } from "@enums/contact-mfa-type"; -import { LOGIN_CODES } from "@enums/login-codes"; -import { RESET_SECURITY_FLOW_TYPE } from "@enums/reset-security-flow-type"; -import { RESET_SECURITY_FLOW_ERROR_CODE } from "@enums/reset-security-flow-error-code"; +import { createQueryBuilder, getRepository } from "#core/database"; +import { log as mainLogger } from "#core/logging"; +import { cleanEmailAddress, isDuplicateIndex, PaymentForm } from "#core/utils"; +import { generatePassword, isValidPassword } from "#core/utils/auth"; +import { generateContactCode } from "#core/utils/contact"; + +import ContactMfaService from "#core/services/ContactMfaService"; +import EmailService from "#core/services/EmailService"; +import NewsletterService from "#core/services/NewsletterService"; +import OptionsService from "#core/services/OptionsService"; +import PaymentService from "#core/services/PaymentService"; +import ResetSecurityFlowService from "#core/services/ResetSecurityFlowService"; + +import Contact from "#models/Contact"; +import ContactProfile from "#models/ContactProfile"; +import ContactRole from "#models/ContactRole"; +import Password from "#models/Password"; + +import BadRequestError from "#api/errors/BadRequestError"; +import CantUpdateContribution from "#api/errors/CantUpdateContribution"; +import DuplicateEmailError from "#api/errors/DuplicateEmailError"; +import NotFoundError from "#api/errors/NotFoundError"; +import UnauthorizedError from "#api/errors/UnauthorizedError"; + +import { CONTACT_MFA_TYPE } from "#enums/contact-mfa-type"; +import { LOGIN_CODES } from "#enums/login-codes"; +import { RESET_SECURITY_FLOW_TYPE } from "#enums/reset-security-flow-type"; +import { RESET_SECURITY_FLOW_ERROR_CODE } from "#enums/reset-security-flow-error-code"; export type PartialContact = Pick & Partial; diff --git a/src/core/services/EmailService.ts b/src/core/services/EmailService.ts index ab6f5d673..acf3481d7 100644 --- a/src/core/services/EmailService.ts +++ b/src/core/services/EmailService.ts @@ -3,9 +3,9 @@ import moment from "moment"; import path from "path"; import { loadFront } from "yaml-front-matter"; -import { log as mainLogger } from "@core/logging"; +import { log as mainLogger } from "#core/logging"; -import OptionsService from "@core/services/OptionsService"; +import OptionsService from "#core/services/OptionsService"; import { EmailMergeFields, @@ -13,17 +13,17 @@ import { EmailPerson, EmailProvider, EmailRecipient -} from "@core/providers/email"; -import MandrillProvider from "@core/providers/email/MandrillProvider"; -import SendGridProvider from "@core/providers/email/SendGridProvider"; -import SMTPProvider from "@core/providers/email/SMTPProvider"; +} from "#core/providers/email"; +import MandrillProvider from "#core/providers/email/MandrillProvider"; +import SendGridProvider from "#core/providers/email/SendGridProvider"; +import SMTPProvider from "#core/providers/email/SMTPProvider"; -import Email from "@models/Email"; -import Contact from "@models/Contact"; -import Callout from "@models/Callout"; +import Email from "#models/Email"; +import Contact from "#models/Contact"; +import Callout from "#models/Callout"; -import config from "@config"; -import { isLocale, Locale } from "@locale"; +import config from "#config"; +import { isLocale, Locale } from "#locale"; const log = mainLogger.child({ app: "email-service" }); @@ -222,8 +222,8 @@ class EmailService { ): Promise; async sendTemplateToContact< T extends ContactEmailParams extends undefined - ? ContactEmailTemplateId - : never + ? ContactEmailTemplateId + : never >( template: T, contact: Contact, diff --git a/src/core/services/GiftService.ts b/src/core/services/GiftService.ts index aa21618fb..e08b384dc 100644 --- a/src/core/services/GiftService.ts +++ b/src/core/services/GiftService.ts @@ -3,20 +3,20 @@ import muhammara from "muhammara"; import moment from "moment"; import { getRepository } from "typeorm"; -import { log as mainLogger } from "@core/logging"; -import stripe from "@core/lib/stripe"; -import { isDuplicateIndex } from "@core/utils"; +import { log as mainLogger } from "#core/logging"; +import stripe from "#core/lib/stripe"; +import { isDuplicateIndex } from "#core/utils"; -import EmailService from "@core/services/EmailService"; -import ContactsService from "@core/services/ContactsService"; -import OptionsService from "@core/services/OptionsService"; +import EmailService from "#core/services/EmailService"; +import ContactsService from "#core/services/ContactsService"; +import OptionsService from "#core/services/OptionsService"; -import Address from "@models/Address"; -import GiftFlow, { GiftForm } from "@models/GiftFlow"; -import ContactRole from "@models/ContactRole"; +import Address from "#models/Address"; +import GiftFlow, { GiftForm } from "#models/GiftFlow"; +import ContactRole from "#models/ContactRole"; -import config from "@config"; -import { generateContactCode } from "@core/utils/contact"; +import config from "#config"; +import { generateContactCode } from "#core/utils/contact"; const log = mainLogger.child({ app: "gift-service" }); @@ -35,9 +35,8 @@ export default class GiftService { payment_method_types: ["card"], line_items: [ { - name: `Gift membership - ${giftForm.months} month${ - giftForm.months != 1 ? "s" : "" - }`, + name: `Gift membership - ${giftForm.months} month${giftForm.months != 1 ? "s" : "" + }`, amount: giftForm.months * GiftService.giftMonthlyAmount * 100, currency: config.currencyCode.toLowerCase(), quantity: 1 diff --git a/src/core/services/NetworkCommunicatorService.ts b/src/core/services/NetworkCommunicatorService.ts index 2cd85c731..5e9e00564 100644 --- a/src/core/services/NetworkCommunicatorService.ts +++ b/src/core/services/NetworkCommunicatorService.ts @@ -3,12 +3,12 @@ import { Server } from "node:http"; import { EventEmitter } from "node:events"; import { sign, verify, JsonWebTokenError } from "jsonwebtoken"; import express, { Request, Response } from "express"; -import config from "@config"; -import { log as mainLogger } from "@core/logging"; -import { wrapAsync } from "@core/utils"; -import { extractToken } from "@core/utils/auth"; +import config from "#config"; +import { log as mainLogger } from "#core/logging"; +import { wrapAsync } from "#core/utils"; +import { extractToken } from "#core/utils/auth"; -import type { NetworkServiceMap } from "@type/network-service-map"; +import type { NetworkServiceMap } from "#type/network-service-map"; const log = mainLogger.child({ app: "network-communicator-service" }); diff --git a/src/core/services/NewsletterService.ts b/src/core/services/NewsletterService.ts index a2c1acf02..c7a0ef2ab 100644 --- a/src/core/services/NewsletterService.ts +++ b/src/core/services/NewsletterService.ts @@ -1,20 +1,20 @@ import { NewsletterStatus } from "@beabee/beabee-common"; -import { getRepository } from "@core/database"; -import { log as mainLogger } from "@core/logging"; +import { getRepository } from "#core/database"; +import { log as mainLogger } from "#core/logging"; import { NewsletterContact, NewsletterProvider, UpdateNewsletterContact -} from "@core/providers/newsletter"; -import MailchimpProvider from "@core/providers/newsletter/MailchimpProvider"; -import NoneProvider from "@core/providers/newsletter/NoneProvider"; +} from "#core/providers/newsletter"; +import MailchimpProvider from "#core/providers/newsletter/MailchimpProvider"; +import NoneProvider from "#core/providers/newsletter/NoneProvider"; -import Contact from "@models/Contact"; -import ContactProfile from "@models/ContactProfile"; +import Contact from "#models/Contact"; +import ContactProfile from "#models/ContactProfile"; -import config from "@config"; +import config from "#config"; const log = mainLogger.child({ app: "newsletter-service" }); diff --git a/src/core/services/OptionsService.ts b/src/core/services/OptionsService.ts index cbc16418c..c8cd6c666 100644 --- a/src/core/services/OptionsService.ts +++ b/src/core/services/OptionsService.ts @@ -1,9 +1,9 @@ -import { getRepository } from "@core/database"; -import _defaultOptions from "@core/defaults.json"; -import { log as mainLogger } from "@core/logging"; +import { getRepository } from "#core/database"; +import _defaultOptions from "#core/defaults.json"; +import { log as mainLogger } from "#core/logging"; import NetworkCommunicatorService from "./NetworkCommunicatorService"; -import Option from "@models/Option"; +import Option from "#models/Option"; export type OptionKey = keyof typeof _defaultOptions; type OptionValue = string | boolean | number; diff --git a/src/core/services/PageSettingsService.ts b/src/core/services/PageSettingsService.ts index 1f5975bf6..24d140050 100644 --- a/src/core/services/PageSettingsService.ts +++ b/src/core/services/PageSettingsService.ts @@ -1,8 +1,8 @@ -import { getRepository } from "@core/database"; +import { getRepository } from "#core/database"; -import OptionsService from "@core/services/OptionsService"; +import OptionsService from "#core/services/OptionsService"; -import PageSettings from "@models/PageSettings"; +import PageSettings from "#models/PageSettings"; interface PageSettingsCache extends PageSettings { patternRegex: RegExp; @@ -22,11 +22,11 @@ export default class PageSettingsService { } return cache === "default" ? { - shareUrl: "/", - shareTitle: OptionsService.getText("share-title"), - shareDescription: OptionsService.getText("share-description"), - shareImage: OptionsService.getText("share-image") - } + shareUrl: "/", + shareTitle: OptionsService.getText("share-title"), + shareDescription: OptionsService.getText("share-description"), + shareImage: OptionsService.getText("share-image") + } : cache; } diff --git a/src/core/services/PaymentFlowService.ts b/src/core/services/PaymentFlowService.ts index 91fcf554c..9211b771a 100644 --- a/src/core/services/PaymentFlowService.ts +++ b/src/core/services/PaymentFlowService.ts @@ -1,18 +1,18 @@ import { ContributionPeriod, PaymentMethod } from "@beabee/beabee-common"; -import { getRepository } from "@core/database"; -import { log as mainLogger } from "@core/logging"; +import { getRepository } from "#core/database"; +import { log as mainLogger } from "#core/logging"; -import EmailService from "@core/services/EmailService"; -import ContactsService from "@core/services/ContactsService"; -import OptionsService from "@core/services/OptionsService"; -import PaymentService from "@core/services/PaymentService"; +import EmailService from "#core/services/EmailService"; +import ContactsService from "#core/services/ContactsService"; +import OptionsService from "#core/services/OptionsService"; +import PaymentService from "#core/services/PaymentService"; import ResetSecurityFlowService from "./ResetSecurityFlowService"; -import Address from "@models/Address"; -import JoinFlow from "@models/JoinFlow"; -import JoinForm from "@models/JoinForm"; -import Contact from "@models/Contact"; +import Address from "#models/Address"; +import JoinFlow from "#models/JoinFlow"; +import JoinForm from "#models/JoinForm"; +import Contact from "#models/Contact"; import { CompletedPaymentFlow, @@ -21,15 +21,15 @@ import { PaymentFlowData, PaymentFlowParams, PaymentFlowProvider -} from "@core/providers/payment-flow"; -import StripeProvider from "@core/providers/payment-flow/StripeProvider"; -import GCProvider from "@core/providers/payment-flow/GCProvider"; +} from "#core/providers/payment-flow"; +import StripeProvider from "#core/providers/payment-flow/StripeProvider"; +import GCProvider from "#core/providers/payment-flow/GCProvider"; -import DuplicateEmailError from "@api/errors/DuplicateEmailError"; +import DuplicateEmailError from "#api/errors/DuplicateEmailError"; -import { RESET_SECURITY_FLOW_TYPE } from "@enums/reset-security-flow-type"; +import { RESET_SECURITY_FLOW_TYPE } from "#enums/reset-security-flow-type"; -import { CompleteUrls } from "@type/complete-urls"; +import { CompleteUrls } from "#type/complete-urls"; const paymentProviders = { [PaymentMethod.StripeCard]: StripeProvider, diff --git a/src/core/services/PaymentService.ts b/src/core/services/PaymentService.ts index 2894ae1dd..1626b5b65 100644 --- a/src/core/services/PaymentService.ts +++ b/src/core/services/PaymentService.ts @@ -1,24 +1,24 @@ import { MembershipStatus, PaymentMethod } from "@beabee/beabee-common"; -import { createQueryBuilder, getRepository } from "@core/database"; -import { log as mainLogger } from "@core/logging"; -import { PaymentForm } from "@core/utils"; -import { calcRenewalDate } from "@core/utils/payment"; +import { createQueryBuilder, getRepository } from "#core/database"; +import { log as mainLogger } from "#core/logging"; +import { PaymentForm } from "#core/utils"; +import { calcRenewalDate } from "#core/utils/payment"; -import Contact from "@models/Contact"; -import Payment from "@models/Payment"; -import PaymentData from "@models/PaymentData"; +import Contact from "#models/Contact"; +import Payment from "#models/Payment"; +import PaymentData from "#models/PaymentData"; import { PaymentProvider, UpdateContributionResult -} from "@core/providers/payment"; -import GCProvider from "@core/providers/payment/GCProvider"; -import ManualProvider from "@core/providers/payment/ManualProvider"; -import StripeProvider from "@core/providers/payment/StripeProvider"; -import { CompletedPaymentFlow } from "@core/providers/payment-flow"; +} from "#core/providers/payment"; +import GCProvider from "#core/providers/payment/GCProvider"; +import ManualProvider from "#core/providers/payment/ManualProvider"; +import StripeProvider from "#core/providers/payment/StripeProvider"; +import { CompletedPaymentFlow } from "#core/providers/payment-flow"; -import { ContributionInfo } from "@type/contribution-info"; +import { ContributionInfo } from "#type/contribution-info"; const log = mainLogger.child({ app: "payment-service" }); diff --git a/src/core/services/ReferralsService.ts b/src/core/services/ReferralsService.ts index 75c84c096..e51fcc1eb 100644 --- a/src/core/services/ReferralsService.ts +++ b/src/core/services/ReferralsService.ts @@ -1,14 +1,14 @@ import _ from "lodash"; -import { getRepository } from "@core/database"; -import { log as mainLogger } from "@core/logging"; +import { getRepository } from "#core/database"; +import { log as mainLogger } from "#core/logging"; -import EmailService from "@core/services/EmailService"; +import EmailService from "#core/services/EmailService"; -import { ReferralGiftForm } from "@models/JoinForm"; -import Contact from "@models/Contact"; -import ReferralGift from "@models/ReferralGift"; -import Referral from "@models/Referral"; +import { ReferralGiftForm } from "#models/JoinForm"; +import Contact from "#models/Contact"; +import ReferralGift from "#models/ReferralGift"; +import Referral from "#models/Referral"; const log = mainLogger.child({ app: "referrals-service" }); diff --git a/src/core/services/ResetSecurityFlowService.ts b/src/core/services/ResetSecurityFlowService.ts index ce493aee3..67e2dd209 100644 --- a/src/core/services/ResetSecurityFlowService.ts +++ b/src/core/services/ResetSecurityFlowService.ts @@ -1,12 +1,12 @@ import { subHours } from "date-fns"; import { InsertResult, MoreThan } from "typeorm"; -import { createQueryBuilder, getRepository } from "@core/database"; +import { createQueryBuilder, getRepository } from "#core/database"; -import ResetSecurityFlow from "@models/ResetSecurityFlow"; -import Contact from "@models/Contact"; +import ResetSecurityFlow from "#models/ResetSecurityFlow"; +import Contact from "#models/Contact"; -import { RESET_SECURITY_FLOW_TYPE } from "@enums/reset-security-flow-type"; +import { RESET_SECURITY_FLOW_TYPE } from "#enums/reset-security-flow-type"; interface InsertResetSecurityFlowResult extends InsertResult { raw: { id: string; contactId: string }[] | undefined; diff --git a/src/core/services/SegmentService.ts b/src/core/services/SegmentService.ts index cbc800547..a8fd3ba22 100644 --- a/src/core/services/SegmentService.ts +++ b/src/core/services/SegmentService.ts @@ -1,14 +1,14 @@ import { contactFilters, validateRuleGroup } from "@beabee/beabee-common"; -import { getRepository } from "@core/database"; +import { getRepository } from "#core/database"; -import ContactTransformer from "@api/transformers/ContactTransformer"; -import { buildSelectQuery } from "@api/utils/rules"; +import ContactTransformer from "#api/transformers/ContactTransformer"; +import { buildSelectQuery } from "#api/utils/rules"; -import Contact from "@models/Contact"; -import Segment from "@models/Segment"; +import Contact from "#models/Contact"; +import Segment from "#models/Segment"; -import { AuthInfo } from "@type/auth-info"; +import { AuthInfo } from "#type/auth-info"; class SegmentService { async createSegment( diff --git a/src/core/sessions.ts b/src/core/sessions.ts index 53f5b1674..e2ea6649d 100644 --- a/src/core/sessions.ts +++ b/src/core/sessions.ts @@ -4,10 +4,10 @@ import express, { Response } from "express"; import session from "express-session"; import { PostgresDriver } from "typeorm/driver/postgres/PostgresDriver"; -import { dataSource } from "@core/database"; -import passport from "@core/lib/passport"; +import { dataSource } from "#core/database"; +import passport from "#core/lib/passport"; -import config from "@config"; +import config from "#config"; const pgSession = _pgSession(session); diff --git a/src/core/template-locals.ts b/src/core/template-locals.ts index 53f62978f..4996ab382 100644 --- a/src/core/template-locals.ts +++ b/src/core/template-locals.ts @@ -1,6 +1,6 @@ import { NextFunction, Request, Response } from "express"; -import { AppConfig } from "@config"; +import { AppConfig } from "#config"; function hasPermission(perms1: string[], perms2: string[]) { return perms1.filter((p) => perms2.includes(p)).length > 0; diff --git a/src/core/utils/auth.ts b/src/core/utils/auth.ts index e648e2d8b..16f2c588b 100644 --- a/src/core/utils/auth.ts +++ b/src/core/utils/auth.ts @@ -1,15 +1,15 @@ import crypto from "crypto"; import { Request, Response } from "express"; import jwt from "jsonwebtoken"; -import { getNextParam } from "@core/utils"; +import { getNextParam } from "#core/utils"; import { TOTP, Secret } from "otpauth"; -import Contact from "@models/Contact"; -import Password from "@models/Password"; +import Contact from "#models/Contact"; +import Password from "#models/Password"; -import { LOGIN_CODES } from "@enums/login-codes"; +import { LOGIN_CODES } from "#enums/login-codes"; -import config from "@config"; +import config from "#config"; export function generateJWTToken(contact: Contact): string { return jwt.sign({ contactId: contact.id }, config.secret); diff --git a/src/core/utils/contact.ts b/src/core/utils/contact.ts index 1c696755c..bd2f73e6c 100644 --- a/src/core/utils/contact.ts +++ b/src/core/utils/contact.ts @@ -1,6 +1,6 @@ import { Request, Response } from "express"; -import Contact from "@models/Contact"; +import Contact from "#models/Contact"; export function loginAndRedirect( req: Request, diff --git a/src/core/utils/email.ts b/src/core/utils/email.ts index 428094200..4eaa99efe 100644 --- a/src/core/utils/email.ts +++ b/src/core/utils/email.ts @@ -1,8 +1,8 @@ import juice from "juice"; -import OptionsService from "@core/services/OptionsService"; +import OptionsService from "#core/services/OptionsService"; -import currentLocale from "@locale"; +import currentLocale from "#locale"; export function getEmailFooter(): string { const locale = currentLocale(); @@ -16,22 +16,21 @@ export function getEmailFooter(): string { "organisation" )}


-

${ - locale.footer.contactUs - } ${OptionsService.getText("support-email")}.

+

${locale.footer.contactUs + } ${OptionsService.getText("support-email")}.

${[ - [ - locale.footer.privacyPolicy, - OptionsService.getText("footer-privacy-link-url") - ], - [locale.footer.terms, OptionsService.getText("footer-terms-link-url")], - ["Impressum", OptionsService.getText("footer-impressum-link-url")] - ] - .filter(([text, url]) => !!url) - .map(([text, url]) => `${text}`) - .join(", ")}

+ [ + locale.footer.privacyPolicy, + OptionsService.getText("footer-privacy-link-url") + ], + [locale.footer.terms, OptionsService.getText("footer-terms-link-url")], + ["Impressum", OptionsService.getText("footer-impressum-link-url")] + ] + .filter(([text, url]) => !!url) + .map(([text, url]) => `${text}`) + .join(", ")}

`; } diff --git a/src/core/utils/index.ts b/src/core/utils/index.ts index df692106e..53fe25b68 100644 --- a/src/core/utils/index.ts +++ b/src/core/utils/index.ts @@ -1,5 +1,5 @@ import { ContributionPeriod } from "@beabee/beabee-common"; -import { AuthInfo } from "@type/auth-info"; +import { AuthInfo } from "#type/auth-info"; import { NextFunction, Request, RequestHandler, Response } from "express"; import { QueryFailedError } from "typeorm"; diff --git a/src/core/utils/payment.test.ts b/src/core/utils/payment.test.ts index a2d4e33d1..8d36df83f 100644 --- a/src/core/utils/payment.test.ts +++ b/src/core/utils/payment.test.ts @@ -4,11 +4,11 @@ import { ContributionPeriod, ContributionType } from "@beabee/beabee-common"; import { add, sub } from "date-fns"; import { calcRenewalDate } from "./payment"; -import Contact from "@models/Contact"; -import ContactRole from "@models/ContactRole"; -import Password from "@models/Password"; +import Contact from "#models/Contact"; +import ContactRole from "#models/ContactRole"; +import Password from "#models/Password"; -import config from "@config"; +import config from "#config"; function createContact(contact?: Partial): Contact { return Object.assign(new Contact(), { diff --git a/src/core/utils/payment.ts b/src/core/utils/payment.ts index a7b4654c4..21e0fee62 100644 --- a/src/core/utils/payment.ts +++ b/src/core/utils/payment.ts @@ -4,8 +4,8 @@ import { PaymentMethod, calcPaymentFee } from "@beabee/beabee-common"; -import config from "@config"; -import Contact from "@models/Contact"; +import config from "#config"; +import Contact from "#models/Contact"; import { addMonths, getYear, setYear, sub, differenceInMonths } from "date-fns"; import { getActualAmount, PaymentForm } from "."; @@ -84,9 +84,9 @@ export function getChargeableAmount( const amount = getActualAmount(paymentForm.monthlyAmount, paymentForm.period); const fee = paymentForm.payFee ? calcPaymentFee( - { amount, period: paymentForm.period, paymentMethod }, - config.stripe.country - ) + { amount, period: paymentForm.period, paymentMethod }, + config.stripe.country + ) : 0; return Math.round((amount + fee) * 100); } diff --git a/src/core/utils/payment/gocardless.ts b/src/core/utils/payment/gocardless.ts index ec72ede53..ca8783157 100644 --- a/src/core/utils/payment/gocardless.ts +++ b/src/core/utils/payment/gocardless.ts @@ -12,12 +12,12 @@ import { } from "gocardless-nodejs/types/Types"; import moment from "moment"; -import { log as mainLogger } from "@core/logging"; -import gocardless from "@core/lib/gocardless"; -import { PaymentForm } from "@core/utils"; -import { getChargeableAmount } from "@core/utils/payment"; +import { log as mainLogger } from "#core/logging"; +import gocardless from "#core/lib/gocardless"; +import { PaymentForm } from "#core/utils"; +import { getChargeableAmount } from "#core/utils/payment"; -import config from "@config"; +import config from "#config"; const log = mainLogger.child({ app: "gc-utils" }); diff --git a/src/core/utils/payment/stripe.ts b/src/core/utils/payment/stripe.ts index 47d7aae71..44c7e0387 100644 --- a/src/core/utils/payment/stripe.ts +++ b/src/core/utils/payment/stripe.ts @@ -6,14 +6,14 @@ import { import { differenceInMonths } from "date-fns"; import Stripe from "stripe"; -import stripe from "@core/lib/stripe"; -import { log as mainLogger } from "@core/logging"; -import { PaymentForm } from "@core/utils"; -import { getChargeableAmount } from "@core/utils/payment"; +import stripe from "#core/lib/stripe"; +import { log as mainLogger } from "#core/logging"; +import { PaymentForm } from "#core/utils"; +import { getChargeableAmount } from "#core/utils/payment"; -import config from "@config"; +import config from "#config"; -import { PaymentSource } from "@type/payment-source"; +import { PaymentSource } from "#type/payment-source"; const log = mainLogger.child({ app: "stripe-utils" }); @@ -45,8 +45,8 @@ async function calculateProrationParams( // as this aligns with Stripe's calculations const prorationTime = Math.floor( subscription.current_period_end - - (subscription.current_period_end - subscription.current_period_start) * - (monthsLeft / 12) + (subscription.current_period_end - subscription.current_period_start) * + (monthsLeft / 12) ); const invoice = await stripe.invoices.retrieveUpcoming({ @@ -85,9 +85,9 @@ export async function createSubscription( off_session: true, ...(renewalDate && renewalDate > new Date() && { - billing_cycle_anchor: Math.floor(+renewalDate / 1000), - proration_behavior: "none" - }) + billing_cycle_anchor: Math.floor(+renewalDate / 1000), + proration_behavior: "none" + }) }); } @@ -136,16 +136,16 @@ export async function updateSubscription( items: [newSubscriptionItem], ...(prorationAmount > 0 ? { - proration_behavior: "always_invoice", - proration_date: prorationTime - } + proration_behavior: "always_invoice", + proration_date: prorationTime + } : { - proration_behavior: "none", - // Force it to change at the start of the next period, this is - // important when changing from monthly to annual as otherwise - // Stripe starts the new billing cycle immediately - trial_end: subscription.current_period_end - }) + proration_behavior: "none", + // Force it to change at the start of the next period, this is + // important when changing from monthly to annual as otherwise + // Stripe starts the new billing cycle immediately + trial_end: subscription.current_period_end + }) }); } else { // Schedule the change for the next period diff --git a/src/locales/current.ts b/src/locales/current.ts index 3d271c158..bb48b96f7 100644 --- a/src/locales/current.ts +++ b/src/locales/current.ts @@ -1,4 +1,4 @@ -import OptionsService from "@core/services/OptionsService"; +import OptionsService from "#core/services/OptionsService"; import localeDe from "./de.json"; import localeDeInformal from "./de@informal.json"; diff --git a/src/migrations/1621513644609-AddEmailAndPasswordToJoinFlow.ts b/src/migrations/1621513644609-AddEmailAndPasswordToJoinFlow.ts index 2fd18032f..0813d695b 100644 --- a/src/migrations/1621513644609-AddEmailAndPasswordToJoinFlow.ts +++ b/src/migrations/1621513644609-AddEmailAndPasswordToJoinFlow.ts @@ -1,10 +1,9 @@ import { MigrationInterface, QueryRunner } from "typeorm"; -import { addThenSetNotNull } from "@core/utils/db"; +import { addThenSetNotNull } from "#core/utils/db"; export class AddEmailAndPasswordToJoinFlow1621513644609 - implements MigrationInterface -{ + implements MigrationInterface { name = "AddEmailAndPasswordToJoinFlow1621513644609"; public async up(queryRunner: QueryRunner): Promise { diff --git a/src/migrations/1632397910432-AddButtonText.ts b/src/migrations/1632397910432-AddButtonText.ts index 0bf79b299..fd6210b73 100644 --- a/src/migrations/1632397910432-AddButtonText.ts +++ b/src/migrations/1632397910432-AddButtonText.ts @@ -1,5 +1,5 @@ import { MigrationInterface, QueryRunner } from "typeorm"; -import { addThenSetNotNull } from "@core/utils/db"; +import { addThenSetNotNull } from "#core/utils/db"; export class AddButtonText1632397910432 implements MigrationInterface { name = "AddButtonText1632397910432"; diff --git a/src/migrations/1634125137636-AddExcerptAndImageToPoll.ts b/src/migrations/1634125137636-AddExcerptAndImageToPoll.ts index 93fb58fce..39d863497 100644 --- a/src/migrations/1634125137636-AddExcerptAndImageToPoll.ts +++ b/src/migrations/1634125137636-AddExcerptAndImageToPoll.ts @@ -1,9 +1,8 @@ -import { addThenSetNotNull } from "@core/utils/db"; +import { addThenSetNotNull } from "#core/utils/db"; import { MigrationInterface, QueryRunner } from "typeorm"; export class AddExcerptAndImageToPoll1634125137636 - implements MigrationInterface -{ + implements MigrationInterface { name = "AddExcerptAndImageToPoll1634125137636"; public async up(queryRunner: QueryRunner): Promise { diff --git a/src/migrations/1650900384747-AddPaymentMethodToJoinForm.ts b/src/migrations/1650900384747-AddPaymentMethodToJoinForm.ts index 41100eb44..9a1412ee5 100644 --- a/src/migrations/1650900384747-AddPaymentMethodToJoinForm.ts +++ b/src/migrations/1650900384747-AddPaymentMethodToJoinForm.ts @@ -1,9 +1,8 @@ -import { addThenSetNotNull } from "@core/utils/db"; +import { addThenSetNotNull } from "#core/utils/db"; import { MigrationInterface, QueryRunner } from "typeorm"; export class AddPaymentMethodToJoinForm1650900384747 - implements MigrationInterface -{ + implements MigrationInterface { name = "AddPaymentMethodToJoinForm1650900384747"; public async up(queryRunner: QueryRunner): Promise { diff --git a/src/migrations/1652115873327-AddUrlsToJoinFlow.ts b/src/migrations/1652115873327-AddUrlsToJoinFlow.ts index d034c3470..446456fc7 100644 --- a/src/migrations/1652115873327-AddUrlsToJoinFlow.ts +++ b/src/migrations/1652115873327-AddUrlsToJoinFlow.ts @@ -1,4 +1,4 @@ -import { addThenSetNotNull } from "@core/utils/db"; +import { addThenSetNotNull } from "#core/utils/db"; import { MigrationInterface, QueryRunner } from "typeorm"; export class AddUrlsToJoinFlow1652115873327 implements MigrationInterface { diff --git a/src/migrations/1696600862719-UpdateGCNextAmount.ts b/src/migrations/1696600862719-UpdateGCNextAmount.ts index a7bb35ce2..bc712b532 100644 --- a/src/migrations/1696600862719-UpdateGCNextAmount.ts +++ b/src/migrations/1696600862719-UpdateGCNextAmount.ts @@ -1,7 +1,7 @@ import { ContributionPeriod, PaymentMethod } from "@beabee/beabee-common"; import { MigrationInterface, QueryRunner } from "typeorm"; -import { getChargeableAmount } from "@core/utils/payment"; +import { getChargeableAmount } from "#core/utils/payment"; interface PaymentQueryResults { id: string; diff --git a/src/models/Callout.ts b/src/models/Callout.ts index eb247e2d5..a499495db 100644 --- a/src/models/Callout.ts +++ b/src/models/Callout.ts @@ -6,15 +6,15 @@ import { PrimaryGeneratedColumn } from "typeorm"; -import { CalloutAccess } from "@enums/callout-access"; -import { CalloutCaptcha } from "@enums/callout-captcha"; +import { CalloutAccess } from "#enums/callout-access"; +import { CalloutCaptcha } from "#enums/callout-captcha"; import ItemWithStatus from "./ItemWithStatus"; import type CalloutResponse from "./CalloutResponse"; import type CalloutTag from "./CalloutTag"; import type CalloutVariant from "./CalloutVariant"; -import { CalloutResponseViewSchema } from "@type/callout-response-view-schema"; +import { CalloutResponseViewSchema } from "#type/callout-response-view-schema"; import { SetCalloutFormSchema } from "@beabee/beabee-common"; @Entity() diff --git a/src/models/CalloutVariant.ts b/src/models/CalloutVariant.ts index 8cc164a13..03a8cbf26 100644 --- a/src/models/CalloutVariant.ts +++ b/src/models/CalloutVariant.ts @@ -1,6 +1,6 @@ import { Column, Entity, ManyToOne, PrimaryColumn } from "typeorm"; import type Callout from "./Callout"; -import { CalloutVariantNavigationData } from "@type/callout-variant-data"; +import { CalloutVariantNavigationData } from "#type/callout-variant-data"; @Entity() export default class CalloutVariant { diff --git a/src/models/Contact.ts b/src/models/Contact.ts index 657d2c451..bae1a1471 100644 --- a/src/models/Contact.ts +++ b/src/models/Contact.ts @@ -12,15 +12,15 @@ import { PrimaryGeneratedColumn } from "typeorm"; -import { getActualAmount } from "@core/utils"; -import config from "@config"; +import { getActualAmount } from "#core/utils"; +import config from "#config"; import type ContactRole from "./ContactRole"; import type ContactProfile from "./ContactProfile"; import Password from "./Password"; import type PaymentData from "./PaymentData"; -import { ContributionInfo } from "@type/contribution-info"; +import { ContributionInfo } from "#type/contribution-info"; interface LoginOverride { code: string; @@ -104,9 +104,9 @@ export default class Contact { return this.contributionMonthlyAmount === null ? null : getActualAmount( - this.contributionMonthlyAmount, - this.contributionPeriod! - ); + this.contributionMonthlyAmount, + this.contributionPeriod! + ); } get contributionDescription(): string { @@ -119,9 +119,8 @@ export default class Contact { ) { return "None"; } else { - return `${config.currencySymbol}${this.contributionAmount}/${ - this.contributionPeriod === "monthly" ? "month" : "year" - }`; + return `${config.currencySymbol}${this.contributionAmount}/${this.contributionPeriod === "monthly" ? "month" : "year" + }`; } } diff --git a/src/models/ContactMfa.ts b/src/models/ContactMfa.ts index 81e77d1fa..aab17ea5f 100644 --- a/src/models/ContactMfa.ts +++ b/src/models/ContactMfa.ts @@ -6,7 +6,7 @@ import { PrimaryGeneratedColumn } from "typeorm"; -import { CONTACT_MFA_TYPE } from "@enums/contact-mfa-type"; +import { CONTACT_MFA_TYPE } from "#enums/contact-mfa-type"; import type Contact from "./Contact"; diff --git a/src/models/Content.ts b/src/models/Content.ts index 0707da790..95f481bcb 100644 --- a/src/models/Content.ts +++ b/src/models/Content.ts @@ -1,5 +1,5 @@ import { Column, Entity, PrimaryColumn, UpdateDateColumn } from "typeorm"; -import { ContentId } from "@type/content-id"; +import { ContentId } from "#type/content-id"; @Entity() export default class Content { diff --git a/src/models/EmailMailing.ts b/src/models/EmailMailing.ts index 3dd065d68..fd1dddbb0 100644 --- a/src/models/EmailMailing.ts +++ b/src/models/EmailMailing.ts @@ -5,7 +5,7 @@ import { ManyToOne, PrimaryGeneratedColumn } from "typeorm"; -import type Email from "@models/Email"; +import type Email from "#models/Email"; export type EmailMailingRecipient = Record; diff --git a/src/models/Export.ts b/src/models/Export.ts index 73b8a20ec..25bf5c80b 100644 --- a/src/models/Export.ts +++ b/src/models/Export.ts @@ -1,4 +1,4 @@ -import { ParamValue } from "@core/utils/params"; +import { ParamValue } from "#core/utils/params"; import { Column, CreateDateColumn, diff --git a/src/models/JoinForm.ts b/src/models/JoinForm.ts index 6e3d05e44..f862e08ea 100644 --- a/src/models/JoinForm.ts +++ b/src/models/JoinForm.ts @@ -1,6 +1,6 @@ import { ContributionPeriod, PaymentMethod } from "@beabee/beabee-common"; import { Column } from "typeorm"; -import { PaymentForm } from "@core/utils"; +import { PaymentForm } from "#core/utils"; import Password from "./Password"; export interface ReferralGiftForm { diff --git a/src/models/ResetSecurityFlow.ts b/src/models/ResetSecurityFlow.ts index cf9e0a5fa..61993a003 100644 --- a/src/models/ResetSecurityFlow.ts +++ b/src/models/ResetSecurityFlow.ts @@ -6,7 +6,7 @@ import { Column } from "typeorm"; import Contact from "./Contact"; -import { RESET_SECURITY_FLOW_TYPE } from "@enums/reset-security-flow-type"; +import { RESET_SECURITY_FLOW_TYPE } from "#enums/reset-security-flow-type"; @Entity() export default class ResetSecurityFlow { diff --git a/src/tools/configure.ts b/src/tools/configure.ts index 219f58ff7..23f82f9d2 100644 --- a/src/tools/configure.ts +++ b/src/tools/configure.ts @@ -1,13 +1,13 @@ -import "module-alias/register"; +// import "module-alias/register"; import { checkbox, input } from "@inquirer/prompts"; -import { getRepository } from "@core/database"; -import { runApp } from "@core/server"; +import { getRepository } from "#core/database"; +import { runApp } from "#core/server"; -import OptionsService from "@core/services/OptionsService"; +import OptionsService from "#core/services/OptionsService"; -import Content from "@models/Content"; +import Content from "#models/Content"; function notEmpty(s: string) { return s.trim() !== ""; diff --git a/src/tools/database/anonymisers/index.ts b/src/tools/database/anonymisers/index.ts index a3a436df6..a64951daf 100644 --- a/src/tools/database/anonymisers/index.ts +++ b/src/tools/database/anonymisers/index.ts @@ -6,11 +6,11 @@ import { } from "typeorm"; import { QueryDeepPartialEntity } from "typeorm/query-builder/QueryPartialEntity"; -import { createQueryBuilder, getRepository } from "@core/database"; -import { log as mainLogger } from "@core/logging"; +import { createQueryBuilder, getRepository } from "#core/database"; +import { log as mainLogger } from "#core/logging"; -import Callout from "@models/Callout"; -import CalloutResponse from "@models/CalloutResponse"; +import Callout from "#models/Callout"; +import CalloutResponse from "#models/CalloutResponse"; import { CalloutComponentSchema, CalloutResponseAnswers diff --git a/src/tools/database/anonymisers/models.ts b/src/tools/database/anonymisers/models.ts index 41eba1465..395cb7fbd 100644 --- a/src/tools/database/anonymisers/models.ts +++ b/src/tools/database/anonymisers/models.ts @@ -7,34 +7,34 @@ import crypto from "crypto"; import { EntityTarget, ObjectLiteral } from "typeorm"; import { v4 as uuidv4 } from "uuid"; -import Email from "@models/Email"; -import EmailMailing from "@models/EmailMailing"; -import Export from "@models/Export"; -import ExportItem from "@models/ExportItem"; -import GiftFlow from "@models/GiftFlow"; -import Contact from "@models/Contact"; -import ContactRole from "@models/ContactRole"; -import ContactProfile from "@models/ContactProfile"; -import Notice from "@models/Notice"; -import Option from "@models/Option"; -import PageSettings from "@models/PageSettings"; -import Payment from "@models/Payment"; -import PaymentData from "@models/PaymentData"; -import Callout from "@models/Callout"; -import CalloutResponse from "@models/CalloutResponse"; -import CalloutResponseTag from "@models/CalloutResponseTag"; -import CalloutTag from "@models/CalloutTag"; -import Project from "@models/Project"; -import ProjectContact from "@models/ProjectContact"; -import ProjectEngagement from "@models/ProjectEngagement"; -import Referral from "@models/Referral"; -import ReferralGift from "@models/ReferralGift"; -import Segment from "@models/Segment"; -import SegmentContact from "@models/SegmentContact"; -import SegmentOngoingEmail from "@models/SegmentOngoingEmail"; -import CalloutResponseComment from "@models/CalloutResponseComment"; -import ResetSecurityFlow from "@models/ResetSecurityFlow"; -import Password from "@models/Password"; +import Email from "#models/Email"; +import EmailMailing from "#models/EmailMailing"; +import Export from "#models/Export"; +import ExportItem from "#models/ExportItem"; +import GiftFlow from "#models/GiftFlow"; +import Contact from "#models/Contact"; +import ContactRole from "#models/ContactRole"; +import ContactProfile from "#models/ContactProfile"; +import Notice from "#models/Notice"; +import Option from "#models/Option"; +import PageSettings from "#models/PageSettings"; +import Payment from "#models/Payment"; +import PaymentData from "#models/PaymentData"; +import Callout from "#models/Callout"; +import CalloutResponse from "#models/CalloutResponse"; +import CalloutResponseTag from "#models/CalloutResponseTag"; +import CalloutTag from "#models/CalloutTag"; +import Project from "#models/Project"; +import ProjectContact from "#models/ProjectContact"; +import ProjectEngagement from "#models/ProjectEngagement"; +import Referral from "#models/Referral"; +import ReferralGift from "#models/ReferralGift"; +import Segment from "#models/Segment"; +import SegmentContact from "#models/SegmentContact"; +import SegmentOngoingEmail from "#models/SegmentOngoingEmail"; +import CalloutResponseComment from "#models/CalloutResponseComment"; +import ResetSecurityFlow from "#models/ResetSecurityFlow"; +import Password from "#models/Password"; export type PropertyMap = ((prop: T) => T) | ObjectMap; export type ObjectMap = { [K in keyof T]?: PropertyMap }; diff --git a/src/tools/database/export-demo.ts b/src/tools/database/export-demo.ts index c41bfa6e1..40037b8d9 100644 --- a/src/tools/database/export-demo.ts +++ b/src/tools/database/export-demo.ts @@ -1,11 +1,11 @@ -import "module-alias/register"; +// import "module-alias/register"; import { Brackets } from "typeorm"; -import { createQueryBuilder } from "@core/database"; -import { runApp } from "@core/server"; +import { createQueryBuilder } from "#core/database"; +import { runApp } from "#core/server"; -import Contact from "@models/Contact"; +import Contact from "#models/Contact"; import { ModelAnonymiser, @@ -26,8 +26,8 @@ import { resetSecurityFlowAnonymiser } from "./anonymisers/models"; import { anonymiseModel, clearModels } from "./anonymisers"; -import Callout from "@models/Callout"; -import CalloutResponse from "@models/CalloutResponse"; +import Callout from "#models/Callout"; +import CalloutResponse from "#models/CalloutResponse"; const contactAnonymisers = [ contactAnonymiser, diff --git a/src/tools/database/export.ts b/src/tools/database/export.ts index cf961a085..200b75ba6 100644 --- a/src/tools/database/export.ts +++ b/src/tools/database/export.ts @@ -1,6 +1,6 @@ -import "module-alias/register"; +// import "module-alias/register"; -import { runApp } from "@core/server"; +import { runApp } from "#core/server"; import * as models from "./anonymisers/models"; import { anonymiseModel, clearModels } from "./anonymisers"; diff --git a/src/tools/database/import-steady.ts b/src/tools/database/import-steady.ts index 563d8f1ec..ef1d1adb5 100644 --- a/src/tools/database/import-steady.ts +++ b/src/tools/database/import-steady.ts @@ -1,4 +1,4 @@ -import "module-alias/register"; +// import "module-alias/register"; import { ContributionPeriod, @@ -8,15 +8,15 @@ import { import { parse } from "csv-parse"; import { In } from "typeorm"; -import { getRepository } from "@core/database"; -import { runApp } from "@core/server"; -import { cleanEmailAddress } from "@core/utils"; +import { getRepository } from "#core/database"; +import { runApp } from "#core/server"; +import { cleanEmailAddress } from "#core/utils"; -import ContactsService from "@core/services/ContactsService"; +import ContactsService from "#core/services/ContactsService"; -import Address from "@models/Address"; -import Contact from "@models/Contact"; -import ContactRole from "@models/ContactRole"; +import Address from "#models/Address"; +import Contact from "#models/Contact"; +import ContactRole from "#models/ContactRole"; const headers = [ "first_name", diff --git a/src/tools/database/import.ts b/src/tools/database/import.ts index e3a161752..e62f81317 100644 --- a/src/tools/database/import.ts +++ b/src/tools/database/import.ts @@ -1,11 +1,11 @@ -import "module-alias/register"; +// import "module-alias/register"; import readline from "readline"; -import { dataSource } from "@core/database"; -import { runApp } from "@core/server"; +import { dataSource } from "#core/database"; +import { runApp } from "#core/server"; -import config from "@config"; +import config from "#config"; if (!config.dev) { console.error("Can't import to live database"); diff --git a/src/tools/gocardless/fetch-customer.js b/src/tools/gocardless/fetch-customer.js index c700d1605..20cfe466d 100644 --- a/src/tools/gocardless/fetch-customer.js +++ b/src/tools/gocardless/fetch-customer.js @@ -2,7 +2,7 @@ require("module-alias/register"); const crypto = require("crypto"); const moment = require("moment"); -const { default: gocardless } = require("@core/lib/gocardless"); +const { default: gocardless } = require("#core/lib/gocardless"); async function fetchCustomers(customerIds) { let customers = [], diff --git a/src/tools/gocardless/fetch-data.js b/src/tools/gocardless/fetch-data.js index 81b57b4d9..7df094d40 100644 --- a/src/tools/gocardless/fetch-data.js +++ b/src/tools/gocardless/fetch-data.js @@ -1,6 +1,6 @@ require("module-alias/register"); -const { default: gocardless } = require("@core/lib/gocardless"); +const { default: gocardless } = require("#core/lib/gocardless"); async function loadData() { console.error("# Loading data from GoCardless..."); diff --git a/src/tools/gocardless/migrate-to-stripe.ts b/src/tools/gocardless/migrate-to-stripe.ts index 33b5cf6cc..354fd4a45 100644 --- a/src/tools/gocardless/migrate-to-stripe.ts +++ b/src/tools/gocardless/migrate-to-stripe.ts @@ -1,4 +1,4 @@ -import "module-alias/register"; +// import "module-alias/register"; import { PaymentMethod, PaymentStatus } from "@beabee/beabee-common"; import { parse } from "csv-parse"; @@ -6,18 +6,18 @@ import { add, startOfDay } from "date-fns"; import Stripe from "stripe"; import { Equal, In } from "typeorm"; -import { createQueryBuilder, getRepository } from "@core/database"; -import { runApp } from "@core/server"; -import stripe from "@core/lib/stripe"; -import { stripeTypeToPaymentMethod } from "@core/utils/payment/stripe"; +import { createQueryBuilder, getRepository } from "#core/database"; +import { runApp } from "#core/server"; +import stripe from "#core/lib/stripe"; +import { stripeTypeToPaymentMethod } from "#core/utils/payment/stripe"; -import PaymentService from "@core/services/PaymentService"; +import PaymentService from "#core/services/PaymentService"; -import Contact from "@models/Contact"; -import Payment from "@models/Payment"; -import PaymentData, { GCPaymentData } from "@models/PaymentData"; +import Contact from "#models/Contact"; +import Payment from "#models/Payment"; +import PaymentData, { GCPaymentData } from "#models/PaymentData"; -import config from "@config"; +import config from "#config"; interface MigrationRow { old_customer_id: string; diff --git a/src/tools/mailchimp/sync.ts b/src/tools/mailchimp/sync.ts index c14bd9960..81d25e013 100644 --- a/src/tools/mailchimp/sync.ts +++ b/src/tools/mailchimp/sync.ts @@ -1,19 +1,19 @@ -import "module-alias/register"; +// import "module-alias/register"; import { NewsletterStatus } from "@beabee/beabee-common"; import moment from "moment"; import { Between } from "typeorm"; -import { getRepository } from "@core/database"; -import { log as mainLogger } from "@core/logging"; -import { runApp } from "@core/server"; +import { getRepository } from "#core/database"; +import { log as mainLogger } from "#core/logging"; +import { runApp } from "#core/server"; -import ContactsService from "@core/services/ContactsService"; -import NewsletterService from "@core/services/NewsletterService"; -import OptionsService from "@core/services/OptionsService"; +import ContactsService from "#core/services/ContactsService"; +import NewsletterService from "#core/services/NewsletterService"; +import OptionsService from "#core/services/OptionsService"; -import Contact from "@models/Contact"; -import ContactRole from "@models/ContactRole"; +import Contact from "#models/Contact"; +import ContactRole from "#models/ContactRole"; const log = mainLogger.child({ app: "mailchimp-sync" }); diff --git a/src/tools/new-user.ts b/src/tools/new-user.ts index 59662a4ed..7c922f1ae 100644 --- a/src/tools/new-user.ts +++ b/src/tools/new-user.ts @@ -1,21 +1,21 @@ -import "module-alias/register"; +// import "module-alias/register"; import { ContributionType } from "@beabee/beabee-common"; import { input, password, select } from "@inquirer/prompts"; import moment from "moment"; -import { getRepository } from "@core/database"; -import { runApp } from "@core/server"; -import { generatePassword, passwordRequirements } from "@core/utils/auth"; +import { getRepository } from "#core/database"; +import { runApp } from "#core/server"; +import { generatePassword, passwordRequirements } from "#core/utils/auth"; -import ContactsService from "@core/services/ContactsService"; -import ResetSecurityFlowService from "@core/services/ResetSecurityFlowService"; +import ContactsService from "#core/services/ContactsService"; +import ResetSecurityFlowService from "#core/services/ResetSecurityFlowService"; -import ContactRole from "@models/ContactRole"; +import ContactRole from "#models/ContactRole"; -import config from "@config"; +import config from "#config"; -import { RESET_SECURITY_FLOW_TYPE } from "@enums/reset-security-flow-type"; +import { RESET_SECURITY_FLOW_TYPE } from "#enums/reset-security-flow-type"; function notEmpty(s: string) { return s.trim() !== ""; diff --git a/src/tools/process-segments.ts b/src/tools/process-segments.ts index d36b7810f..f0e6ad9d8 100644 --- a/src/tools/process-segments.ts +++ b/src/tools/process-segments.ts @@ -1,19 +1,19 @@ -import "module-alias/register"; +// import "module-alias/register"; import { In } from "typeorm"; -import { getRepository } from "@core/database"; -import { log as mainLogger } from "@core/logging"; -import { runApp } from "@core/server"; +import { getRepository } from "#core/database"; +import { log as mainLogger } from "#core/logging"; +import { runApp } from "#core/server"; -import EmailService from "@core/services/EmailService"; -import NewsletterService from "@core/services/NewsletterService"; -import ContactsService from "@core/services/ContactsService"; -import SegmentService from "@core/services/SegmentService"; +import EmailService from "#core/services/EmailService"; +import NewsletterService from "#core/services/NewsletterService"; +import ContactsService from "#core/services/ContactsService"; +import SegmentService from "#core/services/SegmentService"; -import Segment from "@models/Segment"; -import SegmentOngoingEmail from "@models/SegmentOngoingEmail"; -import SegmentContact from "@models/SegmentContact"; +import Segment from "#models/Segment"; +import SegmentOngoingEmail from "#models/SegmentOngoingEmail"; +import SegmentContact from "#models/SegmentContact"; const log = mainLogger.child({ app: "process-segments" }); @@ -53,7 +53,7 @@ async function processSegment(segment: Segment) { // Only fetch old contacts if we need to const oldContacts = segment.newsletterTag || - outgoingEmails.some((oe) => oe.trigger === "onLeave") + outgoingEmails.some((oe) => oe.trigger === "onLeave") ? await ContactsService.findByIds(oldSegmentContactIds) : []; diff --git a/src/tools/start-gifts.ts b/src/tools/start-gifts.ts index 69fbd95da..eed88f58f 100644 --- a/src/tools/start-gifts.ts +++ b/src/tools/start-gifts.ts @@ -1,15 +1,15 @@ -import "module-alias/register"; +// import "module-alias/register"; import moment from "moment"; import { Between } from "typeorm"; -import { getRepository } from "@core/database"; -import { log as mainLogger } from "@core/logging"; -import { runApp } from "@core/server"; +import { getRepository } from "#core/database"; +import { log as mainLogger } from "#core/logging"; +import { runApp } from "#core/server"; -import GiftService from "@core/services/GiftService"; +import GiftService from "#core/services/GiftService"; -import GiftFlow from "@models/GiftFlow"; +import GiftFlow from "#models/GiftFlow"; const log = mainLogger.child({ app: "start-gifts" }); diff --git a/src/tools/stripe/resync.ts b/src/tools/stripe/resync.ts index 66e93bb4b..e085cfc37 100644 --- a/src/tools/stripe/resync.ts +++ b/src/tools/stripe/resync.ts @@ -1,14 +1,14 @@ -import "module-alias/register"; +// import "module-alias/register"; import { PaymentMethod } from "@beabee/beabee-common"; import { In } from "typeorm"; -import { getRepository } from "@core/database"; -import { runApp } from "@core/server"; -import stripe from "@core/lib/stripe"; -import ContactsService from "@core/services/ContactsService"; +import { getRepository } from "#core/database"; +import { runApp } from "#core/server"; +import stripe from "#core/lib/stripe"; +import ContactsService from "#core/services/ContactsService"; -import PaymentData, { StripePaymentData } from "@models/PaymentData"; +import PaymentData, { StripePaymentData } from "#models/PaymentData"; import { handleInvoicePaid, diff --git a/src/tools/test-users.ts b/src/tools/test-users.ts index b172ef82c..c5fd93e0a 100644 --- a/src/tools/test-users.ts +++ b/src/tools/test-users.ts @@ -1,4 +1,4 @@ -import "module-alias/register"; +// import "module-alias/register"; import { ContributionPeriod, @@ -8,15 +8,15 @@ import { import moment from "moment"; import { Brackets } from "typeorm"; -import { createQueryBuilder } from "@core/database"; -import { runApp } from "@core/server"; -import { getActualAmount } from "@core/utils"; +import { createQueryBuilder } from "#core/database"; +import { runApp } from "#core/server"; +import { getActualAmount } from "#core/utils"; -import config from "@config"; +import config from "#config"; -import Payment from "@models/Payment"; -import Contact from "@models/Contact"; -import PaymentData from "@models/PaymentData"; +import Payment from "#models/Payment"; +import Contact from "#models/Contact"; +import PaymentData from "#models/PaymentData"; async function logContact(type: string, conditions: Brackets[]) { const qb = createQueryBuilder(Contact, "m") diff --git a/src/type/auth-info.ts b/src/type/auth-info.ts index 4b1f06fc4..031af48cc 100644 --- a/src/type/auth-info.ts +++ b/src/type/auth-info.ts @@ -1,6 +1,6 @@ import { RoleType } from "@beabee/beabee-common"; -import type ApiKey from "@models/ApiKey"; -import Contact from "@models/Contact"; +import type ApiKey from "#models/ApiKey"; +import Contact from "#models/Contact"; export interface AuthInfo { method: "user" | "api-key"; diff --git a/src/type/callout-data.ts b/src/type/callout-data.ts index f0cfecd78..26116e421 100644 --- a/src/type/callout-data.ts +++ b/src/type/callout-data.ts @@ -1,5 +1,5 @@ -import { CalloutAccess } from "@enums/callout-access"; -import { CalloutCaptcha } from "@enums/callout-captcha"; +import { CalloutAccess } from "#enums/callout-access"; +import { CalloutCaptcha } from "#enums/callout-captcha"; import { CalloutResponseViewSchema } from "./callout-response-view-schema"; import { CalloutVariantData } from "./callout-variant-data"; diff --git a/src/type/contact-mfa-secure.ts b/src/type/contact-mfa-secure.ts index 1f87a4836..0f51e905c 100644 --- a/src/type/contact-mfa-secure.ts +++ b/src/type/contact-mfa-secure.ts @@ -1,4 +1,4 @@ -import type ContactMfa from "@models/ContactMfa"; +import type ContactMfa from "#models/ContactMfa"; /** * The **secure** contact multi factor authentication information without the `secret` key diff --git a/src/type/content-data.ts b/src/type/content-data.ts index 48a2d3ea2..2d80bfcd0 100644 --- a/src/type/content-data.ts +++ b/src/type/content-data.ts @@ -4,7 +4,7 @@ import { StripeFeeCountry } from "@beabee/beabee-common"; -import { Locale } from "@locale"; +import { Locale } from "#locale"; import { ContentId } from "./content-id"; interface FooterLink { @@ -87,17 +87,17 @@ export interface ShareContentData { export type ContentData = Id extends "contacts" - ? ContactsContentData - : never | Id extends "email" - ? EmailContentData - : never | Id extends "general" - ? GeneralContentData - : never | Id extends "join" - ? JoinContentData - : never | Id extends "join/setup" - ? JoinSetupContentData - : never | Id extends "profile" - ? ProfileContentData - : never | Id extends "share" - ? ShareContentData - : never; + ? ContactsContentData + : never | Id extends "email" + ? EmailContentData + : never | Id extends "general" + ? GeneralContentData + : never | Id extends "join" + ? JoinContentData + : never | Id extends "join/setup" + ? JoinSetupContentData + : never | Id extends "profile" + ? ProfileContentData + : never | Id extends "share" + ? ShareContentData + : never; diff --git a/src/type/create-contact-mfa-data.ts b/src/type/create-contact-mfa-data.ts index e14dab70d..e7e83a88d 100644 --- a/src/type/create-contact-mfa-data.ts +++ b/src/type/create-contact-mfa-data.ts @@ -1,4 +1,4 @@ -import { CONTACT_MFA_TYPE } from "@enums/contact-mfa-type"; +import { CONTACT_MFA_TYPE } from "#enums/contact-mfa-type"; export interface CreateContactMfaData { type: CONTACT_MFA_TYPE; diff --git a/src/type/delete-contact-mfa-data.ts b/src/type/delete-contact-mfa-data.ts index 52ff8433e..55fadc0a0 100644 --- a/src/type/delete-contact-mfa-data.ts +++ b/src/type/delete-contact-mfa-data.ts @@ -1,4 +1,4 @@ -import { CONTACT_MFA_TYPE } from "@enums/contact-mfa-type"; +import { CONTACT_MFA_TYPE } from "#enums/contact-mfa-type"; export interface DeleteContactMfaData { type: CONTACT_MFA_TYPE; diff --git a/src/type/passport-local-done-callback.ts b/src/type/passport-local-done-callback.ts index a7cfdf3dc..eefa1db90 100644 --- a/src/type/passport-local-done-callback.ts +++ b/src/type/passport-local-done-callback.ts @@ -1,7 +1,7 @@ -import type Contact from "@models/Contact"; +import type Contact from "#models/Contact"; import type { HttpError } from "routing-controllers"; -import type { UnauthorizedError } from "@api/errors/UnauthorizedError"; -import type { PassportLocalVerifyOptions } from "@type/passport-local-verify-options"; +import type { UnauthorizedError } from "#api/errors/UnauthorizedError"; +import type { PassportLocalVerifyOptions } from "#type/passport-local-verify-options"; export type PassportLocalDoneCallback = ( error: null | HttpError | UnauthorizedError, diff --git a/src/type/passport-local-verify-options.ts b/src/type/passport-local-verify-options.ts index 5e9f34d77..eb88b5c39 100644 --- a/src/type/passport-local-verify-options.ts +++ b/src/type/passport-local-verify-options.ts @@ -1,5 +1,5 @@ import type { IVerifyOptions } from "passport-local"; -import type { LOGIN_CODES } from "@enums/login-codes"; +import type { LOGIN_CODES } from "#enums/login-codes"; export type PassportLocalVerifyOptions = IVerifyOptions & { message: LOGIN_CODES | string; diff --git a/src/type/passport-login-info.ts b/src/type/passport-login-info.ts index ce5ba2dc8..ba26767ae 100644 --- a/src/type/passport-login-info.ts +++ b/src/type/passport-login-info.ts @@ -1,4 +1,4 @@ -import { LOGIN_CODES } from "@enums/login-codes"; +import { LOGIN_CODES } from "#enums/login-codes"; export interface PassportLoginInfo { message: LOGIN_CODES; diff --git a/src/typings/index.d.ts b/src/typings/index.d.ts index a67e22923..22f586ecc 100644 --- a/src/typings/index.d.ts +++ b/src/typings/index.d.ts @@ -1,10 +1,10 @@ import { ParamsDictionary } from "express-serve-static-core"; -import ApiKey from "@models/ApiKey"; -import { CalloutResponseAnswers } from "@models/CalloutResponse"; -import Contact from "@models/Contact"; +import ApiKey from "#models/ApiKey"; +import { CalloutResponseAnswers } from "#models/CalloutResponse"; +import Contact from "#models/Contact"; -import { AuthInfo as AuthInfo2 } from "@type/auth-info"; +import { AuthInfo as AuthInfo2 } from "#type/auth-info"; declare global { type HTMLElement = never; @@ -13,7 +13,7 @@ declare global { type URLSearchParams = never; namespace Express { - export interface User extends Contact {} + export interface User extends Contact { } export interface Request { flash( @@ -30,7 +30,7 @@ declare global { declare module "papaparse" { // eslint-disable-next-line @typescript-eslint/no-empty-interface - interface File {} + interface File { } } declare module "express-session" { diff --git a/src/webhooks/app.ts b/src/webhooks/app.ts index 72b73a8d3..dbbae7c45 100644 --- a/src/webhooks/app.ts +++ b/src/webhooks/app.ts @@ -1,11 +1,11 @@ -import "module-alias/register"; +// import "module-alias/register"; import express, { Handler } from "express"; -import { log, requestErrorLogger, requestLogger } from "@core/logging"; -import { initApp, startServer } from "@core/server"; +import { log, requestErrorLogger, requestLogger } from "#core/logging"; +import { initApp, startServer } from "#core/server"; -import OptionsService, { OptionKey } from "@core/services/OptionsService"; +import OptionsService, { OptionKey } from "#core/services/OptionsService"; import gocardlessApp from "./handlers/gocardless"; import mailchimpApp from "./handlers/mailchimp"; diff --git a/src/webhooks/handlers/gocardless.ts b/src/webhooks/handlers/gocardless.ts index 960fc14b5..745feda5f 100644 --- a/src/webhooks/handlers/gocardless.ts +++ b/src/webhooks/handlers/gocardless.ts @@ -6,9 +6,9 @@ import { PaymentStatus } from "gocardless-nodejs/types/Types"; -import { log as mainLogger } from "@core/logging"; -import gocardless from "@core/lib/gocardless"; -import { wrapAsync } from "@core/utils"; +import { log as mainLogger } from "#core/logging"; +import gocardless from "#core/lib/gocardless"; +import { wrapAsync } from "#core/utils"; import { updatePaymentStatus, updatePayment, diff --git a/src/webhooks/handlers/mailchimp.ts b/src/webhooks/handlers/mailchimp.ts index 4dfa30566..f8aa39040 100644 --- a/src/webhooks/handlers/mailchimp.ts +++ b/src/webhooks/handlers/mailchimp.ts @@ -2,14 +2,14 @@ import { NewsletterStatus, ContributionType } from "@beabee/beabee-common"; import bodyParser from "body-parser"; import express from "express"; -import { log as mainLogger } from "@core/logging"; -import { cleanEmailAddress, wrapAsync } from "@core/utils"; +import { log as mainLogger } from "#core/logging"; +import { cleanEmailAddress, wrapAsync } from "#core/utils"; -import ContactsService from "@core/services/ContactsService"; -import NewsletterService from "@core/services/NewsletterService"; -import OptionsService from "@core/services/OptionsService"; +import ContactsService from "#core/services/ContactsService"; +import NewsletterService from "#core/services/NewsletterService"; +import OptionsService from "#core/services/OptionsService"; -import config from "@config"; +import config from "#config"; const log = mainLogger.child({ app: "webhook-mailchimp" }); diff --git a/src/webhooks/handlers/stripe.ts b/src/webhooks/handlers/stripe.ts index 3aa826969..755e6200b 100644 --- a/src/webhooks/handlers/stripe.ts +++ b/src/webhooks/handlers/stripe.ts @@ -4,20 +4,20 @@ import { add } from "date-fns"; import express from "express"; import Stripe from "stripe"; -import { getRepository } from "@core/database"; -import { log as mainLogger } from "@core/logging"; -import stripe from "@core/lib/stripe"; -import { wrapAsync } from "@core/utils"; -import { convertStatus } from "@core/utils/payment/stripe"; +import { getRepository } from "#core/database"; +import { log as mainLogger } from "#core/logging"; +import stripe from "#core/lib/stripe"; +import { wrapAsync } from "#core/utils"; +import { convertStatus } from "#core/utils/payment/stripe"; -import GiftService from "@core/services/GiftService"; -import ContactsService from "@core/services/ContactsService"; -import PaymentService from "@core/services/PaymentService"; +import GiftService from "#core/services/GiftService"; +import ContactsService from "#core/services/ContactsService"; +import PaymentService from "#core/services/PaymentService"; -import Payment from "@models/Payment"; -import PaymentData, { StripePaymentData } from "@models/PaymentData"; +import Payment from "#models/Payment"; +import PaymentData, { StripePaymentData } from "#models/PaymentData"; -import config from "@config"; +import config from "#config"; const log = mainLogger.child({ app: "webhook-stripe" }); diff --git a/src/webhooks/utils/gocardless.ts b/src/webhooks/utils/gocardless.ts index d67231dca..563c85799 100644 --- a/src/webhooks/utils/gocardless.ts +++ b/src/webhooks/utils/gocardless.ts @@ -6,18 +6,18 @@ import { } from "gocardless-nodejs/types/Types"; import moment, { DurationInputObject } from "moment"; -import { getRepository } from "@core/database"; -import gocardless from "@core/lib/gocardless"; -import { log as mainLogger } from "@core/logging"; -import { convertStatus } from "@core/utils/payment/gocardless"; +import { getRepository } from "#core/database"; +import gocardless from "#core/lib/gocardless"; +import { log as mainLogger } from "#core/logging"; +import { convertStatus } from "#core/utils/payment/gocardless"; -import ContactsService from "@core/services/ContactsService"; -import PaymentService from "@core/services/PaymentService"; +import ContactsService from "#core/services/ContactsService"; +import PaymentService from "#core/services/PaymentService"; -import { GCPaymentData } from "@models/PaymentData"; -import Payment from "@models/Payment"; +import { GCPaymentData } from "#models/PaymentData"; +import Payment from "#models/Payment"; -import config from "@config"; +import config from "#config"; import { PaymentStatus } from "@beabee/beabee-common"; const log = mainLogger.child({ app: "payment-webhook-utils" }); diff --git a/tsconfig.json b/tsconfig.json index 4324fbc4f..dd2ae219f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -16,14 +16,14 @@ "outDir": "./built", "baseUrl": "./", "paths": { - "@core/*": ["./src/core/*"], - "@apps/*": ["./src/apps/*"], - "@api/*": ["./src/api/*"], - "@config": ["./src/config/config"], - "@locale": ["./src/locales/current"], - "@models/*": ["./src/models/*"], - "@type/*": ["./src/type/*"], - "@enums/*": ["./src/enums/*"] + "#core/*": ["./src/core/*"], + "#apps/*": ["./src/apps/*"], + "#api/*": ["./src/api/*"], + "#config": ["./src/config/config"], + "#locale": ["./src/locales/current"], + "#models/*": ["./src/models/*"], + "#type/*": ["./src/type/*"], + "#enums/*": ["./src/enums/*"] }, "typeRoots": ["./src/typings", "./node_modules/@types/"] } From 0436caff7c48121585a4cbfeb790919088c87c44 Mon Sep 17 00:00:00 2001 From: Pascal Garber Date: Thu, 21 Mar 2024 13:58:57 +0100 Subject: [PATCH 2/3] chore(native-import-alias): Add index import alias --- package.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index e5f17d4a5..1b13d2c49 100644 --- a/package.json +++ b/package.json @@ -139,9 +139,11 @@ "> 1%" ], "imports": { + "#core/utils": "./built/core/utils/index.js", "#core/defaults.json": "./built/core/defaults.json", "#core/*": "./built/core/*.js", "#apps/*": "./built/apps/*.js", + "#api/utils": "./built/api/utils/index.js", "#api/*": "./built/api/*.js", "#config": "./built/config/config.js", "#locale": "./built/locales/current.js", @@ -164,4 +166,4 @@ "postcss": "8.4.32" } } -} \ No newline at end of file +} From 04c358935a5b1e634238f4edc1c2b56534181673 Mon Sep 17 00:00:00 2001 From: Pascal Garber Date: Thu, 21 Mar 2024 14:44:23 +0100 Subject: [PATCH 3/3] chore: Format code --- src/api/controllers/SegmentController.ts | 6 +-- src/api/dto/AddressDto.ts | 2 +- src/api/dto/BaseDto.ts | 3 +- src/api/dto/CalloutFormDto.ts | 12 ++++-- src/api/dto/CalloutResponseDto.ts | 6 +-- src/api/dto/ContentDto.ts | 28 +++++++------- src/api/dto/ContributionDto.ts | 3 +- .../BaseCalloutResponseTransformer.ts | 6 +-- src/api/transformers/BaseTransformer.ts | 6 +-- .../transformers/CalloutResponseExporter.ts | 15 ++++---- .../CalloutResponseTransformer.ts | 4 +- src/api/transformers/ContactTransformer.ts | 12 +++--- src/api/validators/MinContributionAmount.ts | 3 +- src/apps/gift/app.ts | 14 +++---- src/apps/members/app.ts | 8 ++-- src/apps/members/apps/add/app.ts | 10 ++--- .../members/apps/member/apps/profile/app.ts | 10 ++--- src/apps/members/apps/segments/app.ts | 10 ++--- src/apps/reports/apps/map/app.ts | 6 +-- src/apps/settings/apps/newsletters/app.ts | 8 ++-- src/apps/tools/apps/exports/app.ts | 5 ++- .../tools/apps/exports/exports/GiftsExport.ts | 38 +++++++++---------- .../apps/exports/exports/ReferralsExport.ts | 24 ++++++------ src/apps/tools/apps/special-urls/app.js | 5 ++- src/core/lib/gocardless.ts | 13 ++++--- src/core/middleware.ts | 4 +- src/core/providers/email/BaseProvider.ts | 10 ++--- .../providers/newsletter/MailchimpProvider.ts | 6 +-- src/core/providers/payment/GCProvider.ts | 16 ++++---- src/core/providers/payment/ManualProvider.ts | 4 +- src/core/providers/payment/StripeProvider.ts | 16 ++++---- src/core/services/EmailService.ts | 4 +- src/core/services/GiftService.ts | 5 ++- src/core/services/PageSettingsService.ts | 10 ++--- src/core/utils/email.ts | 29 +++++++------- src/core/utils/payment.ts | 6 +-- src/core/utils/payment/stripe.ts | 28 +++++++------- ...513644609-AddEmailAndPasswordToJoinFlow.ts | 3 +- .../1634125137636-AddExcerptAndImageToPoll.ts | 3 +- ...650900384747-AddPaymentMethodToJoinForm.ts | 3 +- src/models/Contact.ts | 11 +++--- src/tools/process-segments.ts | 2 +- src/type/content-data.ts | 28 +++++++------- src/typings/index.d.ts | 4 +- 44 files changed, 233 insertions(+), 216 deletions(-) diff --git a/src/api/controllers/SegmentController.ts b/src/api/controllers/SegmentController.ts index 7c9b9dc49..a0b5a7447 100644 --- a/src/api/controllers/SegmentController.ts +++ b/src/api/controllers/SegmentController.ts @@ -113,9 +113,9 @@ export class SegmentController { ...query, rules: query.rules ? { - condition: "AND", - rules: [segment.ruleGroup, query.rules] - } + condition: "AND", + rules: [segment.ruleGroup, query.rules] + } : segment.ruleGroup }); } diff --git a/src/api/dto/AddressDto.ts b/src/api/dto/AddressDto.ts index 4d056e938..dfa664faf 100644 --- a/src/api/dto/AddressDto.ts +++ b/src/api/dto/AddressDto.ts @@ -19,4 +19,4 @@ export class UpdateAddressDto implements Address { postcode!: string; } -export class GetAddressDto extends UpdateAddressDto { } +export class GetAddressDto extends UpdateAddressDto {} diff --git a/src/api/dto/BaseDto.ts b/src/api/dto/BaseDto.ts index 6c2a7e2df..6090dcbef 100644 --- a/src/api/dto/BaseDto.ts +++ b/src/api/dto/BaseDto.ts @@ -68,7 +68,8 @@ export class GetExportQuery { export class GetPaginatedQuery extends GetExportQuery - implements PaginatedQuery { + implements PaginatedQuery +{ @IsOptional() @Min(1) @Max(100) diff --git a/src/api/dto/CalloutFormDto.ts b/src/api/dto/CalloutFormDto.ts index 313faf8be..460e7453c 100644 --- a/src/api/dto/CalloutFormDto.ts +++ b/src/api/dto/CalloutFormDto.ts @@ -84,7 +84,8 @@ class ContentCalloutComponentDto extends BaseCalloutComponentDto { class InputCalloutComponentDto extends BaseCalloutComponentDto - implements InputCalloutComponentSchema { + implements InputCalloutComponentSchema +{ @IsIn(inputTypes) type!: (typeof inputTypes)[number]; @@ -108,7 +109,8 @@ class SelectCalloutComponentDataDto { class SelectCalloutComponentDto extends BaseCalloutComponentDto - implements SelectCalloutComponentSchema { + implements SelectCalloutComponentSchema +{ @IsIn(selectTypes) type!: (typeof selectTypes)[number]; @@ -134,7 +136,8 @@ class RadioCalloutComponentValueDto { class RadioCalloutComponentDto extends BaseCalloutComponentDto - implements RadioCalloutComponentSchema { + implements RadioCalloutComponentSchema +{ @IsIn(radioTypes) type!: (typeof radioTypes)[number]; @@ -211,7 +214,8 @@ type CalloutComponentDto = class NestableCalloutComponentDto extends BaseCalloutComponentDto - implements NestableCalloutComponentSchema { + implements NestableCalloutComponentSchema +{ @IsIn(nestedTypes) type!: (typeof nestedTypes)[number]; diff --git a/src/api/dto/CalloutResponseDto.ts b/src/api/dto/CalloutResponseDto.ts index 1a59adf31..76ff92046 100644 --- a/src/api/dto/CalloutResponseDto.ts +++ b/src/api/dto/CalloutResponseDto.ts @@ -65,9 +65,9 @@ export class ListCalloutResponsesDto extends GetPaginatedQuery { // TODO: this is a bit hacky export interface GetCalloutResponseOptsDto - extends BaseGetCalloutResponseOptsDto { } + extends BaseGetCalloutResponseOptsDto {} export interface ListCalloutResponsesDto - extends BaseGetCalloutResponseOptsDto { } + extends BaseGetCalloutResponseOptsDto {} export class GetCalloutResponseDto { @IsString() @@ -179,7 +179,7 @@ export type ExportCalloutResponseDto = [ export interface ExportCalloutResponsesOptsDto extends GetExportQuery, - BaseGetCalloutResponseOptsDto { + BaseGetCalloutResponseOptsDto { callout: Callout; components: (CalloutComponentSchema & { slideId: string })[]; } diff --git a/src/api/dto/ContentDto.ts b/src/api/dto/ContentDto.ts index 0f5e1541d..345f95049 100644 --- a/src/api/dto/ContentDto.ts +++ b/src/api/dto/ContentDto.ts @@ -197,17 +197,17 @@ export class GetShareContentDto implements ShareContentData { export type GetContentDto = Id extends "contacts" - ? GetContactsContentDto - : never | Id extends "email" - ? GetEmailContentDto - : never | Id extends "general" - ? GetGeneralContentDto - : never | Id extends "join" - ? GetJoinContentDto - : never | Id extends "join/setup" - ? GetJoinSetupContentDto - : never | Id extends "profile" - ? GetProfileContentDto - : never | Id extends "share" - ? GetShareContentDto - : never; + ? GetContactsContentDto + : never | Id extends "email" + ? GetEmailContentDto + : never | Id extends "general" + ? GetGeneralContentDto + : never | Id extends "join" + ? GetJoinContentDto + : never | Id extends "join/setup" + ? GetJoinSetupContentDto + : never | Id extends "profile" + ? GetProfileContentDto + : never | Id extends "share" + ? GetShareContentDto + : never; diff --git a/src/api/dto/ContributionDto.ts b/src/api/dto/ContributionDto.ts index ce9cf8b42..b7e14ac22 100644 --- a/src/api/dto/ContributionDto.ts +++ b/src/api/dto/ContributionDto.ts @@ -41,7 +41,8 @@ export class UpdateContributionDto { export class StartContributionDto extends UpdateContributionDto - implements StartJoinFlowDto { + implements StartJoinFlowDto +{ @IsUrl() completeUrl!: string; diff --git a/src/api/transformers/BaseCalloutResponseTransformer.ts b/src/api/transformers/BaseCalloutResponseTransformer.ts index 600c4c17b..13a6932f8 100644 --- a/src/api/transformers/BaseCalloutResponseTransformer.ts +++ b/src/api/transformers/BaseCalloutResponseTransformer.ts @@ -35,9 +35,9 @@ export abstract class BaseCalloutResponseTransformer< protected transformFilters( query: GetOptsDto & PaginatedQuery ): [ - Partial>, - FilterHandlers - ] { + Partial>, + FilterHandlers + ] { // If looking for responses for a particular callout then add answer filtering if (query.callout) { const answerFilters = getCalloutFilters(query.callout.formSchema); diff --git a/src/api/transformers/BaseTransformer.ts b/src/api/transformers/BaseTransformer.ts index fc9046fe2..dfb378074 100644 --- a/src/api/transformers/BaseTransformer.ts +++ b/src/api/transformers/BaseTransformer.ts @@ -31,7 +31,7 @@ export abstract class BaseTransformer< GetDtoOpts = unknown, Query extends GetDtoOpts & PaginatedQuery = GetDtoOpts & PaginatedQuery > { - protected abstract model: { new(): Model }; + protected abstract model: { new (): Model }; protected modelIdField = "id"; protected abstract filters: Filters; @@ -91,7 +91,7 @@ export abstract class BaseTransformer< fieldPrefix: string, query: Query, auth: AuthInfo | undefined - ): void { } + ): void {} /** * Modify the items after they are fetched. @@ -107,7 +107,7 @@ export abstract class BaseTransformer< items: Model[], query: Query, auth: AuthInfo | undefined - ): Promise { } + ): Promise {} /** * Check for sufficient authentication and prepare the query, diff --git a/src/api/transformers/CalloutResponseExporter.ts b/src/api/transformers/CalloutResponseExporter.ts index ae49c767d..0646f9523 100644 --- a/src/api/transformers/CalloutResponseExporter.ts +++ b/src/api/transformers/CalloutResponseExporter.ts @@ -36,11 +36,11 @@ class CalloutResponseExporter extends BaseCalloutResponseTransformer< ): ExportCalloutResponseDto { const contact: [string, string, string, string] = response.contact ? [ - response.contact.firstname, - response.contact.lastname, - response.contact.fullname, - response.contact.email - ] + response.contact.firstname, + response.contact.lastname, + response.contact.fullname, + response.contact.email + ] : ["", "", response.guestName || "", response.guestEmail || ""]; return [ @@ -110,8 +110,9 @@ class CalloutResponseExporter extends BaseCalloutResponseTransformer< components }); - const exportName = `responses-${callout.slug - }_${new Date().toISOString()}.csv`; + const exportName = `responses-${ + callout.slug + }_${new Date().toISOString()}.csv`; const headers = [ "Date", diff --git a/src/api/transformers/CalloutResponseTransformer.ts b/src/api/transformers/CalloutResponseTransformer.ts index 6a2a6b547..c801a4ad4 100644 --- a/src/api/transformers/CalloutResponseTransformer.ts +++ b/src/api/transformers/CalloutResponseTransformer.ts @@ -69,8 +69,8 @@ export class CalloutResponseTransformer extends BaseCalloutResponseTransformer< }), ...(opts.with?.includes(GetCalloutResponseWith.Tags) && response.tags && { - tags: response.tags.map((rt) => CalloutTagTransformer.convert(rt.tag)) - }) + tags: response.tags.map((rt) => CalloutTagTransformer.convert(rt.tag)) + }) }; } diff --git a/src/api/transformers/ContactTransformer.ts b/src/api/transformers/ContactTransformer.ts index d1c6145e4..371e13be1 100644 --- a/src/api/transformers/ContactTransformer.ts +++ b/src/api/transformers/ContactTransformer.ts @@ -59,12 +59,12 @@ class ContactTransformer extends BaseTransformer< }), ...(opts?.with?.includes(GetContactWith.Profile) && contact.profile && { - profile: ContactProfileTransformer.convert( - contact.profile, - undefined, - auth - ) - }), + profile: ContactProfileTransformer.convert( + contact.profile, + undefined, + auth + ) + }), ...(opts?.with?.includes(GetContactWith.Roles) && { roles: contact.roles.map(ContactRoleTransformer.convert) }), diff --git a/src/api/validators/MinContributionAmount.ts b/src/api/validators/MinContributionAmount.ts index 47080f501..17cb58ac3 100644 --- a/src/api/validators/MinContributionAmount.ts +++ b/src/api/validators/MinContributionAmount.ts @@ -9,7 +9,8 @@ import OptionsService from "#core/services/OptionsService"; @ValidatorConstraint({ name: "minContributionAmount" }) export default class MinContributionAmount - implements ValidatorConstraintInterface { + implements ValidatorConstraintInterface +{ validate(amount: unknown, args: ValidationArguments): boolean { return typeof amount === "number" && amount >= this.minAmount(args); } diff --git a/src/apps/gift/app.ts b/src/apps/gift/app.ts index 2cc04e0dc..c3e4f0dee 100644 --- a/src/apps/gift/app.ts +++ b/src/apps/gift/app.ts @@ -38,14 +38,14 @@ interface AddressSchema { type UpdateGiftAddressSchema = | { - sameAddress: true; - giftAddress: AddressSchema; - } + sameAddress: true; + giftAddress: AddressSchema; + } | { - sameAddress: false; - giftAddress: AddressSchema; - deliveryAddress: AddressSchema; - }; + sameAddress: false; + giftAddress: AddressSchema; + deliveryAddress: AddressSchema; + }; function schemaToGiftForm(data: CreateGiftSchema): GiftForm { const giftForm = new GiftForm(); diff --git a/src/apps/members/app.ts b/src/apps/members/app.ts index 6b8899e6e..1e5932693 100644 --- a/src/apps/members/app.ts +++ b/src/apps/members/app.ts @@ -84,10 +84,10 @@ export function cleanRuleGroup(group: RuleGroup): RuleGroup { "condition" in rule ? cleanRuleGroup(rule) : { - field: rule.field, - operator: rule.operator, - value: Array.isArray(rule.value) ? rule.value : [rule.value] - } + field: rule.field, + operator: rule.operator, + value: Array.isArray(rule.value) ? rule.value : [rule.value] + } ) }; } diff --git a/src/apps/members/apps/add/app.ts b/src/apps/members/apps/add/app.ts index c38628a41..95b62b494 100644 --- a/src/apps/members/apps/add/app.ts +++ b/src/apps/members/apps/add/app.ts @@ -86,11 +86,11 @@ app.post( }, data.addToNewsletter ? { - newsletterStatus: NewsletterStatus.Subscribed, - newsletterGroups: OptionsService.getList( - "newsletter-default-groups" - ) - } + newsletterStatus: NewsletterStatus.Subscribed, + newsletterGroups: OptionsService.getList( + "newsletter-default-groups" + ) + } : undefined ); } catch (error) { diff --git a/src/apps/members/apps/member/apps/profile/app.ts b/src/apps/members/apps/member/apps/profile/app.ts index 52603d9ea..b4f6f357d 100644 --- a/src/apps/members/apps/member/apps/profile/app.ts +++ b/src/apps/members/apps/member/apps/profile/app.ts @@ -46,11 +46,11 @@ app.post( deliveryOptIn: delivery_optin, deliveryAddress: delivery_optin ? { - line1: delivery_line1, - line2: delivery_line2, - city: delivery_city, - postcode: delivery_postcode - } + line1: delivery_line1, + line2: delivery_line2, + city: delivery_city, + postcode: delivery_postcode + } : null }); } catch (error) { diff --git a/src/apps/members/apps/segments/app.ts b/src/apps/members/apps/segments/app.ts index dc6bfb968..6e680c573 100644 --- a/src/apps/members/apps/segments/app.ts +++ b/src/apps/members/apps/segments/app.ts @@ -137,11 +137,11 @@ app.post( const email = data.email === "__new__" ? await getRepository(Email).save( - schemaToEmail({ - ...data, - name: "Email to segment " + segment.name - }) - ) + schemaToEmail({ + ...data, + name: "Email to segment " + segment.name + }) + ) : await getRepository(Email).findOneByOrFail({ id: data.email }); if (data.type === "ongoing") { diff --git a/src/apps/reports/apps/map/app.ts b/src/apps/reports/apps/map/app.ts index ab001c57f..50d1ad183 100644 --- a/src/apps/reports/apps/map/app.ts +++ b/src/apps/reports/apps/map/app.ts @@ -65,9 +65,9 @@ async function getPostcodes(postcodes: string[]): Promise { for (const result of data.result) { postcodeCache[result.query] = result.result ? { - latitude: result.result.latitude, - longitude: result.result.longitude - } + latitude: result.result.latitude, + longitude: result.result.longitude + } : null; } } diff --git a/src/apps/settings/apps/newsletters/app.ts b/src/apps/settings/apps/newsletters/app.ts index 335af808a..c1bc25881 100644 --- a/src/apps/settings/apps/newsletters/app.ts +++ b/src/apps/settings/apps/newsletters/app.ts @@ -47,11 +47,11 @@ function isMismatchedContact(contact: Contact, nlContact: NewsletterContact) { return ( contact.profile.newsletterStatus !== nlContact.status || groupsList(contact.profile.newsletterGroups) !== - groupsList(nlContact.groups) || + groupsList(nlContact.groups) || !!contact.membership?.isActive !== - nlContact.tags.includes( - OptionsService.getText("newsletter-active-member-tag") - ) + nlContact.tags.includes( + OptionsService.getText("newsletter-active-member-tag") + ) ); } diff --git a/src/apps/tools/apps/exports/app.ts b/src/apps/tools/apps/exports/app.ts index c0a19d5ff..52575c018 100644 --- a/src/apps/tools/apps/exports/app.ts +++ b/src/apps/tools/apps/exports/app.ts @@ -192,8 +192,9 @@ app.post( } else if (data.action === "export") { const items = await exportType.getItems(data.status); - const exportName = `export-${exportDetails.description - }_${new Date().toISOString()}.csv`; + const exportName = `export-${ + exportDetails.description + }_${new Date().toISOString()}.csv`; const exportData = await exportType.getExport(items as any); res.attachment(exportName).send(Papa.unparse(exportData as any)); // TODO: fix diff --git a/src/apps/tools/apps/exports/exports/GiftsExport.ts b/src/apps/tools/apps/exports/exports/GiftsExport.ts index 43b484d47..35cd7bef1 100644 --- a/src/apps/tools/apps/exports/exports/GiftsExport.ts +++ b/src/apps/tools/apps/exports/exports/GiftsExport.ts @@ -39,26 +39,26 @@ export default class GiftsExport extends BaseExport { return giftFlows.map(({ date, giftee, giftForm, setupCode }) => { const gifteeDetails = giftee ? { - GifteeName: giftee.fullname, - GifteeFirstName: giftee.firstname, - GifteeEmail: giftee.email, - GifteeExpiryDate: giftee.roles - .find((p) => p.type === "member") - ?.dateExpires?.toISOString(), - GifteeHasActivated: !giftee.password.hash, - GifteeHasConverted: - giftee.contributionType !== ContributionType.Gift, - ...addressFields(giftee.profile.deliveryAddress) - } + GifteeName: giftee.fullname, + GifteeFirstName: giftee.firstname, + GifteeEmail: giftee.email, + GifteeExpiryDate: giftee.roles + .find((p) => p.type === "member") + ?.dateExpires?.toISOString(), + GifteeHasActivated: !giftee.password.hash, + GifteeHasConverted: + giftee.contributionType !== ContributionType.Gift, + ...addressFields(giftee.profile.deliveryAddress) + } : { - GifteeName: giftForm.firstname + " " + giftForm.lastname, - GifteeFirstName: giftForm.firstname, - GifteeEmail: giftForm.email, - GifteeExpiryDate: "", - GifteeHasActivated: false, - GifteeHasConverted: false, - ...addressFields(giftForm.deliveryAddress) - }; + GifteeName: giftForm.firstname + " " + giftForm.lastname, + GifteeFirstName: giftForm.firstname, + GifteeEmail: giftForm.email, + GifteeExpiryDate: "", + GifteeHasActivated: false, + GifteeHasConverted: false, + ...addressFields(giftForm.deliveryAddress) + }; return { GiftPurchaseDate: date.toISOString(), diff --git a/src/apps/tools/apps/exports/exports/ReferralsExport.ts b/src/apps/tools/apps/exports/exports/ReferralsExport.ts index 09a929678..1f6113f74 100644 --- a/src/apps/tools/apps/exports/exports/ReferralsExport.ts +++ b/src/apps/tools/apps/exports/exports/ReferralsExport.ts @@ -10,18 +10,18 @@ import BaseExport, { ExportResult } from "./BaseExport"; function contactDetails(contact: Contact | null) { return contact ? [ - contact.email, - contact.firstname, - contact.lastname, - ...(contact.profile.deliveryOptIn && contact.profile.deliveryAddress - ? [ - contact.profile.deliveryAddress.line1, - contact.profile.deliveryAddress.line2, - contact.profile.deliveryAddress.city, - contact.profile.deliveryAddress.postcode - ] - : ["", "", "", ""]) - ] + contact.email, + contact.firstname, + contact.lastname, + ...(contact.profile.deliveryOptIn && contact.profile.deliveryAddress + ? [ + contact.profile.deliveryAddress.line1, + contact.profile.deliveryAddress.line2, + contact.profile.deliveryAddress.city, + contact.profile.deliveryAddress.postcode + ] + : ["", "", "", ""]) + ] : ["", "", "", "", "", "", ""]; } diff --git a/src/apps/tools/apps/special-urls/app.js b/src/apps/tools/apps/special-urls/app.js index 29bd6648d..d676d14a7 100644 --- a/src/apps/tools/apps/special-urls/app.js +++ b/src/apps/tools/apps/special-urls/app.js @@ -107,8 +107,9 @@ app.post( }); break; case "export-urls": { - const exportName = `export-${req.model.name - }_${new Date().toISOString()}.csv`; + const exportName = `export-${ + req.model.name + }_${new Date().toISOString()}.csv`; const exportData = (await SpecialUrls.find({ group: req.model })) .filter((specialUrl) => !req.body.onlyActive || specialUrl.active) .map((specialUrl) => ({ diff --git a/src/core/lib/gocardless.ts b/src/core/lib/gocardless.ts index 4bc8a4496..1ba63505c 100644 --- a/src/core/lib/gocardless.ts +++ b/src/core/lib/gocardless.ts @@ -21,8 +21,9 @@ import { DeepPartial } from "typeorm"; const log = mainLogger.child({ app: "gocardless-api" }); const gocardless = axios.create({ - baseURL: `https://${config.gocardless.sandbox ? "api-sandbox" : "api" - }.gocardless.com`, + baseURL: `https://${ + config.gocardless.sandbox ? "api-sandbox" : "api" + }.gocardless.com`, headers: { Authorization: `Bearer ${config.gocardless.accessToken}`, "GoCardless-Version": "2015-07-06", @@ -194,10 +195,10 @@ export default { req.body && req.headers["content-type"] === "application/json" && req.headers["webhook-signature"] === - crypto - .createHmac("sha256", config.gocardless.secret) - .update(req.body) - .digest("hex") + crypto + .createHmac("sha256", config.gocardless.secret) + .update(req.body) + .digest("hex") ); } } diff --git a/src/core/middleware.ts b/src/core/middleware.ts index 7ca8bf2cc..290928173 100644 --- a/src/core/middleware.ts +++ b/src/core/middleware.ts @@ -75,8 +75,8 @@ const send400: OnErrorHandler = (errors, req, res) => { const redirectTo = (url: string): OnErrorHandler => - (errors, req, res) => - res.redirect(url); + (errors, req, res) => + res.redirect(url); const replyWithJSON: OnErrorHandler = (errors, req, res) => { res.status(400).send(convertErrorsToMessages(errors)); diff --git a/src/core/providers/email/BaseProvider.ts b/src/core/providers/email/BaseProvider.ts index bae6f924a..14e66a6d3 100644 --- a/src/core/providers/email/BaseProvider.ts +++ b/src/core/providers/email/BaseProvider.ts @@ -85,12 +85,12 @@ const magicMergeFieldsProcessors = { recipient.mergeFields?.LOGINLINK ? recipient : { - ...recipient, - mergeFields: { - ...recipient.mergeFields, - LOGINLINK: `${config.audience}/auth/login` + ...recipient, + mergeFields: { + ...recipient.mergeFields, + LOGINLINK: `${config.audience}/auth/login` + } } - } ); } } as const; diff --git a/src/core/providers/newsletter/MailchimpProvider.ts b/src/core/providers/newsletter/MailchimpProvider.ts index 226bc8e72..12b692cd4 100644 --- a/src/core/providers/newsletter/MailchimpProvider.ts +++ b/src/core/providers/newsletter/MailchimpProvider.ts @@ -157,8 +157,8 @@ function mcMemberToNlContact(member: MCMember): NewsletterContact { status: mcStatusToStatus(member.status), groups: member.interests ? Object.entries(member.interests) - .filter(([group, isOptedIn]) => isOptedIn) - .map(([group]) => group) + .filter(([group, isOptedIn]) => isOptedIn) + .map(([group]) => group) : [], tags: member.tags.map((tag) => tag.name), fields @@ -211,7 +211,7 @@ export default class MailchimpProvider implements NewsletterProvider { try { const resp = await this.instance.get(this.emailUrl(email)); return mcMemberToNlContact(resp.data); - } catch (err) { } + } catch (err) {} } async getContacts(): Promise { diff --git a/src/core/providers/payment/GCProvider.ts b/src/core/providers/payment/GCProvider.ts index be6c95c04..fa276130b 100644 --- a/src/core/providers/payment/GCProvider.ts +++ b/src/core/providers/payment/GCProvider.ts @@ -61,11 +61,11 @@ export default class GCProvider extends PaymentProvider { hasPendingPayment: pendingPayment, ...(this.data.nextAmount && this.contact.contributionPeriod && { - nextAmount: getActualAmount( - this.data.nextAmount.monthly, - this.contact.contributionPeriod - ) - }), + nextAmount: getActualAmount( + this.data.nextAmount.monthly, + this.contact.contributionPeriod + ) + }), ...(paymentSource && { paymentSource }) }; } @@ -161,9 +161,9 @@ export default class GCProvider extends PaymentProvider { this.data.nextAmount = startNow ? null : { - monthly: paymentForm.monthlyAmount, - chargeable: Number(subscription.amount) - }; + monthly: paymentForm.monthlyAmount, + chargeable: Number(subscription.amount) + }; await this.updateData(); diff --git a/src/core/providers/payment/ManualProvider.ts b/src/core/providers/payment/ManualProvider.ts index ed091d603..344c367f6 100644 --- a/src/core/providers/payment/ManualProvider.ts +++ b/src/core/providers/payment/ManualProvider.ts @@ -20,8 +20,8 @@ export default class ManualProvider extends PaymentProvider< }; } - async cancelContribution(keepMandate: boolean): Promise { } - async updateContact(updates: Partial): Promise { } + async cancelContribution(keepMandate: boolean): Promise {} + async updateContact(updates: Partial): Promise {} async updateContribution( paymentForm: PaymentForm diff --git a/src/core/providers/payment/StripeProvider.ts b/src/core/providers/payment/StripeProvider.ts index 820208a66..30abc0747 100644 --- a/src/core/providers/payment/StripeProvider.ts +++ b/src/core/providers/payment/StripeProvider.ts @@ -58,11 +58,11 @@ export default class StripeProvider extends PaymentProvider { ...(paymentSource && { paymentSource }), ...(this.data.nextAmount && this.contact.contributionPeriod && { - nextAmount: getActualAmount( - this.data.nextAmount.monthly, - this.contact.contributionPeriod - ) - }) + nextAmount: getActualAmount( + this.data.nextAmount.monthly, + this.contact.contributionPeriod + ) + }) }; } @@ -151,9 +151,9 @@ export default class StripeProvider extends PaymentProvider { this.data.nextAmount = startNow ? null : { - chargeable: getChargeableAmount(paymentForm, this.method), - monthly: paymentForm.monthlyAmount - }; + chargeable: getChargeableAmount(paymentForm, this.method), + monthly: paymentForm.monthlyAmount + }; await this.updateData(); diff --git a/src/core/services/EmailService.ts b/src/core/services/EmailService.ts index acf3481d7..b5de0b404 100644 --- a/src/core/services/EmailService.ts +++ b/src/core/services/EmailService.ts @@ -222,8 +222,8 @@ class EmailService { ): Promise; async sendTemplateToContact< T extends ContactEmailParams extends undefined - ? ContactEmailTemplateId - : never + ? ContactEmailTemplateId + : never >( template: T, contact: Contact, diff --git a/src/core/services/GiftService.ts b/src/core/services/GiftService.ts index e08b384dc..85378091a 100644 --- a/src/core/services/GiftService.ts +++ b/src/core/services/GiftService.ts @@ -35,8 +35,9 @@ export default class GiftService { payment_method_types: ["card"], line_items: [ { - name: `Gift membership - ${giftForm.months} month${giftForm.months != 1 ? "s" : "" - }`, + name: `Gift membership - ${giftForm.months} month${ + giftForm.months != 1 ? "s" : "" + }`, amount: giftForm.months * GiftService.giftMonthlyAmount * 100, currency: config.currencyCode.toLowerCase(), quantity: 1 diff --git a/src/core/services/PageSettingsService.ts b/src/core/services/PageSettingsService.ts index 24d140050..f72662b7d 100644 --- a/src/core/services/PageSettingsService.ts +++ b/src/core/services/PageSettingsService.ts @@ -22,11 +22,11 @@ export default class PageSettingsService { } return cache === "default" ? { - shareUrl: "/", - shareTitle: OptionsService.getText("share-title"), - shareDescription: OptionsService.getText("share-description"), - shareImage: OptionsService.getText("share-image") - } + shareUrl: "/", + shareTitle: OptionsService.getText("share-title"), + shareDescription: OptionsService.getText("share-description"), + shareImage: OptionsService.getText("share-image") + } : cache; } diff --git a/src/core/utils/email.ts b/src/core/utils/email.ts index 4eaa99efe..93b4cbef6 100644 --- a/src/core/utils/email.ts +++ b/src/core/utils/email.ts @@ -16,21 +16,22 @@ export function getEmailFooter(): string { "organisation" )}


-

${locale.footer.contactUs - } ${OptionsService.getText("support-email")}.

+

${ + locale.footer.contactUs + } ${OptionsService.getText("support-email")}.

${[ - [ - locale.footer.privacyPolicy, - OptionsService.getText("footer-privacy-link-url") - ], - [locale.footer.terms, OptionsService.getText("footer-terms-link-url")], - ["Impressum", OptionsService.getText("footer-impressum-link-url")] - ] - .filter(([text, url]) => !!url) - .map(([text, url]) => `${text}`) - .join(", ")}

+ [ + locale.footer.privacyPolicy, + OptionsService.getText("footer-privacy-link-url") + ], + [locale.footer.terms, OptionsService.getText("footer-terms-link-url")], + ["Impressum", OptionsService.getText("footer-impressum-link-url")] + ] + .filter(([text, url]) => !!url) + .map(([text, url]) => `${text}`) + .join(", ")}

`; } diff --git a/src/core/utils/payment.ts b/src/core/utils/payment.ts index 21e0fee62..8bc92cbec 100644 --- a/src/core/utils/payment.ts +++ b/src/core/utils/payment.ts @@ -84,9 +84,9 @@ export function getChargeableAmount( const amount = getActualAmount(paymentForm.monthlyAmount, paymentForm.period); const fee = paymentForm.payFee ? calcPaymentFee( - { amount, period: paymentForm.period, paymentMethod }, - config.stripe.country - ) + { amount, period: paymentForm.period, paymentMethod }, + config.stripe.country + ) : 0; return Math.round((amount + fee) * 100); } diff --git a/src/core/utils/payment/stripe.ts b/src/core/utils/payment/stripe.ts index 44c7e0387..572744215 100644 --- a/src/core/utils/payment/stripe.ts +++ b/src/core/utils/payment/stripe.ts @@ -45,8 +45,8 @@ async function calculateProrationParams( // as this aligns with Stripe's calculations const prorationTime = Math.floor( subscription.current_period_end - - (subscription.current_period_end - subscription.current_period_start) * - (monthsLeft / 12) + (subscription.current_period_end - subscription.current_period_start) * + (monthsLeft / 12) ); const invoice = await stripe.invoices.retrieveUpcoming({ @@ -85,9 +85,9 @@ export async function createSubscription( off_session: true, ...(renewalDate && renewalDate > new Date() && { - billing_cycle_anchor: Math.floor(+renewalDate / 1000), - proration_behavior: "none" - }) + billing_cycle_anchor: Math.floor(+renewalDate / 1000), + proration_behavior: "none" + }) }); } @@ -136,16 +136,16 @@ export async function updateSubscription( items: [newSubscriptionItem], ...(prorationAmount > 0 ? { - proration_behavior: "always_invoice", - proration_date: prorationTime - } + proration_behavior: "always_invoice", + proration_date: prorationTime + } : { - proration_behavior: "none", - // Force it to change at the start of the next period, this is - // important when changing from monthly to annual as otherwise - // Stripe starts the new billing cycle immediately - trial_end: subscription.current_period_end - }) + proration_behavior: "none", + // Force it to change at the start of the next period, this is + // important when changing from monthly to annual as otherwise + // Stripe starts the new billing cycle immediately + trial_end: subscription.current_period_end + }) }); } else { // Schedule the change for the next period diff --git a/src/migrations/1621513644609-AddEmailAndPasswordToJoinFlow.ts b/src/migrations/1621513644609-AddEmailAndPasswordToJoinFlow.ts index 0813d695b..8812e703b 100644 --- a/src/migrations/1621513644609-AddEmailAndPasswordToJoinFlow.ts +++ b/src/migrations/1621513644609-AddEmailAndPasswordToJoinFlow.ts @@ -3,7 +3,8 @@ import { MigrationInterface, QueryRunner } from "typeorm"; import { addThenSetNotNull } from "#core/utils/db"; export class AddEmailAndPasswordToJoinFlow1621513644609 - implements MigrationInterface { + implements MigrationInterface +{ name = "AddEmailAndPasswordToJoinFlow1621513644609"; public async up(queryRunner: QueryRunner): Promise { diff --git a/src/migrations/1634125137636-AddExcerptAndImageToPoll.ts b/src/migrations/1634125137636-AddExcerptAndImageToPoll.ts index 39d863497..c34af2543 100644 --- a/src/migrations/1634125137636-AddExcerptAndImageToPoll.ts +++ b/src/migrations/1634125137636-AddExcerptAndImageToPoll.ts @@ -2,7 +2,8 @@ import { addThenSetNotNull } from "#core/utils/db"; import { MigrationInterface, QueryRunner } from "typeorm"; export class AddExcerptAndImageToPoll1634125137636 - implements MigrationInterface { + implements MigrationInterface +{ name = "AddExcerptAndImageToPoll1634125137636"; public async up(queryRunner: QueryRunner): Promise { diff --git a/src/migrations/1650900384747-AddPaymentMethodToJoinForm.ts b/src/migrations/1650900384747-AddPaymentMethodToJoinForm.ts index 9a1412ee5..4d469fe92 100644 --- a/src/migrations/1650900384747-AddPaymentMethodToJoinForm.ts +++ b/src/migrations/1650900384747-AddPaymentMethodToJoinForm.ts @@ -2,7 +2,8 @@ import { addThenSetNotNull } from "#core/utils/db"; import { MigrationInterface, QueryRunner } from "typeorm"; export class AddPaymentMethodToJoinForm1650900384747 - implements MigrationInterface { + implements MigrationInterface +{ name = "AddPaymentMethodToJoinForm1650900384747"; public async up(queryRunner: QueryRunner): Promise { diff --git a/src/models/Contact.ts b/src/models/Contact.ts index bae1a1471..c95a901c6 100644 --- a/src/models/Contact.ts +++ b/src/models/Contact.ts @@ -104,9 +104,9 @@ export default class Contact { return this.contributionMonthlyAmount === null ? null : getActualAmount( - this.contributionMonthlyAmount, - this.contributionPeriod! - ); + this.contributionMonthlyAmount, + this.contributionPeriod! + ); } get contributionDescription(): string { @@ -119,8 +119,9 @@ export default class Contact { ) { return "None"; } else { - return `${config.currencySymbol}${this.contributionAmount}/${this.contributionPeriod === "monthly" ? "month" : "year" - }`; + return `${config.currencySymbol}${this.contributionAmount}/${ + this.contributionPeriod === "monthly" ? "month" : "year" + }`; } } diff --git a/src/tools/process-segments.ts b/src/tools/process-segments.ts index f0e6ad9d8..87b8459cf 100644 --- a/src/tools/process-segments.ts +++ b/src/tools/process-segments.ts @@ -53,7 +53,7 @@ async function processSegment(segment: Segment) { // Only fetch old contacts if we need to const oldContacts = segment.newsletterTag || - outgoingEmails.some((oe) => oe.trigger === "onLeave") + outgoingEmails.some((oe) => oe.trigger === "onLeave") ? await ContactsService.findByIds(oldSegmentContactIds) : []; diff --git a/src/type/content-data.ts b/src/type/content-data.ts index 2d80bfcd0..f41e05fdd 100644 --- a/src/type/content-data.ts +++ b/src/type/content-data.ts @@ -87,17 +87,17 @@ export interface ShareContentData { export type ContentData = Id extends "contacts" - ? ContactsContentData - : never | Id extends "email" - ? EmailContentData - : never | Id extends "general" - ? GeneralContentData - : never | Id extends "join" - ? JoinContentData - : never | Id extends "join/setup" - ? JoinSetupContentData - : never | Id extends "profile" - ? ProfileContentData - : never | Id extends "share" - ? ShareContentData - : never; + ? ContactsContentData + : never | Id extends "email" + ? EmailContentData + : never | Id extends "general" + ? GeneralContentData + : never | Id extends "join" + ? JoinContentData + : never | Id extends "join/setup" + ? JoinSetupContentData + : never | Id extends "profile" + ? ProfileContentData + : never | Id extends "share" + ? ShareContentData + : never; diff --git a/src/typings/index.d.ts b/src/typings/index.d.ts index 22f586ecc..c6d74e061 100644 --- a/src/typings/index.d.ts +++ b/src/typings/index.d.ts @@ -13,7 +13,7 @@ declare global { type URLSearchParams = never; namespace Express { - export interface User extends Contact { } + export interface User extends Contact {} export interface Request { flash( @@ -30,7 +30,7 @@ declare global { declare module "papaparse" { // eslint-disable-next-line @typescript-eslint/no-empty-interface - interface File { } + interface File {} } declare module "express-session" {